linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Need a meaningful memory measure out of /proc/meminfo
@ 2003-07-28  8:51 Denis Vlasenko
  2003-07-28  9:21 ` Denis Vlasenko
  0 siblings, 1 reply; 2+ messages in thread
From: Denis Vlasenko @ 2003-07-28  8:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: thomasez

[-- Attachment #1: Type: text/plain, Size: 3907 bytes --]

Hi. I want to calculate and give to user a terse info
(one or just a couple of numbers) about current memory
consumption. Since today's kernels typically use almost
all RAM for cacheing it is useless to just report amount
of RAM in use, it's nearly always is $total_ram-10k.

As a first approximation I took amount of allocated RAM
which will survive oom. Look (zero swap/highmem snipped):

$ cat /proc/meminfo;./oom;cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  262057984 235958272 26099712        0  3977216 126554112
Swap:        0        0        0
MemTotal:       255916 kB
MemFree:         25488 kB
MemShared:           0 kB
Buffers:          3884 kB
Cached:         123588 kB
Active:          65148 kB
Inactive:       144760 kB
LowTotal:       255916 kB
LowFree:         25488 kB
./oom: Killed
        total:    used:    free:  shared: buffers:  cached:
Mem:  262057984 108625920 153432064        0   479232  9801728
Swap:        0        0        0               ^        ^
MemTotal:       255916 kB                      |        |
MemFree:        149836 kB                      |        |
MemShared:           0 kB                      |        |
Buffers:           468 kB <-------- less than 1M        |
Cached:           9572 kB <-------- a 10M---------------+
Active:          24220 kB
Inactive:        68248 kB
LowTotal:       255916 kB
LowFree:        149836 kB

Ok, so I use Used-Buffers-Cached as a memory measure.
It remains almost unchanged across oom.

Although I am worried that I can lie to user because above test
shows that some 10M of buffers+cached are not really freeable.
Also I run this box swapless, what to do with swap numbers?

Please share your thoughs.

----BEGIN SHAMELESS PLUG SECTION----
Why do I need this? I found a little cute utility, nanotop,
in floppyfw project. It shows cpu load, mem load and eth load,
one line every second.

I started to play with it. I improved ability to parse command line,
specify update period, cpu bar size, which interface(s) to report,
made output even more terse. And hopefully made mem output somewhat
more meaningful.

Code is reworked to completely avoid <stdio.h> and made modular.
You can add code to monitor something else real easy now, swap
is already planned for 0.2 ;)

This toy compiles to a static binary under 4k with dietlibc.

I renamed it to nanometer, it really has not much in common with top.
Source and precompiled binary is in attached tarball.

Compare for yourself:

# ./nanotop
CPU [          ] MEM 219.6MB eth0:  35.00B/s rcv  18.00B/s snd  0 err
CPU [-         ] MEM 219.6MB eth0:   6.7kB/s rcv   1.6kB/s snd  0 err
CPU [-         ] MEM 219.6MB eth0:   4.8kB/s rcv   4.0kB/s snd  0 err
CPU [-         ] MEM 219.6MB eth0:   5.3kB/s rcv   1.5kB/s snd  0 err
CPU [-         ] MEM 219.6MB eth0:   3.6kB/s rcv   2.4kB/s snd  0 err
CPU [=-        ] MEM 219.6MB eth0:  74.3kB/s rcv  62.5kB/s snd  0 err
CPU [-         ] MEM 219.6MB eth0:   3.4kB/s rcv   2.4kB/s snd  0 err

# ./nanometer c m ieth0 ilo ieth1
cpu [??????????] mem  78M eth0   0    0  lo   0    0  eth1 ???? ????
cpu [..........] mem  78M eth0 4.0k 2.4k lo   0    0  eth1 ???? ????
cpu [..........] mem  78M eth0 9.6k 2.6k lo   0    0  eth1 ???? ????
cpu [UU........] mem  78M eth0  78k  64k lo 140  140  eth1 ???? ????
cpu [U.........] mem  78M eth0 7.6k 4.8k lo   0    0  eth1 ???? ????
cpu [UU........] mem  78M eth0 4.7k 9.2k lo   0    0  eth1 ???? ????
cpu [..........] mem  78M eth0 1.6k 1.3k lo   0    0  eth1 ???? ????
cpu [U.........] mem  78M eth0  10k 3.7k lo   0    0  eth1 ???? ????
cpu [..........] mem  78M eth0 152k 129k lo 140  140  eth1 ???? ????
cpu [SUUU......] mem  78M eth0 257k 171k lo   0    0  eth1 ???? ????
cpu [UUUUU.....] mem  78M eth0 352k 303k lo   0    0  eth1 ???? ????
cpu [SUUUU.....] mem  78M eth0 236k 232k lo   0    0  eth1 ???? ????
----END SHAMELESS PLUG SECTION----
--
vda

[-- Attachment #2: nanometer-0.1.tar.gz --]
[-- Type: application/x-gzip, Size: 6151 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-07-28  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-28  8:51 Need a meaningful memory measure out of /proc/meminfo Denis Vlasenko
2003-07-28  9:21 ` Denis Vlasenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).