--- free.1 | 6 ++++++ free.c | 7 ++++++- proc/sysinfo.c | 4 ++++ vmstat.c | 6 +++++- 4 files changed, 21 insertions(+), 2 deletions(-) --- free.1 +++ free.1 2019-12-11 06:20:16.659772479 +0000 @@ -100,6 +100,12 @@ Switch to the wide mode. The wide mode p than 80 characters. In this mode \fBbuffers\fR and \fBcache\fR are reported in two separate columns. .TP +\fB\-C\fR, \fB\-\-full\-cache\fR +Add to the plain \fBCached\fR in-memory cache for files also more cache lines as +the \fBNFS_Unstable\fR pages sent to the server, but not yet committed to stable storage +and the \fBSwapCached\fR memory that once was swapped out but is swapped back. +Can be also enabled by the environment variable \fBPS_FULL_CACHE\fR. +.TP \fB\-c\fR, \fB\-\-count\fR \fIcount\fR Display the result .I count --- free.c +++ free.c 2019-12-11 06:20:16.659772479 +0000 @@ -90,6 +90,7 @@ static void __attribute__ ((__noreturn__ fputs(_(" -t, --total show total for RAM + swap\n"), out); fputs(_(" -s N, --seconds N repeat printing every N seconds\n"), out); fputs(_(" -c N, --count N repeat printing N times, then exit\n"), out); + fputs(_(" -C, --full-cache add further cache lines to main cache\n"), out); fputs(_(" -w, --wide wide output\n"), out); fputs(USAGE_SEPARATOR, out); fputs(_(" --help display this help and exit\n"), out); @@ -231,6 +232,7 @@ int main(int argc, char **argv) { "total", no_argument, NULL, 't' }, { "seconds", required_argument, NULL, 's' }, { "count", required_argument, NULL, 'c' }, + { "full-cache",required_argument, NULL, HELP_OPTION }, { "wide", no_argument, NULL, 'w' }, { "help", no_argument, NULL, HELP_OPTION }, { "version", no_argument, NULL, 'V' }, @@ -250,7 +252,7 @@ int main(int argc, char **argv) textdomain(PACKAGE); atexit(close_stdout); - while ((c = getopt_long(argc, argv, "bkmghltc:ws:V", longopts, NULL)) != -1) + while ((c = getopt_long(argc, argv, "bkmghltCc:ws:V", longopts, NULL)) != -1) switch (c) { case 'b': check_unit_set(&unit_set); @@ -333,6 +335,9 @@ int main(int argc, char **argv) case 'w': flags |= FREE_WIDE; break; + case 'C': + setenv("PS_FULL_CACHE", "yes", 1); + break; case HELP_OPTION: usage(stdout); case 'V': --- proc/sysinfo.c +++ proc/sysinfo.c 2019-12-11 06:20:16.659772479 +0000 @@ -3,6 +3,7 @@ * Copyright (C) 1992-1998 by Michael K. Johnson, johnsonm@redhat.com * Copyright 1998-2003 Albert Cahalan * June 2003, Fabian Frederick, disk and slab info + * Copyright (c) 2008 Bart Van Assche. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -700,6 +701,7 @@ void meminfo(void){ int linux_version_code = procps_linux_version(); mem_table_struct findme = { namebuf, NULL}; mem_table_struct *found; + const char *ev; char *head; char *tail; static const mem_table_struct mem_table[] = { @@ -779,6 +781,8 @@ nextline: kb_inactive = kb_inact_dirty + kb_inact_clean + kb_inact_laundry; } kb_main_cached = kb_page_cache + kb_slab_reclaimable; + if ((ev=getenv("PS_FULL_CACHE"))) + kb_main_cached += kb_swap_cached + kb_nfs_unstable; kb_swap_used = kb_swap_total - kb_swap_free; /* if kb_main_available is greater than kb_main_total or our calculation of --- vmstat.c +++ vmstat.c 2019-12-11 06:22:44.716984764 +0000 @@ -103,6 +103,7 @@ static void __attribute__ ((__noreturn__ fputs(_(" -p, --partition partition specific statistics\n"), out); fputs(_(" -S, --unit define display unit\n"), out); fputs(_(" -w, --wide wide output\n"), out); + fputs(_(" -C, --full-cache add further cache lines to main cache\n"), out); fputs(_(" -t, --timestamp show timestamp\n"), out); fputs(USAGE_SEPARATOR, out); fputs(USAGE_HELP, out); @@ -899,7 +900,7 @@ int main(int argc, char *argv[]) atexit(close_stdout); while ((c = - getopt_long(argc, argv, "afmnsdDp:S:wthV", longopts, + getopt_long(argc, argv, "aCfmnsdDp:S:wthV", longopts, NULL)) != -1) switch (c) { case 'V': @@ -968,6 +969,9 @@ int main(int argc, char *argv[]) case 't': t_option = 1; break; + case 'C': + setenv("PS_FULL_CACHE", "yes", 1); + break; default: /* no other aguments defined yet. */ usage(stderr);