111 lines
4.0 KiB
Diff
111 lines
4.0 KiB
Diff
---
|
|
free.1 | 6 ++++++
|
|
free.c | 6 +++++-
|
|
proc/sysinfo.c | 16 ++++++++++------
|
|
proc/sysinfo.h | 5 +++++
|
|
4 files changed, 26 insertions(+), 7 deletions(-)
|
|
|
|
--- free.1
|
|
+++ free.1 2015-01-23 15:25:22.093559404 +0000
|
|
@@ -48,6 +48,13 @@ display the units of print out. Followi
|
|
If unit is missing, and you have petabyte of RAM or swap, the number is in
|
|
terabytes and columns might not be aligned with header.
|
|
.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,
|
|
+the \fBSReclaimable\fR as part of \fISlab\fR, that might be reclaimed, such as caches,
|
|
+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 2015-01-23 15:14:07.186228830 +0000
|
|
@@ -213,6 +213,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, 'C' },
|
|
{ "help", no_argument, NULL, HELP_OPTION },
|
|
{ "version", no_argument, NULL, 'V' },
|
|
{ NULL, 0, NULL, 0 }
|
|
@@ -231,7 +232,7 @@ int main(int argc, char **argv)
|
|
textdomain(PACKAGE);
|
|
atexit(close_stdout);
|
|
|
|
- while ((c = getopt_long(argc, argv, "bkmghlotc:s:V", longopts, NULL)) != -1)
|
|
+ while ((c = getopt_long(argc, argv, "bkmghlotCc:s:V", longopts, NULL)) != -1)
|
|
switch (c) {
|
|
case 'b':
|
|
args.exponent = 1;
|
|
@@ -281,6 +282,9 @@ int main(int argc, char **argv)
|
|
error(EXIT_FAILURE, ERANGE,
|
|
_("failed to parse count argument: '%s'"), optarg);
|
|
break;
|
|
+ case 'C':
|
|
+ setenv("PS_FULL_CACHE", "yes", 1);
|
|
+ break;
|
|
case HELP_OPTION:
|
|
usage(stdout);
|
|
case 'V':
|
|
--- proc/sysinfo.c
|
|
+++ proc/sysinfo.c 2015-01-23 15:08:35.381519221 +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
|
|
@@ -598,17 +599,18 @@ static unsigned long kb_vmalloc_chunk;
|
|
static unsigned long kb_vmalloc_total;
|
|
static unsigned long kb_vmalloc_used;
|
|
// seen on 2.6.24-rc6-git12
|
|
-static unsigned long kb_anon_pages;
|
|
-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_anon_pages;
|
|
+unsigned long kb_bounce;
|
|
+unsigned long kb_commit_limit;
|
|
+unsigned long kb_nfs_unstable;
|
|
+unsigned long kb_swap_reclaimable;
|
|
+unsigned long kb_swap_unreclaimable;
|
|
|
|
void meminfo(void){
|
|
char namebuf[16]; /* big enough to hold any row name */
|
|
mem_table_struct findme = { namebuf, NULL};
|
|
mem_table_struct *found;
|
|
+ const char *ev;
|
|
char *head;
|
|
char *tail;
|
|
static const mem_table_struct mem_table[] = {
|
|
@@ -684,6 +686,8 @@ nextline:
|
|
}
|
|
kb_swap_used = kb_swap_total - kb_swap_free;
|
|
kb_main_used = kb_main_total - kb_main_free;
|
|
+ if ((ev=getenv("PS_FULL_CACHE")))
|
|
+ kb_main_cached += kb_swap_reclaimable + kb_swap_cached + kb_nfs_unstable;
|
|
}
|
|
|
|
/*****************************************************************/
|
|
--- proc/sysinfo.h
|
|
+++ proc/sysinfo.h 2012-06-01 15:10:57.000000000 +0000
|
|
@@ -31,6 +31,11 @@ extern unsigned long kb_main_total;
|
|
extern unsigned long kb_swap_free;
|
|
extern unsigned long kb_swap_total;
|
|
/* recently introduced */
|
|
+extern unsigned long kb_anon_pages;
|
|
+extern unsigned long kb_bounce;
|
|
+extern unsigned long kb_nfs_unstable;
|
|
+extern unsigned long kb_slab_reclaimable;
|
|
+extern unsigned long kb_slab_unreclaimable;
|
|
extern unsigned long kb_high_free;
|
|
extern unsigned long kb_high_total;
|
|
extern unsigned long kb_low_free;
|