summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Shi <yang.s@alibaba-inc.com>2017-11-15 20:31:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 21:21:01 -0500
commit7ad3f188aac15772c97523dc4ca3e8e5b6294b9c (patch)
tree1fc5e1d3a3525021e5a89d73862c6424ffcc9be5
parent47ee9d89f04ccce34b6f076258d96d0ba3f5daa9 (diff)
tools: slabinfo: add "-U" option to show unreclaimable slabs only
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/1507152550-46205-2-git-send-email-yang.s@alibaba-inc.com Signed-off-by: Yang Shi <yang.s@alibaba-inc.com> Acked-by: Christoph Lameter <cl@linux.com> Acked-by: David Rientjes <rientjes@google.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Michal Hocko <mhocko@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--tools/vm/slabinfo.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
index b0b7ef6d0de1..f82c2eaa859d 100644
--- a/tools/vm/slabinfo.c
+++ b/tools/vm/slabinfo.c
@@ -84,6 +84,7 @@ int output_lines = -1;
84int sort_loss; 84int sort_loss;
85int extended_totals; 85int extended_totals;
86int show_bytes; 86int show_bytes;
87int unreclaim_only;
87 88
88/* Debug options */ 89/* Debug options */
89int sanity; 90int sanity;
@@ -133,6 +134,7 @@ static void usage(void)
133 "-L|--Loss Sort by loss\n" 134 "-L|--Loss Sort by loss\n"
134 "-X|--Xtotals Show extended summary information\n" 135 "-X|--Xtotals Show extended summary information\n"
135 "-B|--Bytes Show size in bytes\n" 136 "-B|--Bytes Show size in bytes\n"
137 "-U|--Unreclaim Show unreclaimable slabs only\n"
136 "\nValid debug options (FZPUT may be combined)\n" 138 "\nValid debug options (FZPUT may be combined)\n"
137 "a / A Switch on all debug options (=FZUP)\n" 139 "a / A Switch on all debug options (=FZUP)\n"
138 "- Switch off all debug options\n" 140 "- Switch off all debug options\n"
@@ -569,6 +571,9 @@ static void slabcache(struct slabinfo *s)
569 if (strcmp(s->name, "*") == 0) 571 if (strcmp(s->name, "*") == 0)
570 return; 572 return;
571 573
574 if (unreclaim_only && s->reclaim_account)
575 return;
576
572 if (actual_slabs == 1) { 577 if (actual_slabs == 1) {
573 report(s); 578 report(s);
574 return; 579 return;
@@ -1347,6 +1352,7 @@ struct option opts[] = {
1347 { "Loss", no_argument, NULL, 'L'}, 1352 { "Loss", no_argument, NULL, 'L'},
1348 { "Xtotals", no_argument, NULL, 'X'}, 1353 { "Xtotals", no_argument, NULL, 'X'},
1349 { "Bytes", no_argument, NULL, 'B'}, 1354 { "Bytes", no_argument, NULL, 'B'},
1355 { "Unreclaim", no_argument, NULL, 'U'},
1350 { NULL, 0, NULL, 0 } 1356 { NULL, 0, NULL, 0 }
1351}; 1357};
1352 1358
@@ -1358,7 +1364,7 @@ int main(int argc, char *argv[])
1358 1364
1359 page_size = getpagesize(); 1365 page_size = getpagesize();
1360 1366
1361 while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LXB", 1367 while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LXBU",
1362 opts, NULL)) != -1) 1368 opts, NULL)) != -1)
1363 switch (c) { 1369 switch (c) {
1364 case '1': 1370 case '1':
@@ -1439,6 +1445,9 @@ int main(int argc, char *argv[])
1439 case 'B': 1445 case 'B':
1440 show_bytes = 1; 1446 show_bytes = 1;
1441 break; 1447 break;
1448 case 'U':
1449 unreclaim_only = 1;
1450 break;
1442 default: 1451 default:
1443 fatal("%s: Invalid option '%c'\n", argv[0], optopt); 1452 fatal("%s: Invalid option '%c'\n", argv[0], optopt);
1444 1453