BusyBox dynamic linked on uClibc for init? [resources usage] (fwd)

Denys Vlasenko vda.linux at googlemail.com
Fri May 13 02:02:56 UTC 2011


On Thursday 12 May 2011 15:03, Tomasz Czapiewski wrote:
> I have at least few megabytes of RAM for all BusyBox processes.
> Most of the time there are these applets used: echo, ps, cp, mv, mkdir, rm, 
> cat, grep, tee, pwd, ls, sed, awk, test, head, tail, httpd, mount, insmod, 
> lsmod, rmmod, kill, killall, ln,...
> and rarely: dd, mke2fs, flash_eraseall, tar, gzip, gunzip, ifconfig, cryptpw, 
> passwd, top, vi,...).

You need to understand your system's memory consumption better.

busybox top 's' command may help you to see memory usage more clearly.
Press 's' to sort by different field, 'r' to invert the sort.

Example:

Mem total:2054936 anon:231124 map:31872 free:394024
 slab:174244 buf:166772 cache:1067320 dirty:40 write:0
Swap total:131068 free:131068
  PID   VSZ VSZRW   RSS (SHR)*DIRTY (SHR) STACK COMMAND
 1458  108m 35652 63352 12236 44824     0  3016 kmail -caption KMail -icon kmail -miniicon kmail
...
 2216  5100   612  1828  1304   524     0   132 /bin/bash
 2155  2152   632   924   592   276     0   132 ksysguardd
 2084  2752   328   764   616   136     0   132 xinit
  875  1796   320   528   388   104     0   132 rpc.portmap
  960  1816   312   524   420    64     0   132 gpm -D -2 -m /dev/psaux -t ps2
 2144  1600   296   352   284    60     0   132 kwrapper ksmserver
^^^^^^^^^^^^^^^^^^^^^^ fat glibc-based stuff
vvvvvvvvvvvvvvvvvvvvvv bbox processes
24577   996   160   212   168    44     0   132 top
  929   984   148   152   120    32     0   132 runsvdir -P /var/service _____________________________________________
  943   984   148   180   152    28     0   132 svlogd -tt /var/log/service/klog
  854   188   148    56     4    24     0   132 udevd
 2061   980   144   200   164    24     0   132 ntpd -ddnNl -S ./ntp.script -p ..........
 1094   980   144   176   152    24     0   132 getty 38400 /dev/tty7 linux
 1177   980   144   152   128    24     0   132 svlogd -tt /var/log/service/vsftp
  982   168   152    36     0    24     0   132 socklog ucspi
 1186   984   148   188   152    24     0   132 crond -f -d7
 1192   980   144   160   136    24     0   132 tcpsvd -vE -l 0 -c 40 0 22 /usr/bin/sshd -i -D -e -p22 -u0
 1106   980   144   164   140    24     0   132 udpsvd -v -c 10 -l localhost 0 69 tftpd /pub/tftpd_root
    1   984   148   180   156    24     0   132 /bin/sh /init
 2099   984   148   216   172    24     0   132 /bin/sh /usr/bin/startkde
 1167   984   148   172   140    24     0   132 syslogd -m 0 -n -s 99 -b 9 -O /.local/var/service/syslog/syslog
 1104  1004   144   196     0    24     0   132 ./udhcpc -vv -C -o -V --foreground --interface=if --pidfile=/.local/var/service/dhcp_if/udhcpc.pid
  992   980   144   160   136    24     0   132 svlogd -tt /var/log/service/ftpd_bbox
 1127   980   144   148   128    20     0   132 svlogd -tt /var/log/service/httpd_ssl
 1181   980   144   148   128    20     0   132 svlogd -tt /var/log/service/fan_cpu0
 1004   976   140   136   116    20     0   132 runsv getty_tty3
 1108   980   144   156   136    20     0   132 svlogd -tt /var/log/service/tidy_tmp
  966   976   140   136   116    20     0   132 runsv ora_db_test1st
  932   976   140   136   116    20     0   132 runsv gpm
  964   976   140   136   116    20     0   132 runsv sshd
  939   980   144   148   128    20     0   132 svlogd -tt /var/log/service/dnsd
 1082   980   144   156   136    20     0   132 svlogd -tt /var/log/service/tftpd
 1128   980   144   148   128    20     0   132 svlogd -tt /var/log/service/dhcpd_if
 1123   980   144   156   136    20     0   132 svlogd -tt /var/log/service/ntpd
 1042   980   144   172   152    20     0   132 getty 38400 /dev/tty3 linux

Observations:

VSZ value of busybox processes is very close: because they are
*the same binary*, they share *the very same memory pages for code*.
The difference in only in their data areas.

How big is each data area for each process?

Well, for one, dynamic data *has to be* RW, not RO.
Therefore, VSZRW is much better indicator for "how much mem
this process uses up?" type questions.

But even this column overestimates usage, because:
- almost every process-private data page is rw, but
- many rw pages are shared (because they aren't really modified yet)

Therefore, DIRTY column is more precise indicator
for "how much modified memory data (which can newer be shared
with outher processes) this process has?"

As you see, for bbox processes DIRTY is tiny.

-- 
vda




More information about the busybox mailing list