diff options
| author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2015-11-05 21:45:22 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-05 22:34:48 -0500 |
| commit | 2651f6e7fe1c24b0a50691828edd392971d57d4f (patch) | |
| tree | a7f39ef2ed97cc20a6701dbb094ee4190050e459 /tools/vm | |
| parent | 4980a9639b4bf4948f4cba60e3e6c45a635b98ec (diff) | |
tools/vm/slabinfo: sort slabs by loss
Introduce opt "-L|--sort-loss" to sort and output slabs by
loss (waste) in slabcache().
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 | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c index 2ef7f0ca0168..2e154f13c60e 100644 --- a/tools/vm/slabinfo.c +++ b/tools/vm/slabinfo.c | |||
| @@ -80,6 +80,7 @@ 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 | int output_lines = -1; |
| 83 | int sort_loss; | ||
| 83 | 84 | ||
| 84 | /* Debug options */ | 85 | /* Debug options */ |
| 85 | int sanity = 0; | 86 | int sanity = 0; |
| @@ -126,6 +127,7 @@ static void usage(void) | |||
| 126 | "-z|--zero Include empty slabs\n" | 127 | "-z|--zero Include empty slabs\n" |
| 127 | "-1|--1ref Single reference\n" | 128 | "-1|--1ref Single reference\n" |
| 128 | "-N|--lines=K Show the first K slabs\n" | 129 | "-N|--lines=K Show the first K slabs\n" |
| 130 | "-L|--Loss Sort by loss\n" | ||
| 129 | "\nValid debug options (FZPUT may be combined)\n" | 131 | "\nValid debug options (FZPUT may be combined)\n" |
| 130 | "a / A Switch on all debug options (=FZUP)\n" | 132 | "a / A Switch on all debug options (=FZUP)\n" |
| 131 | "- Switch off all debug options\n" | 133 | "- Switch off all debug options\n" |
| @@ -301,8 +303,9 @@ static void first_line(void) | |||
| 301 | if (show_activity) | 303 | if (show_activity) |
| 302 | printf("Name Objects Alloc Free %%Fast Fallb O CmpX UL\n"); | 304 | printf("Name Objects Alloc Free %%Fast Fallb O CmpX UL\n"); |
| 303 | else | 305 | else |
| 304 | printf("Name Objects Objsize Space " | 306 | printf("Name Objects Objsize %s " |
| 305 | "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n"); | 307 | "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n", |
| 308 | sort_loss ? "Loss" : "Space"); | ||
| 306 | } | 309 | } |
| 307 | 310 | ||
| 308 | /* | 311 | /* |
| @@ -335,6 +338,11 @@ static unsigned long slab_activity(struct slabinfo *s) | |||
| 335 | s->alloc_slowpath + s->free_slowpath; | 338 | s->alloc_slowpath + s->free_slowpath; |
| 336 | } | 339 | } |
| 337 | 340 | ||
| 341 | static unsigned long slab_waste(struct slabinfo *s) | ||
| 342 | { | ||
| 343 | return slab_size(s) - s->objects * s->object_size; | ||
| 344 | } | ||
| 345 | |||
| 338 | static void slab_numa(struct slabinfo *s, int mode) | 346 | static void slab_numa(struct slabinfo *s, int mode) |
| 339 | { | 347 | { |
| 340 | int node; | 348 | int node; |
| @@ -563,7 +571,10 @@ static void slabcache(struct slabinfo *s) | |||
| 563 | if (show_empty && s->slabs) | 571 | if (show_empty && s->slabs) |
| 564 | return; | 572 | return; |
| 565 | 573 | ||
| 566 | store_size(size_str, slab_size(s)); | 574 | if (sort_loss == 0) |
| 575 | store_size(size_str, slab_size(s)); | ||
| 576 | else | ||
| 577 | store_size(size_str, slab_waste(s)); | ||
| 567 | snprintf(dist_str, 40, "%lu/%lu/%d", s->slabs - s->cpu_slabs, | 578 | snprintf(dist_str, 40, "%lu/%lu/%d", s->slabs - s->cpu_slabs, |
| 568 | s->partial, s->cpu_slabs); | 579 | s->partial, s->cpu_slabs); |
| 569 | 580 | ||
| @@ -1013,6 +1024,8 @@ static void sort_slabs(void) | |||
| 1013 | result = slab_size(s1) < slab_size(s2); | 1024 | result = slab_size(s1) < slab_size(s2); |
| 1014 | else if (sort_active) | 1025 | else if (sort_active) |
| 1015 | result = slab_activity(s1) < slab_activity(s2); | 1026 | result = slab_activity(s1) < slab_activity(s2); |
| 1027 | else if (sort_loss) | ||
| 1028 | result = slab_waste(s1) < slab_waste(s2); | ||
| 1016 | else | 1029 | else |
| 1017 | result = strcasecmp(s1->name, s2->name); | 1030 | result = strcasecmp(s1->name, s2->name); |
| 1018 | 1031 | ||
| @@ -1291,6 +1304,7 @@ struct option opts[] = { | |||
| 1291 | { "zero", no_argument, NULL, 'z' }, | 1304 | { "zero", no_argument, NULL, 'z' }, |
| 1292 | { "1ref", no_argument, NULL, '1'}, | 1305 | { "1ref", no_argument, NULL, '1'}, |
| 1293 | { "lines", required_argument, NULL, 'N'}, | 1306 | { "lines", required_argument, NULL, 'N'}, |
| 1307 | { "Loss", no_argument, NULL, 'L'}, | ||
| 1294 | { NULL, 0, NULL, 0 } | 1308 | { NULL, 0, NULL, 0 } |
| 1295 | }; | 1309 | }; |
| 1296 | 1310 | ||
| @@ -1302,7 +1316,7 @@ int main(int argc, char *argv[]) | |||
| 1302 | 1316 | ||
| 1303 | page_size = getpagesize(); | 1317 | page_size = getpagesize(); |
| 1304 | 1318 | ||
| 1305 | while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:", | 1319 | while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:L", |
| 1306 | opts, NULL)) != -1) | 1320 | opts, NULL)) != -1) |
| 1307 | switch (c) { | 1321 | switch (c) { |
| 1308 | case '1': | 1322 | case '1': |
| @@ -1371,6 +1385,9 @@ int main(int argc, char *argv[]) | |||
| 1371 | output_lines = 1; | 1385 | output_lines = 1; |
| 1372 | } | 1386 | } |
| 1373 | break; | 1387 | break; |
| 1388 | case 'L': | ||
| 1389 | sort_loss = 1; | ||
| 1390 | break; | ||
| 1374 | default: | 1391 | default: |
| 1375 | fatal("%s: Invalid option '%c'\n", argv[0], optopt); | 1392 | fatal("%s: Invalid option '%c'\n", argv[0], optopt); |
| 1376 | 1393 | ||
