Hi,
Ok, so I did the work myself for those who are interested :
before :
total used free shared buffers cached
Mem: 33088172 9587560 23500612 0 921836 6832320
-/+ buffers/cache: 1833404 31254768
Swap: 33554424 0 33554424
after :
total used free shared buffers
cached slab
Mem: 33088172 9587684 23500488 0 921832
6832320 1660240
-/+ buffers/cache/slab: 173292 32914880
Swap: 33554424 0 33554424
this is more realistic, this server have nothing launched but sshd,
syslog, getty etc ..
Regards.
Nicolas
2010/1/18 Craig Small <[email protected]>:
> tags 565518 upstream
> thankyou
> On Sun, Jan 17, 2010 at 11:28:19PM +0100, Nico wrote:
>> slab cache usage (after the find/updatedb with a scan of all the
>> filesystem). This kind of memory usage
>> does not reflect user point of view,
>> because as soon as a program request memory, slab cache is reduced and
>> this memory can be used for userspace programs.
> There is a lot of that going on, which is why its difficult to know in
> Linux what your "real" memory usage is.
>
>> Yes ! exact, that's what I am saying.
>> You can monitor slab usage in /proc/meminfo or with the "slabtop"
>> command, but "free" does not take into account
>> the slab cache.
> That would be due to the fact the kernel figures don't either.
>
>> I don't know what to do, the user point of view (me and others, for
>> instance https://bugs.launchpad.net/ubuntu/+source/procps/+bug/126329
>> ) is the free command doesnt reflect any more the
>> memory used by programs, I cannot say if the answer is changing the
>> kernel /proc interface or modifing userland "free"
> We definitely will not be modifying the Debian version alone, as this
> will mean you get different answers depending on the distribution.
>
> - Craig
>
> --
> Craig Small GnuPG:1C1B D893 1418 2AF4 45EE 95CB C76C E5AC 12CA DFA5
> http://www.enc.com.au/ csmall at : enc.com.au
> http://www.debian.org/ Debian GNU/Linux, software should be Free
>
diff -ur procps-3.2.8.orig/free.c procps-3.2.8/free.c
--- procps-3.2.8.orig/free.c 2004-01-30 03:30:29.000000000 +0100
+++ procps-3.2.8/free.c 2010-01-24 11:44:45.000000000 +0100
@@ -61,15 +61,16 @@
do {
meminfo();
- printf(" total used free shared buffers cached\n");
+ printf(" total used free shared buffers cached slab\n");
printf(
- "%-7s %10Lu %10Lu %10Lu %10Lu %10Lu %10Lu\n", "Mem:",
+ "%-7s %10Lu %10Lu %10Lu %10Lu %10Lu %10Lu %10Lu\n", "Mem:",
S(kb_main_total),
S(kb_main_used),
S(kb_main_free),
S(kb_main_shared),
S(kb_main_buffers),
- S(kb_main_cached)
+ S(kb_main_cached),
+ S(kb_slab_reclaimable)
);
// Print low vs. high information, if the user requested it.
// Note we check if low_total==0: if so, then this kernel does
@@ -77,35 +78,35 @@
// print the high info, even if it is zero.
if (show_high) {
printf(
- "%-7s %10Lu %10Lu %10Lu\n", "Low:",
+ "%-7s %10Lu %10Lu %10Lu\n", "Low:",
S(kb_low_total),
S(kb_low_total - kb_low_free),
S(kb_low_free)
);
printf(
- "%-7s %10Lu %10Lu %10Lu\n", "High:",
+ "%-7s %10Lu %10Lu %10Lu\n", "High:",
S(kb_high_total),
S(kb_high_total - kb_high_free),
S(kb_high_free)
);
}
if(!old_fmt){
- unsigned KLONG buffers_plus_cached = kb_main_buffers + kb_main_cached;
+ unsigned KLONG buffers_plus_cached = kb_main_buffers + kb_main_cached + kb_slab_reclaimable;
printf(
- "-/+ buffers/cache: %10Lu %10Lu\n",
+ "-/+ buffers/cache/slab: %10Lu %10Lu\n",
S(kb_main_used - buffers_plus_cached),
S(kb_main_free + buffers_plus_cached)
);
}
printf(
- "%-7s %10Lu %10Lu %10Lu\n", "Swap:",
+ "%-7s %10Lu %10Lu %10Lu\n", "Swap:",
S(kb_swap_total),
S(kb_swap_used),
S(kb_swap_free)
);
if(show_total){
printf(
- "%-7s %10Lu %10Lu %10Lu\n", "Total:",
+ "%-7s %10Lu %10Lu %10Lu\n", "Total:",
S(kb_main_total + kb_swap_total),
S(kb_main_used + kb_swap_used),
S(kb_main_free + kb_swap_free)
diff -ur procps-3.2.8.orig/proc/library.map procps-3.2.8/proc/library.map
--- procps-3.2.8.orig/proc/library.map 2005-03-14 05:32:40.000000000 +0100
+++ procps-3.2.8/proc/library.map 2010-01-24 11:41:35.000000000 +0100
@@ -18,6 +18,7 @@
kb_main_free; kb_main_total; kb_main_used; kb_swap_free;
kb_swap_total; kb_swap_used; kb_main_shared;
kb_low_total; kb_low_free; kb_high_total; kb_high_free;
+ kb_slab_reclaimable;
vm_pgpgin; vm_pgpgout; vm_pswpin; vm_pswpout;
free_slabinfo; put_slabinfo; get_slabinfo; get_proc_stats;
local: *;
diff -ur procps-3.2.8.orig/proc/sysinfo.c procps-3.2.8/proc/sysinfo.c
--- procps-3.2.8.orig/proc/sysinfo.c 2008-03-24 05:33:43.000000000 +0100
+++ procps-3.2.8/proc/sysinfo.c 2010-01-24 11:42:11.000000000 +0100
@@ -538,8 +538,8 @@
static unsigned long kb_bounce;
static unsigned long kb_commit_limit;
static unsigned long kb_nfs_unstable;
-static unsigned long kb_swap_reclaimable;
-static unsigned long kb_swap_unreclaimable;
+unsigned long kb_slab_reclaimable;
+unsigned long kb_slab_unreclaimable;
void meminfo(void){
char namebuf[16]; /* big enough to hold any row name */
@@ -572,8 +572,8 @@
{"NFS_Unstable", &kb_nfs_unstable},
{"PageTables", &kb_pagetables}, // kB version of vmstat nr_page_table_pages
{"ReverseMaps", &nr_reversemaps}, // same as vmstat nr_page_table_pages
- {"SReclaimable", &kb_swap_reclaimable}, // "swap reclaimable" (dentry and inode structures)
- {"SUnreclaim", &kb_swap_unreclaimable},
+ {"SReclaimable", &kb_slab_reclaimable}, // "slab reclaimable" (dentry and inode structures)
+ {"SUnreclaim", &kb_slab_unreclaimable},
{"Slab", &kb_slab}, // kB version of vmstat nr_slab
{"SwapCached", &kb_swap_cached},
{"SwapFree", &kb_swap_free}, // important
@@ -586,9 +586,7 @@
const int mem_table_count = sizeof(mem_table)/sizeof(mem_table_struct);
FILE_TO_BUF(MEMINFO_FILE,meminfo_fd);
-
kb_inactive = ~0UL;
-
head = buf;
for(;;){
tail = strchr(head, ':');
diff -ur procps-3.2.8.orig/proc/sysinfo.h procps-3.2.8/proc/sysinfo.h
--- procps-3.2.8.orig/proc/sysinfo.h 2006-06-25 08:41:48.000000000 +0200
+++ procps-3.2.8/proc/sysinfo.h 2010-01-24 11:37:01.000000000 +0100
@@ -54,6 +54,10 @@
extern unsigned long kb_mapped;
extern unsigned long kb_pagetables;
+extern unsigned long kb_slab_reclaimable;
+extern unsigned long kb_slab_unreclaimable;
+
+
#define BUFFSIZE (64*1024)
typedef unsigned long long jiff;
extern void getstat(jiff *restrict cuse, jiff *restrict cice, jiff *restrict csys, jiff *restrict cide, jiff *restrict ciow, jiff *restrict cxxx, jiff *restrict cyyy, jiff *restrict czzz,