free: reusing 'shared' for Shmem

Previously the shared memory column was always zero
for 2.6 series kernels (and later) due to the fact,
that the value was taken from the MemShared entry
that disappeared with 2.6 series kernels.
Later a new Shmem entry appeared in the /proc/meminfo
file and the 'shared' column now displays either
the MemShared or the Shmem value (depending on their
presence - the presence is mutually exclusive).
If none of the two entries is exported by the kernel,
then the column is zero.
This commit is contained in:
Jaromir Capik 2013-08-07 18:21:43 +02:00
parent 5f663aee47
commit 9315d00f01
2 changed files with 7 additions and 3 deletions

7
free.1
View File

@ -11,8 +11,11 @@ free \- Display amount of free and used memory in the system
.SH DESCRIPTION .SH DESCRIPTION
.B free .B free
displays the total amount of free and used physical and swap memory in the displays the total amount of free and used physical and swap memory in the
system, as well as the buffers used by the kernel. The shared memory column system, as well as the buffers used by the kernel.
should be ignored; it is obsolete. The shared memory column represents either the MemShared value (2.4 series
kernels) or the Shmem value (2.6 series kernels and later) taken from the
/proc/meminfo file. The value is zero if none of the entries is exported
by the kernel.
.SH OPTIONS .SH OPTIONS
.TP .TP
\fB\-b\fR, \fB\-\-bytes\fR \fB\-b\fR, \fB\-\-bytes\fR

View File

@ -629,13 +629,14 @@ void meminfo(void){
{"LowTotal", &kb_low_total}, {"LowTotal", &kb_low_total},
{"Mapped", &kb_mapped}, // kB version of vmstat nr_mapped {"Mapped", &kb_mapped}, // kB version of vmstat nr_mapped
{"MemFree", &kb_main_free}, // important {"MemFree", &kb_main_free}, // important
{"MemShared", &kb_main_shared}, // important, but now gone! {"MemShared", &kb_main_shared}, // obsolete since kernel 2.6! (sharing the variable with Shmem replacement)
{"MemTotal", &kb_main_total}, // important {"MemTotal", &kb_main_total}, // important
{"NFS_Unstable", &kb_nfs_unstable}, {"NFS_Unstable", &kb_nfs_unstable},
{"PageTables", &kb_pagetables}, // kB version of vmstat nr_page_table_pages {"PageTables", &kb_pagetables}, // kB version of vmstat nr_page_table_pages
{"ReverseMaps", &nr_reversemaps}, // same as 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) {"SReclaimable", &kb_swap_reclaimable}, // "swap reclaimable" (dentry and inode structures)
{"SUnreclaim", &kb_swap_unreclaimable}, {"SUnreclaim", &kb_swap_unreclaimable},
{"Shmem", &kb_main_shared}, // kernel 2.6 and later (sharing the output variable with obsolete MemShared)
{"Slab", &kb_slab}, // kB version of vmstat nr_slab {"Slab", &kb_slab}, // kB version of vmstat nr_slab
{"SwapCached", &kb_swap_cached}, {"SwapCached", &kb_swap_cached},
{"SwapFree", &kb_swap_free}, // important {"SwapFree", &kb_swap_free}, // important