Mar 26, 2014

Unix as IDE. Memmory profiling

cat /proc/meminfo
#MemTotal:       16350248 kB
#MemFree:        14502016 kB
#Buffers:          133516 kB
#Cached:           738584 kB
#..
#Mapped:           106640 kB
#Shmem:             78664 kB
#Slab:             101588 kB
#SReclaimable:      81208 kB
#SUnreclaim:        20380 kB
#KernelStack:        3000 kB
#PageTables:        18616 kB
#..
cat /proc/iomem 
#00000000-00000fff : reserved
#00001000-0009d7ff : System RAM
#0009d800-0009ffff : reserved
#000a0000-000bffff : PCI Bus 0000:00
#000c0000-000c7fff : Video ROM
#...
cat /proc/pagetypeinfo
#Page block order: 9
#Pages per block:  512
#
# ...
#
#Number of blocks type     Unmovable  Reclaimable      Movable      Reserve      Isolate 
#Node 0, zone      DMA            1            0            6            1            0 
#Node 0, zone    DMA32            8           32         1742            2            0 
#Node 0, zone   Normal          222           94         6069            2            0

cat /proc/buddyinfo 
#Node 0, zone      DMA      0      0      0      0      0      0      0      0      1      1      3 
#Node 0, zone    DMA32   1734   1323    616    162     59     32     10     13      7      3    749 
#Node 0, zone   Normal   2712   3081   1760    654    320    144     51     27     27     12   2728

sudo cat /proc/slabinfo
sudo slabtop
Shared Memory Segments
ipcs -m
#------ Shared Memory Segments --------
#key        shmid      owner      perms      bytes      nattch     status      
#0x00000000 0          alex       600        393216     2          dest         
#0x00000000 360449     alex       600        4194304    2          dest         
#0x00000000 196610     alex       600        2097152    2          dest         
#0x00000000 229379     alex       600        1048576    2          dest
ipcs -m -p
#
#------ Shared Memory Creator/Last-op PIDs --------
#shmid      owner      cpid       lpid      
#0          alex       3613       4418      
#360449     alex       3993       4418      
#196610     alex       3317       4418      
#229379     alex       3613       4418

Mar 23, 2014

Qemu. Mips cpu virtualization

About MIPS architecture

Download initrd.gz and vmlinux-3.2.0-4-4kc-malta from http://ftp.debian.org/debian/dists/stable/main/installer-mips/current/images/malta/netboot/
# install
qemu-system-mips -M malta -kernel vmlinux-3.2.0-4-4kc-malta -initrd initrd.gz \
 -hda debian74_mips.img  -append "root=/dev/sda1 console=ttyS0" -nographic

# boot
qemu-system-mips -M malta -kernel vmlinux-3.2.0-4-4kc-malta \
 -hda debian74_mips.img -append "root=/dev/sda1 console=ttyS0" -nographic

On guest host:
uname -a
# Linux debianmips 3.2.0-4-4kc-malta #1 Debian 3.2.54-2 mips GNU/Linux

cat /proc/cpuinfo 
# system type  : MIPS Malta
# processor  : 0
# cpu model  : MIPS 24Kc V0.0  FPU V0.0
mips hello world (http://en.wikipedia.org/wiki/MIPS_architecture#MIPS_assembly_language):
00400640 <main>:
#include <stdio.h>

int main() {
  400640: 27bdffe0  addiu sp,sp,-32
  400644: afbf001c  sw ra,28(sp)
  400648: afbe0018  sw s8,24(sp)
  40064c: 03a0f021  move s8,sp
    printf("Hello world!\n");
  400650: 3c020040  lui v0,0x40
  400654: 24440810  addiu a0,v0,2064
  400658: 0c100140  jal 400500 <puts@plt>
  40065c: 00200825  move at,at
    return 0;
  400660: 00001021  move v0,zero
}
  400664: 03c0e821  move sp,s8
  400668: 8fbf001c  lw ra,28(sp)
  40066c: 8fbe0018  lw s8,24(sp)
  400670: 27bd0020  addiu sp,sp,32
  400674: 03e00008  jr ra
  400678: 00200825  move at,at
  40067c: 00200825  move at,at
i386 hello world:
0804840c <main>:
#include <stdio.h>

int main() {
 804840c: 55                    push   ebp
 804840d: 89 e5                 mov    ebp,esp
 804840f: 83 e4 f0              and    esp,0xfffffff0
 8048412: 83 ec 10              sub    esp,0x10
    printf("Hello world!\n");
 8048415: c7 04 24 c0 84 04 08  mov    DWORD PTR [esp],0x80484c0
 804841c: e8 cf fe ff ff        call   80482f0 <puts@plt>
    return 0;
 8048421: b8 00 00 00 00        mov    eax,0x0
}
 8048426: c9                    leave  
 8048427: c3                    ret    
 8048428: 90                    nop
 8048429: 90                    nop
 804842a: 90                    nop
 804842b: 90                    nop
 804842c: 90                    nop
 804842d: 90                    nop
 804842e: 90                    nop
 804842f: 90                    nop
x64 hello world:
00000000004004fd <main>:
#include <stdio.h>

int main() {
  4004fd: 55                    push   rbp
  4004fe: 48 89 e5              mov    rbp,rsp
    printf("Hello world!\n");
  400501: bf a4 05 40 00        mov    edi,0x4005a4
  400506: e8 d5 fe ff ff        call   4003e0 <puts@plt>
    return 0;
  40050b: b8 00 00 00 00        mov    eax,0x0
}
  400510: 5d                    pop    rbp
  400511: c3                    ret    
  400512: 66 2e 0f 1f 84 00 00  nop    WORD PTR cs:[rax+rax*1+0x0]
  400519: 00 00 00 
  40051c: 0f 1f 40 00           nop    DWORD PTR [rax+0x0]

Instructions for other archs with qemu:
https://gmplib.org/~tege/qemu.html

Mar 18, 2014

Terminal


Oblivion
text color #D3D7CF
background color #2E3436

Inconsolata Medium 13

Tango
gconftool --set --type string /apps/gnome-terminal/profiles/Default/palette \ 
'#3b3b3b:#cf6a4c:#99ad6a:#d8ad4c:#597bc5:#a037b0:#71b9f8:#adadad:#636363:#f79274:#c1d592:#ffd574:#81a3ed:#c85fd8:#99e1ff:#d5d5d5'