Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
soc:2010:cooldavid:notes:gpxememlayout [2010/06/02 12:45]
cooldavid created
soc:2010:cooldavid:notes:gpxememlayout [2010/06/02 13:12] (current)
cooldavid
Line 99: Line 99:
 </​file>​ </​file>​
  
-==== Current memory ​usage ====+==== Memory ​usage ==== 
 +We can see the current memory usage by the symbols 
 +exported by linker. Which is defined in the linker 
 +script mentioned in the previours section.
  
 +For ''​i386.lds'',​ if we want to know how much memory
 +was used. We can simply check for _etextdata, or _stack.
 +
 +The heap was declared as globle variable in ''​src/​core/​malloc.c'',​
 +which would put in bss section. We can get its address by:
 +== objdump -t bin/​gpxe.pxe.tmp | grep ' heap$' ==
 +<​file>​
 +000b3c5c l     O .bss.textdata ​ 00020000 heap
 +</​file>​
 +
 +As long as the _stack plus real stack usage at runtime dose
 +not exceed 1MB, we should be safe.
 +
 +We can also exam the what symbol cost most memory size by:
 +== readelf -W -s bin/​gpxe.pxe.tmp | sort -n -k 3 | tail ==
 +<​file>​
 +   463: 0007c7a4 ​ 6104 OBJECT ​ LOCAL  DEFAULT ​   5 bnx2_rv2p_proc2
 +  1337: 000a505c ​ 6320 OBJECT ​ LOCAL  DEFAULT ​   6 rxb
 +  3869: 00091738 ​ 8192 OBJECT ​ GLOBAL HIDDEN ​   5 linda_ib_fw
 +  1351: 000a6f4c ​ 9084 OBJECT ​ LOCAL  DEFAULT ​   6 rx_buffer
 +   391: 00094e9c ​ 9348 OBJECT ​ LOCAL  DEFAULT ​   6 amd8111e
 +   469: 00083838 22348 OBJECT ​ LOCAL  DEFAULT ​   5 bnx2_TXP_b06FwText
 +   479: 0008a1b4 22464 OBJECT ​ LOCAL  DEFAULT ​   5 bnx2_COM_b06FwText
 +   464: 0007df7c 22672 OBJECT ​ LOCAL  DEFAULT ​   5 bnx2_RXP_b06FwText
 +   461: 00099874 41848 OBJECT ​ LOCAL  DEFAULT ​   6 bnx2_bss
 +  1344: 000a92c8 43064 OBJECT ​ LOCAL  DEFAULT ​   6 virtqueue
 +</​file>​
 +The number bigger than 5 digits in decimal, were displayed as hex.
 +== readelf -W -s bin/​gpxe.pxe.tmp | grep ' 0x[0-9]\+ ' ==
 +<​file>​
 +  2052: 000b3c5c 0x20000 OBJECT ​ LOCAL  DEFAULT ​   6 heap
 +  3141: 000d4100 0x18808 OBJECT ​ GLOBAL HIDDEN ​   6 _shared_bss
 +</​file>​

QR Code
QR Code soc:2010:cooldavid:notes:gpxememlayout (generated for current page)