Skip to content

Commit

Permalink
tools: slabinfo: add "-U" option to show unreclaimable slabs only
Browse files Browse the repository at this point in the history
Patch series "oom: capture unreclaimable slab info in oom message", v10.

Recently we ran into a oom issue, kernel panic due to no killable
process.  The dmesg shows huge unreclaimable slabs used almost 100%
memory, but kdump doesn't capture vmcore due to some reason.

So, it may sound better to capture unreclaimable slab info in oom
message when kernel panic to aid trouble shooting and cover the corner
case.  Since kernel already panic, so capturing more information sounds
worthy and doesn't bother normal oom killer.

With the patchset, tools/vm/slabinfo has a new option, "-U", to show
unreclaimable slab only.

And, oom will print all non zero (num_objs * size != 0) unreclaimable
slabs in oom killer message.

This patch (of 3):

Add "-U" option to show unreclaimable slabs only.

"-U" and "-S" together can tell us what unreclaimable slabs use the most
memory to help debug huge unreclaimable slabs issue.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Yang Shi <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Acked-by: David Rientjes <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Yang Shi authored and torvalds committed Nov 16, 2017
1 parent 47ee9d8 commit 7ad3f18
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/vm/slabinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ int output_lines = -1;
int sort_loss;
int extended_totals;
int show_bytes;
int unreclaim_only;

/* Debug options */
int sanity;
Expand Down Expand Up @@ -133,6 +134,7 @@ static void usage(void)
"-L|--Loss Sort by loss\n"
"-X|--Xtotals Show extended summary information\n"
"-B|--Bytes Show size in bytes\n"
"-U|--Unreclaim Show unreclaimable slabs only\n"
"\nValid debug options (FZPUT may be combined)\n"
"a / A Switch on all debug options (=FZUP)\n"
"- Switch off all debug options\n"
Expand Down Expand Up @@ -569,6 +571,9 @@ static void slabcache(struct slabinfo *s)
if (strcmp(s->name, "*") == 0)
return;

if (unreclaim_only && s->reclaim_account)
return;

if (actual_slabs == 1) {
report(s);
return;
Expand Down Expand Up @@ -1347,6 +1352,7 @@ struct option opts[] = {
{ "Loss", no_argument, NULL, 'L'},
{ "Xtotals", no_argument, NULL, 'X'},
{ "Bytes", no_argument, NULL, 'B'},
{ "Unreclaim", no_argument, NULL, 'U'},
{ NULL, 0, NULL, 0 }
};

Expand All @@ -1358,7 +1364,7 @@ int main(int argc, char *argv[])

page_size = getpagesize();

while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LXB",
while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LXBU",
opts, NULL)) != -1)
switch (c) {
case '1':
Expand Down Expand Up @@ -1439,6 +1445,9 @@ int main(int argc, char *argv[])
case 'B':
show_bytes = 1;
break;
case 'U':
unreclaim_only = 1;
break;
default:
fatal("%s: Invalid option '%c'\n", argv[0], optopt);

Expand Down

0 comments on commit 7ad3f18

Please sign in to comment.