aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2015-11-05 21:45:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-05 22:34:48 -0500
commit016c6cdf3df8b05a23ff7b0e77aa7f4fe83e700d (patch)
treea79e909f28ed4e1f10aeb1cd5fba5a7ce2054959
parent0d00bf589f0f8976b5bccbb5bd03a497762b5545 (diff)
tools/vm/slabinfo: introduce extended totals mode
Add "-X|--Xtotals" opt to output extended totals summary, which includes: -- totals summary -- slabs sorted by size -- slabs sorted by loss (waste) Example: ======= slabinfo --X -N 1 Slabcache Totals ---------------- Slabcaches : 91 Aliases : 120->69 Active: 65 Memory used: 568.3M # Loss : 30.4M MRatio: 5% # Objects : 920.1K # PartObj: 161.2K ORatio: 17% Per Cache Average Min Max Total --------------------------------------------------------- #Objects 14.1K 1 227.8K 920.1K #Slabs 533 1 11.7K 34.7K #PartSlab 86 0 4.3K 5.6K %PartSlab 24% 0% 100% 16% PartObjs 17 0 129.3K 161.2K % PartObj 17% 0% 100% 17% Memory 8.7M 8.1K 384.7M 568.3M Used 8.2M 160 366.5M 537.9M Loss 468.8K 0 18.2M 30.4M Per Object Average Min Max --------------------------------------------- Memory 587 8 8.1K User 584 8 8.1K Loss 2 0 64 Slabs sorted by size ---------------------- Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg ext4_inode_cache 211142 1736 384.7M 11732/40/10 18 3 0 95 a Slabs sorted by loss ---------------------- Name Objects Objsize Loss Slabs/Part/Cpu O/S O %Fr %Ef Flg ext4_inode_cache 211142 1736 18.2M 11732/40/10 18 3 0 95 a 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>
-rw-r--r--tools/vm/slabinfo.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
index de4974df4255..44b83ce352fd 100644
--- a/tools/vm/slabinfo.c
+++ b/tools/vm/slabinfo.c
@@ -81,6 +81,7 @@ int show_ops = 0;
81int show_activity = 0; 81int show_activity = 0;
82int output_lines = -1; 82int output_lines = -1;
83int sort_loss; 83int sort_loss;
84int extended_totals;
84 85
85/* Debug options */ 86/* Debug options */
86int sanity = 0; 87int sanity = 0;
@@ -128,6 +129,7 @@ static void usage(void)
128 "-1|--1ref Single reference\n" 129 "-1|--1ref Single reference\n"
129 "-N|--lines=K Show the first K slabs\n" 130 "-N|--lines=K Show the first K slabs\n"
130 "-L|--Loss Sort by loss\n" 131 "-L|--Loss Sort by loss\n"
132 "-X|--Xtotals Show extended summary information\n"
131 "\nValid debug options (FZPUT may be combined)\n" 133 "\nValid debug options (FZPUT may be combined)\n"
132 "a / A Switch on all debug options (=FZUP)\n" 134 "a / A Switch on all debug options (=FZUP)\n"
133 "- Switch off all debug options\n" 135 "- Switch off all debug options\n"
@@ -615,8 +617,7 @@ static void slabcache(struct slabinfo *s)
615 total_free ? (s->free_fastpath * 100 / total_free) : 0, 617 total_free ? (s->free_fastpath * 100 / total_free) : 0,
616 s->order_fallback, s->order, s->cmpxchg_double_fail, 618 s->order_fallback, s->order, s->cmpxchg_double_fail,
617 s->cmpxchg_double_cpu_fail); 619 s->cmpxchg_double_cpu_fail);
618 } 620 } else {
619 else
620 printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n", 621 printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n",
621 s->name, s->objects, s->object_size, size_str, dist_str, 622 s->name, s->objects, s->object_size, size_str, dist_str,
622 s->objs_per_slab, s->order, 623 s->objs_per_slab, s->order,
@@ -624,6 +625,7 @@ static void slabcache(struct slabinfo *s)
624 s->slabs ? (s->objects * s->object_size * 100) / 625 s->slabs ? (s->objects * s->object_size * 100) /
625 (s->slabs * (page_size << s->order)) : 100, 626 (s->slabs * (page_size << s->order)) : 100,
626 flags); 627 flags);
628 }
627} 629}
628 630
629/* 631/*
@@ -1256,15 +1258,16 @@ static void read_slab_dir(void)
1256static void output_slabs(void) 1258static void output_slabs(void)
1257{ 1259{
1258 struct slabinfo *slab; 1260 struct slabinfo *slab;
1261 int lines = output_lines;
1259 1262
1260 for (slab = slabinfo; (slab < slabinfo + slabs) && 1263 for (slab = slabinfo; (slab < slabinfo + slabs) &&
1261 output_lines != 0; slab++) { 1264 lines != 0; slab++) {
1262 1265
1263 if (slab->alias) 1266 if (slab->alias)
1264 continue; 1267 continue;
1265 1268
1266 if (output_lines != -1) 1269 if (lines != -1)
1267 output_lines--; 1270 lines--;
1268 1271
1269 if (show_numa) 1272 if (show_numa)
1270 slab_numa(slab, 0); 1273 slab_numa(slab, 0);
@@ -1285,6 +1288,30 @@ static void output_slabs(void)
1285 } 1288 }
1286} 1289}
1287 1290
1291static void xtotals(void)
1292{
1293 totals();
1294
1295 link_slabs();
1296 rename_slabs();
1297
1298 printf("\nSlabs sorted by size\n");
1299 printf("----------------------\n");
1300 sort_loss = 0;
1301 sort_size = 1;
1302 sort_slabs();
1303 output_slabs();
1304
1305 printf("\nSlabs sorted by loss\n");
1306 printf("----------------------\n");
1307 line = 0;
1308 sort_loss = 1;
1309 sort_size = 0;
1310 sort_slabs();
1311 output_slabs();
1312 printf("\n");
1313}
1314
1288struct option opts[] = { 1315struct option opts[] = {
1289 { "aliases", no_argument, NULL, 'a' }, 1316 { "aliases", no_argument, NULL, 'a' },
1290 { "activity", no_argument, NULL, 'A' }, 1317 { "activity", no_argument, NULL, 'A' },
@@ -1307,6 +1334,7 @@ struct option opts[] = {
1307 { "1ref", no_argument, NULL, '1'}, 1334 { "1ref", no_argument, NULL, '1'},
1308 { "lines", required_argument, NULL, 'N'}, 1335 { "lines", required_argument, NULL, 'N'},
1309 { "Loss", no_argument, NULL, 'L'}, 1336 { "Loss", no_argument, NULL, 'L'},
1337 { "Xtotals", no_argument, NULL, 'X'},
1310 { NULL, 0, NULL, 0 } 1338 { NULL, 0, NULL, 0 }
1311}; 1339};
1312 1340
@@ -1318,7 +1346,7 @@ int main(int argc, char *argv[])
1318 1346
1319 page_size = getpagesize(); 1347 page_size = getpagesize();
1320 1348
1321 while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:L", 1349 while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LX",
1322 opts, NULL)) != -1) 1350 opts, NULL)) != -1)
1323 switch (c) { 1351 switch (c) {
1324 case '1': 1352 case '1':
@@ -1390,6 +1418,11 @@ int main(int argc, char *argv[])
1390 case 'L': 1418 case 'L':
1391 sort_loss = 1; 1419 sort_loss = 1;
1392 break; 1420 break;
1421 case 'X':
1422 if (output_lines == -1)
1423 output_lines = 1;
1424 extended_totals = 1;
1425 break;
1393 default: 1426 default:
1394 fatal("%s: Invalid option '%c'\n", argv[0], optopt); 1427 fatal("%s: Invalid option '%c'\n", argv[0], optopt);
1395 1428
@@ -1409,12 +1442,13 @@ int main(int argc, char *argv[])
1409 fatal("%s: Invalid pattern '%s' code %d\n", 1442 fatal("%s: Invalid pattern '%s' code %d\n",
1410 argv[0], pattern_source, err); 1443 argv[0], pattern_source, err);
1411 read_slab_dir(); 1444 read_slab_dir();
1412 if (show_alias) 1445 if (show_alias) {
1413 alias(); 1446 alias();
1414 else 1447 } else if (extended_totals) {
1415 if (show_totals) 1448 xtotals();
1449 } else if (show_totals) {
1416 totals(); 1450 totals();
1417 else { 1451 } else {
1418 link_slabs(); 1452 link_slabs();
1419 rename_slabs(); 1453 rename_slabs();
1420 sort_slabs(); 1454 sort_slabs();