summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobin C. Harding <tobin@kernel.org>2019-07-11 23:59:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-12 14:05:46 -0400
commitd914999689609d45b36db2b0fabb05cf7fc1fa1f (patch)
treee356ed8aee170cd6b1ddff997050b7b69624b26a
parent98879b3b9edc1604f2d1a6686576ef4d08ed3310 (diff)
tools/vm/slabinfo: order command line options
During recent discussion on LKML over SLAB vs SLUB it was suggested by Jesper that it would be nice to have a tool to view the current fragmentation of the slab allocators. CC list for this set is taken from that thread. For SLUB we have all the information for this already exposed by the kernel and also we have a userspace tool for displaying this info: tools/vm/slabinfo.c Extend slabinfo to improve the fragmentation information by enabling sorting of caches by number of partial slabs. Also add cache list sorted in this manner to the output of `slabinfo -X`. This patch (of 4): get_opt() has a spurious character within the option string. Remove it and reorder the options in alphabetic order so that it is easier to keep the options correct. Use the same ordering for command help output and long option handling code. Link: http://lkml.kernel.org/r/20190426022622.4089-2-tobin@kernel.org Signed-off-by: Tobin C. Harding <tobin@kernel.org> Cc: Jesper Dangaard Brouer <brouer@redhat.com> Cc: Pekka Enberg <penberg@iki.fi> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Christoph Lameter <cl@linux.com> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Tejun Heo <tj@kernel.org> Cc: Qian Cai <cai@lca.pw> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Alexander Duyck <alexander.duyck@gmail.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Brendan Gregg <brendan.d.gregg@gmail.com>, Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--tools/vm/slabinfo.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
index 73818f1b2ef8..e9b5437b2f28 100644
--- a/tools/vm/slabinfo.c
+++ b/tools/vm/slabinfo.c
@@ -110,7 +110,7 @@ static void fatal(const char *x, ...)
110static void usage(void) 110static void usage(void)
111{ 111{
112 printf("slabinfo 4/15/2011. (c) 2007 sgi/(c) 2011 Linux Foundation.\n\n" 112 printf("slabinfo 4/15/2011. (c) 2007 sgi/(c) 2011 Linux Foundation.\n\n"
113 "slabinfo [-aADefhilnosrStTvz1LXBU] [N=K] [-dafzput] [slab-regexp]\n" 113 "slabinfo [-aABDefhilLnorsStTUvXz1] [N=K] [-dafzput] [slab-regexp]\n"
114 "-a|--aliases Show aliases\n" 114 "-a|--aliases Show aliases\n"
115 "-A|--activity Most active slabs first\n" 115 "-A|--activity Most active slabs first\n"
116 "-B|--Bytes Show size in bytes\n" 116 "-B|--Bytes Show size in bytes\n"
@@ -131,9 +131,9 @@ static void usage(void)
131 "-T|--Totals Show summary information\n" 131 "-T|--Totals Show summary information\n"
132 "-U|--Unreclaim Show unreclaimable slabs only\n" 132 "-U|--Unreclaim Show unreclaimable slabs only\n"
133 "-v|--validate Validate slabs\n" 133 "-v|--validate Validate slabs\n"
134 "-X|--Xtotals Show extended summary information\n"
134 "-z|--zero Include empty slabs\n" 135 "-z|--zero Include empty slabs\n"
135 "-1|--1ref Single reference\n" 136 "-1|--1ref Single reference\n"
136 "-X|--Xtotals Show extended summary information\n"
137 137
138 "\n" 138 "\n"
139 "-d | --debug Switch off all debug options\n" 139 "-d | --debug Switch off all debug options\n"
@@ -1334,6 +1334,7 @@ static void xtotals(void)
1334struct option opts[] = { 1334struct option opts[] = {
1335 { "aliases", no_argument, NULL, 'a' }, 1335 { "aliases", no_argument, NULL, 'a' },
1336 { "activity", no_argument, NULL, 'A' }, 1336 { "activity", no_argument, NULL, 'A' },
1337 { "Bytes", no_argument, NULL, 'B'},
1337 { "debug", optional_argument, NULL, 'd' }, 1338 { "debug", optional_argument, NULL, 'd' },
1338 { "display-activity", no_argument, NULL, 'D' }, 1339 { "display-activity", no_argument, NULL, 'D' },
1339 { "empty", no_argument, NULL, 'e' }, 1340 { "empty", no_argument, NULL, 'e' },
@@ -1341,21 +1342,20 @@ struct option opts[] = {
1341 { "help", no_argument, NULL, 'h' }, 1342 { "help", no_argument, NULL, 'h' },
1342 { "inverted", no_argument, NULL, 'i'}, 1343 { "inverted", no_argument, NULL, 'i'},
1343 { "slabs", no_argument, NULL, 'l' }, 1344 { "slabs", no_argument, NULL, 'l' },
1345 { "Loss", no_argument, NULL, 'L'},
1344 { "numa", no_argument, NULL, 'n' }, 1346 { "numa", no_argument, NULL, 'n' },
1347 { "lines", required_argument, NULL, 'N'},
1345 { "ops", no_argument, NULL, 'o' }, 1348 { "ops", no_argument, NULL, 'o' },
1346 { "shrink", no_argument, NULL, 's' },
1347 { "report", no_argument, NULL, 'r' }, 1349 { "report", no_argument, NULL, 'r' },
1350 { "shrink", no_argument, NULL, 's' },
1348 { "Size", no_argument, NULL, 'S'}, 1351 { "Size", no_argument, NULL, 'S'},
1349 { "tracking", no_argument, NULL, 't'}, 1352 { "tracking", no_argument, NULL, 't'},
1350 { "Totals", no_argument, NULL, 'T'}, 1353 { "Totals", no_argument, NULL, 'T'},
1354 { "Unreclaim", no_argument, NULL, 'U'},
1351 { "validate", no_argument, NULL, 'v' }, 1355 { "validate", no_argument, NULL, 'v' },
1356 { "Xtotals", no_argument, NULL, 'X'},
1352 { "zero", no_argument, NULL, 'z' }, 1357 { "zero", no_argument, NULL, 'z' },
1353 { "1ref", no_argument, NULL, '1'}, 1358 { "1ref", no_argument, NULL, '1'},
1354 { "lines", required_argument, NULL, 'N'},
1355 { "Loss", no_argument, NULL, 'L'},
1356 { "Xtotals", no_argument, NULL, 'X'},
1357 { "Bytes", no_argument, NULL, 'B'},
1358 { "Unreclaim", no_argument, NULL, 'U'},
1359 { NULL, 0, NULL, 0 } 1359 { NULL, 0, NULL, 0 }
1360}; 1360};
1361 1361
@@ -1367,18 +1367,18 @@ int main(int argc, char *argv[])
1367 1367
1368 page_size = getpagesize(); 1368 page_size = getpagesize();
1369 1369
1370 while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LXBU", 1370 while ((c = getopt_long(argc, argv, "aABd::DefhilLnN:orsStTUvXz1",
1371 opts, NULL)) != -1) 1371 opts, NULL)) != -1)
1372 switch (c) { 1372 switch (c) {
1373 case '1':
1374 show_single_ref = 1;
1375 break;
1376 case 'a': 1373 case 'a':
1377 show_alias = 1; 1374 show_alias = 1;
1378 break; 1375 break;
1379 case 'A': 1376 case 'A':
1380 sort_active = 1; 1377 sort_active = 1;
1381 break; 1378 break;
1379 case 'B':
1380 show_bytes = 1;
1381 break;
1382 case 'd': 1382 case 'd':
1383 set_debug = 1; 1383 set_debug = 1;
1384 if (!debug_opt_scan(optarg)) 1384 if (!debug_opt_scan(optarg))
@@ -1399,9 +1399,22 @@ int main(int argc, char *argv[])
1399 case 'i': 1399 case 'i':
1400 show_inverted = 1; 1400 show_inverted = 1;
1401 break; 1401 break;
1402 case 'l':
1403 show_slab = 1;
1404 break;
1405 case 'L':
1406 sort_loss = 1;
1407 break;
1402 case 'n': 1408 case 'n':
1403 show_numa = 1; 1409 show_numa = 1;
1404 break; 1410 break;
1411 case 'N':
1412 if (optarg) {
1413 output_lines = atoi(optarg);
1414 if (output_lines < 1)
1415 output_lines = 1;
1416 }
1417 break;
1405 case 'o': 1418 case 'o':
1406 show_ops = 1; 1419 show_ops = 1;
1407 break; 1420 break;
@@ -1411,33 +1424,20 @@ int main(int argc, char *argv[])
1411 case 's': 1424 case 's':
1412 shrink = 1; 1425 shrink = 1;
1413 break; 1426 break;
1414 case 'l': 1427 case 'S':
1415 show_slab = 1; 1428 sort_size = 1;
1416 break; 1429 break;
1417 case 't': 1430 case 't':
1418 show_track = 1; 1431 show_track = 1;
1419 break; 1432 break;
1420 case 'v':
1421 validate = 1;
1422 break;
1423 case 'z':
1424 skip_zero = 0;
1425 break;
1426 case 'T': 1433 case 'T':
1427 show_totals = 1; 1434 show_totals = 1;
1428 break; 1435 break;
1429 case 'S': 1436 case 'U':
1430 sort_size = 1; 1437 unreclaim_only = 1;
1431 break;
1432 case 'N':
1433 if (optarg) {
1434 output_lines = atoi(optarg);
1435 if (output_lines < 1)
1436 output_lines = 1;
1437 }
1438 break; 1438 break;
1439 case 'L': 1439 case 'v':
1440 sort_loss = 1; 1440 validate = 1;
1441 break; 1441 break;
1442 case 'X': 1442 case 'X':
1443 if (output_lines == -1) 1443 if (output_lines == -1)
@@ -1445,11 +1445,11 @@ int main(int argc, char *argv[])
1445 extended_totals = 1; 1445 extended_totals = 1;
1446 show_bytes = 1; 1446 show_bytes = 1;
1447 break; 1447 break;
1448 case 'B': 1448 case 'z':
1449 show_bytes = 1; 1449 skip_zero = 0;
1450 break; 1450 break;
1451 case 'U': 1451 case '1':
1452 unreclaim_only = 1; 1452 show_single_ref = 1;
1453 break; 1453 break;
1454 default: 1454 default:
1455 fatal("%s: Invalid option '%c'\n", argv[0], optopt); 1455 fatal("%s: Invalid option '%c'\n", argv[0], optopt);