free: option to show memory commit limits
This commit is largely the userland only changes found in !73 added by Jens Låås (@jelaas) References: procps-ng/procps!73
This commit is contained in:
parent
9bebdf2ab3
commit
16734d580e
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
|||||||
procps-ng-NEXT
|
procps-ng-NEXT
|
||||||
---------------
|
---------------
|
||||||
* Rename pwait to pidwait
|
* Rename pwait to pidwait
|
||||||
|
* free: Add committed line option merge #25
|
||||||
* library: renamed to libproc-2 and reset to 0:0:0
|
* library: renamed to libproc-2 and reset to 0:0:0
|
||||||
* library: add support for accessing smaps_rollup issue #112, #201
|
* library: add support for accessing smaps_rollup issue #112, #201
|
||||||
* pkill: Check for lt- variants of program name issue #192
|
* pkill: Check for lt- variants of program name issue #192
|
||||||
|
7
free.1
7
free.1
@ -2,7 +2,7 @@
|
|||||||
.\" This page Copyright (C) 1993 Matt Welsh, mdw@sunsite.unc.edu.
|
.\" This page Copyright (C) 1993 Matt Welsh, mdw@sunsite.unc.edu.
|
||||||
.\" Long options where added at April 15th, 2011.
|
.\" Long options where added at April 15th, 2011.
|
||||||
.\" Freely distributable under the terms of the GPL
|
.\" Freely distributable under the terms of the GPL
|
||||||
.TH FREE 1 "2018-05-31" "procps-ng" "User Commands"
|
.TH FREE 1 "2020-06-16" "procps-ng" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
free \- Display amount of free and used memory in the system
|
free \- Display amount of free and used memory in the system
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -124,6 +124,11 @@ of 1024).
|
|||||||
\fB\-t\fR, \fB\-\-total\fR
|
\fB\-t\fR, \fB\-\-total\fR
|
||||||
Display a line showing the column totals.
|
Display a line showing the column totals.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-v\fR, \fB\-\-committed\fR
|
||||||
|
Display a line showing the memory commit limit and amount of committed/uncommitted
|
||||||
|
memory. The \fBtotal\fR column on this line will display the memory commit
|
||||||
|
limit. This line is relevant if memory overcommit is disabled.
|
||||||
|
.TP
|
||||||
\fB\-\-help\fR
|
\fB\-\-help\fR
|
||||||
Print help.
|
Print help.
|
||||||
.TP
|
.TP
|
||||||
|
18
free.c
18
free.c
@ -54,6 +54,7 @@
|
|||||||
#define FREE_SI (1 << 5)
|
#define FREE_SI (1 << 5)
|
||||||
#define FREE_REPEAT (1 << 6)
|
#define FREE_REPEAT (1 << 6)
|
||||||
#define FREE_REPEATCOUNT (1 << 7)
|
#define FREE_REPEATCOUNT (1 << 7)
|
||||||
|
#define FREE_COMMITTED (1 << 8)
|
||||||
|
|
||||||
struct commandline_arguments {
|
struct commandline_arguments {
|
||||||
int exponent; /* demanded in kilos, magas... */
|
int exponent; /* demanded in kilos, magas... */
|
||||||
@ -88,6 +89,7 @@ static void __attribute__ ((__noreturn__))
|
|||||||
fputs(_(" --si use powers of 1000 not 1024\n"), out);
|
fputs(_(" --si use powers of 1000 not 1024\n"), out);
|
||||||
fputs(_(" -l, --lohi show detailed low and high memory statistics\n"), out);
|
fputs(_(" -l, --lohi show detailed low and high memory statistics\n"), out);
|
||||||
fputs(_(" -t, --total show total for RAM + swap\n"), out);
|
fputs(_(" -t, --total show total for RAM + swap\n"), out);
|
||||||
|
fputs(_(" -v, --committed show committed memory and commit limit\n"), out);
|
||||||
fputs(_(" -s N, --seconds N repeat printing every N seconds\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 N, --count N repeat printing N times, then exit\n"), out);
|
||||||
fputs(_(" -w, --wide wide output\n"), out);
|
fputs(_(" -w, --wide wide output\n"), out);
|
||||||
@ -209,6 +211,7 @@ int main(int argc, char **argv)
|
|||||||
{ "si", no_argument, NULL, SI_OPTION },
|
{ "si", no_argument, NULL, SI_OPTION },
|
||||||
{ "lohi", no_argument, NULL, 'l' },
|
{ "lohi", no_argument, NULL, 'l' },
|
||||||
{ "total", no_argument, NULL, 't' },
|
{ "total", no_argument, NULL, 't' },
|
||||||
|
{ "committed", no_argument, NULL, 'v' },
|
||||||
{ "seconds", required_argument, NULL, 's' },
|
{ "seconds", required_argument, NULL, 's' },
|
||||||
{ "count", required_argument, NULL, 'c' },
|
{ "count", required_argument, NULL, 'c' },
|
||||||
{ "wide", no_argument, NULL, 'w' },
|
{ "wide", no_argument, NULL, 'w' },
|
||||||
@ -230,7 +233,7 @@ int main(int argc, char **argv)
|
|||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
atexit(close_stdout);
|
atexit(close_stdout);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "bkmghltc:ws:V", longopts, NULL)) != -1)
|
while ((c = getopt_long(argc, argv, "bkmghltvc:ws:V", longopts, NULL)) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
check_unit_set(&unit_set);
|
check_unit_set(&unit_set);
|
||||||
@ -293,6 +296,9 @@ int main(int argc, char **argv)
|
|||||||
case 't':
|
case 't':
|
||||||
flags |= FREE_TOTAL;
|
flags |= FREE_TOTAL;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
flags |= FREE_COMMITTED;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
flags |= FREE_REPEAT;
|
flags |= FREE_REPEAT;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@ -392,6 +398,16 @@ int main(int argc, char **argv)
|
|||||||
MEMINFO_GET(mem_info, MEMINFO_SWAP_FREE, ul_int), flags, args));
|
MEMINFO_GET(mem_info, MEMINFO_SWAP_FREE, ul_int), flags, args));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
if (flags & FREE_COMMITTED) {
|
||||||
|
printf("%-9s", _("Comm:"));
|
||||||
|
printf("%11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_COMMIT_LIMIT, ul_int), flags, args));
|
||||||
|
printf(" %11s", scale_size(MEMINFO_GET(mem_info, MEMINFO_MEM_COMMITTED_AS, ul_int), flags, args));
|
||||||
|
printf(" %11s", scale_size(
|
||||||
|
MEMINFO_GET(mem_info, MEMINFO_MEM_COMMIT_LIMIT, ul_int) -
|
||||||
|
MEMINFO_GET(mem_info, MEMINFO_MEM_COMMITTED_AS, ul_int), flags, args));
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (flags & FREE_REPEATCOUNT) {
|
if (flags & FREE_REPEATCOUNT) {
|
||||||
args.repeat_counter--;
|
args.repeat_counter--;
|
||||||
|
Loading…
Reference in New Issue
Block a user