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

* Re: Need a meaningful memory measure out of /proc/meminfo
  2003-07-28  8:51 Need a meaningful memory measure out of /proc/meminfo Denis Vlasenko
@ 2003-07-28  9:21 ` Denis Vlasenko
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Vlasenko @ 2003-07-28  9:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: thomasez

On 28 July 2003 11:51, Denis Vlasenko wrote:
> 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?

FYI: this is how oom looks like under nanometer (with swap reporting added):
# nanometer d500 c m s ieth0 ilo
cpu [..........] mem  85M/247M swp 428k eth0 4.2k 3.0k lo   0    0
cpu [..........] mem  85M/247M swp 428k eth0 2.0k 1.7k lo   0    0
cpu [..........] mem  85M/247M swp 428k eth0 5.3k 5.6k lo   0    0
cpu [SSSSU.....] mem 119M/247M swp 428k eth0 3.1k 2.8k lo   0    0
cpu [SSSSSSSSSS] mem 157M/247M swp 4.0M eth0 5.0k 3.8k lo   0    0
cpu [SSSSSU....] mem 171M/247M swp 5.0M eth0 8.0k 4.0k lo 140  140
cpu [SSSSSSSSS.] mem 205M/247M swp  10M eth0 5.1k 3.3k lo   0    0
cpu [SSSS......] mem 205M/247M swp  20M eth0  76k  59k lo   0    0
cpu [SSSS......] mem 211M/247M swp  25M eth0  47k 5.7k lo   0    0
cpu [SSSSSS....] mem 221M/247M swp  32M eth0 391k 9.5k lo   0    0
cpu [SSS.......] mem 220M/247M swp  39M eth0  31k 4.2k lo   0    0
cpu [SSSS......] mem 220M/247M swp  51M eth0 7.9k 840  lo   0    0
cpu [SSSS......] mem 222M/247M swp  58M eth0  92k 7.8k lo   0    0
cpu [SS........] mem 222M/247M swp  60M eth0  85k 5.6k lo   0    0
cpu [SSSS......] mem 225M/247M swp  65M eth0  76k 4.9k lo 140  140
cpu [SSSS......] mem 227M/247M swp  72M eth0  54k 4.5k lo   0    0
cpu [SSSSSS....] mem 229M/247M swp  74M eth0 4.5k 3.2k lo   0    0
cpu [SSSSSSSSSS] mem 232M/247M swp  74M eth0  45k  35k lo   0    0
cpu [SSSSSSSSSS] mem 231M/247M swp  74M eth0 107k  29k lo   0    0
cpu [SSSSSSSSSS] mem 232M/247M swp  74M eth0 171k 6.2k lo   0    0
cpu [SSSSSSSSSS] mem 232M/247M swp  74M eth0 2.3k 1.8k lo   0    0
cpu [SSSSSSSSSS] mem 232M/247M swp  74M eth0 5.7k 5.4k lo   0    0
cpu [SSSSSSSSSS] mem 232M/247M swp  74M eth0  40k 2.9k lo   0    0
cpu [SSSSSSSSSS] mem 236M/247M swp  74M eth0 342k 9.6k lo   0    0
cpu [SSSSSSSSSS] mem 239M/247M swp  74M eth0 3.0k 2.5k lo   0    0
cpu [SSSSSSSSSS] mem 240M/247M swp  74M eth0 6.2k 4.4k lo   0    0
cpu [SSSSSSSSSS] mem 240M/247M swp  74M eth0 313k  26k lo   0    0
cpu [SSSSSSSSSS] mem 240M/247M swp  74M eth0 124k  35k lo   0    0
cpu [SSSSSSSSSS] mem 241M/247M swp  74M eth0  21k  16k lo   0    0
cpu [SSSSSS....] mem  28M/247M swp  60M eth0 380k  15k lo   0    0
cpu [..........] mem  27M/247M swp  61M eth0  10k 5.7k lo   0    0
cpu [..........] mem  27M/247M swp  61M eth0 2.8k 2.1k lo   0    0

# cat /proc/swaps
Filename                        Type            Size    Used    Priority
/mnt/auto/vfat.hda3/PAGEFILE    file            76792   54400   -1

At oom, mem reporting was showing ~6 meg as still free...
I want to do better.
--
vda

^ 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).