diff options
| author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2015-11-05 21:45:20 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-05 22:34:48 -0500 |
| commit | 4980a9639b4bf4948f4cba60e3e6c45a635b98ec (patch) | |
| tree | 60657bf18171f02d2288366f55a7d93f6f0b2dfa /tools/vm | |
| parent | 2b10075539d334b4732a07857672972fe971f7df (diff) | |
tools/vm/slabinfo: limit the number of reported slabs
Introduce opt "-N|--lines=K" to limit the number of slabs
being reported in output_slabs().
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'tools/vm')
| -rw-r--r-- | tools/vm/slabinfo.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c index 258ed014729d..2ef7f0ca0168 100644 --- a/tools/vm/slabinfo.c +++ b/tools/vm/slabinfo.c | |||
| @@ -79,6 +79,7 @@ int sort_active = 0; | |||
| 79 | int set_debug = 0; | 79 | int set_debug = 0; |
| 80 | int show_ops = 0; | 80 | int show_ops = 0; |
| 81 | int show_activity = 0; | 81 | int show_activity = 0; |
| 82 | int output_lines = -1; | ||
| 82 | 83 | ||
| 83 | /* Debug options */ | 84 | /* Debug options */ |
| 84 | int sanity = 0; | 85 | int sanity = 0; |
| @@ -124,6 +125,7 @@ static void usage(void) | |||
| 124 | "-v|--validate Validate slabs\n" | 125 | "-v|--validate Validate slabs\n" |
| 125 | "-z|--zero Include empty slabs\n" | 126 | "-z|--zero Include empty slabs\n" |
| 126 | "-1|--1ref Single reference\n" | 127 | "-1|--1ref Single reference\n" |
| 128 | "-N|--lines=K Show the first K slabs\n" | ||
| 127 | "\nValid debug options (FZPUT may be combined)\n" | 129 | "\nValid debug options (FZPUT may be combined)\n" |
| 128 | "a / A Switch on all debug options (=FZUP)\n" | 130 | "a / A Switch on all debug options (=FZUP)\n" |
| 129 | "- Switch off all debug options\n" | 131 | "- Switch off all debug options\n" |
| @@ -1242,11 +1244,14 @@ static void output_slabs(void) | |||
| 1242 | { | 1244 | { |
| 1243 | struct slabinfo *slab; | 1245 | struct slabinfo *slab; |
| 1244 | 1246 | ||
| 1245 | for (slab = slabinfo; slab < slabinfo + slabs; slab++) { | 1247 | for (slab = slabinfo; (slab < slabinfo + slabs) && |
| 1248 | output_lines != 0; slab++) { | ||
| 1246 | 1249 | ||
| 1247 | if (slab->alias) | 1250 | if (slab->alias) |
| 1248 | continue; | 1251 | continue; |
| 1249 | 1252 | ||
| 1253 | if (output_lines != -1) | ||
| 1254 | output_lines--; | ||
| 1250 | 1255 | ||
| 1251 | if (show_numa) | 1256 | if (show_numa) |
| 1252 | slab_numa(slab, 0); | 1257 | slab_numa(slab, 0); |
| @@ -1285,6 +1290,7 @@ struct option opts[] = { | |||
| 1285 | { "validate", no_argument, NULL, 'v' }, | 1290 | { "validate", no_argument, NULL, 'v' }, |
| 1286 | { "zero", no_argument, NULL, 'z' }, | 1291 | { "zero", no_argument, NULL, 'z' }, |
| 1287 | { "1ref", no_argument, NULL, '1'}, | 1292 | { "1ref", no_argument, NULL, '1'}, |
| 1293 | { "lines", required_argument, NULL, 'N'}, | ||
| 1288 | { NULL, 0, NULL, 0 } | 1294 | { NULL, 0, NULL, 0 } |
| 1289 | }; | 1295 | }; |
| 1290 | 1296 | ||
| @@ -1296,7 +1302,7 @@ int main(int argc, char *argv[]) | |||
| 1296 | 1302 | ||
| 1297 | page_size = getpagesize(); | 1303 | page_size = getpagesize(); |
| 1298 | 1304 | ||
| 1299 | while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTS", | 1305 | while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:", |
| 1300 | opts, NULL)) != -1) | 1306 | opts, NULL)) != -1) |
| 1301 | switch (c) { | 1307 | switch (c) { |
| 1302 | case '1': | 1308 | case '1': |
| @@ -1358,7 +1364,13 @@ int main(int argc, char *argv[]) | |||
| 1358 | case 'S': | 1364 | case 'S': |
| 1359 | sort_size = 1; | 1365 | sort_size = 1; |
| 1360 | break; | 1366 | break; |
| 1361 | 1367 | case 'N': | |
| 1368 | if (optarg) { | ||
| 1369 | output_lines = atoi(optarg); | ||
| 1370 | if (output_lines < 1) | ||
| 1371 | output_lines = 1; | ||
| 1372 | } | ||
| 1373 | break; | ||
| 1362 | default: | 1374 | default: |
| 1363 | fatal("%s: Invalid option '%c'\n", argv[0], optopt); | 1375 | fatal("%s: Invalid option '%c'\n", argv[0], optopt); |
| 1364 | 1376 | ||
