diff options
author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2015-11-05 21:45:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-05 22:34:48 -0500 |
commit | a8ea0bf1286a3a96466139a828f3d161d19ca015 (patch) | |
tree | 11e219556878a72c245c22f45ef7107a35f3b502 /tools/vm | |
parent | 016c6cdf3df8b05a23ff7b0e77aa7f4fe83e700d (diff) |
tools/vm/slabinfo: output sizes in bytes
Introduce "-B|--Bytes" opt to disable store_size() dynamic
size scaling and report size in bytes instead.
This `expands' the interface a bit, it's impossible to use
printf("%6s") anymore to output sizes.
Example:
slabinfo -X -N 2
Slabcache Totals
----------------
Slabcaches : 91 Aliases : 119->69 Active: 63
Memory used: 199798784 # Loss : 10689376 MRatio: 5%
# Objects : 324301 # PartObj: 18151 ORatio: 5%
Per Cache Average Min Max Total
----------------------------------------------------------------------------
#Objects 5147 1 89068 324301
#Slabs 199 1 3886 12537
#PartSlab 12 0 240 778
%PartSlab 32% 0% 100% 6%
PartObjs 5 0 4569 18151
% PartObj 26% 0% 100% 5%
Memory 3171409 8192 127336448 199798784
Used 3001736 160 121429728 189109408
Loss 169672 0 5906720 10689376
Per Object Average Min Max
-----------------------------------------------------------
Memory 585 8 8192
User 583 8 8192
Loss 2 0 64
Slabs sorted by size
--------------------
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 127336448 3871/0/15 18 3 0 95 a
dentry 89068 288 26058752 3164/0/17 28 1 0 98 a
Slabs sorted by loss
--------------------
Name Objects Objsize Loss Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 5906720 3871/0/15 18 3 0 95 a
inode_cache 11628 864 537472 642/0/4 18 2 0 94 a
Besides, store_size() does not use powers of two for G/M/K
if (value > 1000000000UL) {
divisor = 100000000UL;
trailer = 'G';
} else if (value > 1000000UL) {
divisor = 100000UL;
trailer = 'M';
} else if (value > 1000UL) {
divisor = 100;
trailer = 'K';
}
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 | 88 |
1 files changed, 51 insertions, 37 deletions
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c index 44b83ce352fd..60beb91419d4 100644 --- a/tools/vm/slabinfo.c +++ b/tools/vm/slabinfo.c | |||
@@ -82,6 +82,7 @@ int show_activity = 0; | |||
82 | int output_lines = -1; | 82 | int output_lines = -1; |
83 | int sort_loss; | 83 | int sort_loss; |
84 | int extended_totals; | 84 | int extended_totals; |
85 | int show_bytes; | ||
85 | 86 | ||
86 | /* Debug options */ | 87 | /* Debug options */ |
87 | int sanity = 0; | 88 | int sanity = 0; |
@@ -130,6 +131,7 @@ static void usage(void) | |||
130 | "-N|--lines=K Show the first K slabs\n" | 131 | "-N|--lines=K Show the first K slabs\n" |
131 | "-L|--Loss Sort by loss\n" | 132 | "-L|--Loss Sort by loss\n" |
132 | "-X|--Xtotals Show extended summary information\n" | 133 | "-X|--Xtotals Show extended summary information\n" |
134 | "-B|--Bytes Show size in bytes\n" | ||
133 | "\nValid debug options (FZPUT may be combined)\n" | 135 | "\nValid debug options (FZPUT may be combined)\n" |
134 | "a / A Switch on all debug options (=FZUP)\n" | 136 | "a / A Switch on all debug options (=FZUP)\n" |
135 | "- Switch off all debug options\n" | 137 | "- Switch off all debug options\n" |
@@ -231,15 +233,17 @@ static int store_size(char *buffer, unsigned long value) | |||
231 | char trailer = 0; | 233 | char trailer = 0; |
232 | int n; | 234 | int n; |
233 | 235 | ||
234 | if (value > 1000000000UL) { | 236 | if (!show_bytes) { |
235 | divisor = 100000000UL; | 237 | if (value > 1000000000UL) { |
236 | trailer = 'G'; | 238 | divisor = 100000000UL; |
237 | } else if (value > 1000000UL) { | 239 | trailer = 'G'; |
238 | divisor = 100000UL; | 240 | } else if (value > 1000000UL) { |
239 | trailer = 'M'; | 241 | divisor = 100000UL; |
240 | } else if (value > 1000UL) { | 242 | trailer = 'M'; |
241 | divisor = 100; | 243 | } else if (value > 1000UL) { |
242 | trailer = 'K'; | 244 | divisor = 100; |
245 | trailer = 'K'; | ||
246 | } | ||
243 | } | 247 | } |
244 | 248 | ||
245 | value /= divisor; | 249 | value /= divisor; |
@@ -303,11 +307,12 @@ int line = 0; | |||
303 | static void first_line(void) | 307 | static void first_line(void) |
304 | { | 308 | { |
305 | if (show_activity) | 309 | if (show_activity) |
306 | printf("Name Objects Alloc Free %%Fast Fallb O CmpX UL\n"); | 310 | printf("Name Objects Alloc Free" |
311 | " %%Fast Fallb O CmpX UL\n"); | ||
307 | else | 312 | else |
308 | printf("Name Objects Objsize %s " | 313 | printf("Name Objects Objsize %s " |
309 | "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n", | 314 | "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n", |
310 | sort_loss ? "Loss" : "Space"); | 315 | sort_loss ? " Loss" : "Space"); |
311 | } | 316 | } |
312 | 317 | ||
313 | /* | 318 | /* |
@@ -516,7 +521,7 @@ static void report(struct slabinfo *s) | |||
516 | if (strcmp(s->name, "*") == 0) | 521 | if (strcmp(s->name, "*") == 0) |
517 | return; | 522 | return; |
518 | 523 | ||
519 | printf("\nSlabcache: %-20s Aliases: %2d Order : %2d Objects: %lu\n", | 524 | printf("\nSlabcache: %-15s Aliases: %2d Order : %2d Objects: %lu\n", |
520 | s->name, s->aliases, s->order, s->objects); | 525 | s->name, s->aliases, s->order, s->objects); |
521 | if (s->hwcache_align) | 526 | if (s->hwcache_align) |
522 | printf("** Hardware cacheline aligned\n"); | 527 | printf("** Hardware cacheline aligned\n"); |
@@ -618,7 +623,7 @@ static void slabcache(struct slabinfo *s) | |||
618 | s->order_fallback, s->order, s->cmpxchg_double_fail, | 623 | s->order_fallback, s->order, s->cmpxchg_double_fail, |
619 | s->cmpxchg_double_cpu_fail); | 624 | s->cmpxchg_double_cpu_fail); |
620 | } else { | 625 | } else { |
621 | printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n", | 626 | printf("%-21s %8ld %7d %15s %14s %4d %1d %3ld %3ld %s\n", |
622 | s->name, s->objects, s->object_size, size_str, dist_str, | 627 | s->name, s->objects, s->object_size, size_str, dist_str, |
623 | s->objs_per_slab, s->order, | 628 | s->objs_per_slab, s->order, |
624 | s->slabs ? (s->partial * 100) / s->slabs : 100, | 629 | s->slabs ? (s->partial * 100) / s->slabs : 100, |
@@ -933,84 +938,88 @@ static void totals(void) | |||
933 | 938 | ||
934 | printf("Slabcache Totals\n"); | 939 | printf("Slabcache Totals\n"); |
935 | printf("----------------\n"); | 940 | printf("----------------\n"); |
936 | printf("Slabcaches : %3d Aliases : %3d->%-3d Active: %3d\n", | 941 | printf("Slabcaches : %15d Aliases : %11d->%-3d Active: %3d\n", |
937 | slabs, aliases, alias_targets, used_slabs); | 942 | slabs, aliases, alias_targets, used_slabs); |
938 | 943 | ||
939 | store_size(b1, total_size);store_size(b2, total_waste); | 944 | store_size(b1, total_size);store_size(b2, total_waste); |
940 | store_size(b3, total_waste * 100 / total_used); | 945 | store_size(b3, total_waste * 100 / total_used); |
941 | printf("Memory used: %6s # Loss : %6s MRatio:%6s%%\n", b1, b2, b3); | 946 | printf("Memory used: %15s # Loss : %15s MRatio:%6s%%\n", b1, b2, b3); |
942 | 947 | ||
943 | store_size(b1, total_objects);store_size(b2, total_partobj); | 948 | store_size(b1, total_objects);store_size(b2, total_partobj); |
944 | store_size(b3, total_partobj * 100 / total_objects); | 949 | store_size(b3, total_partobj * 100 / total_objects); |
945 | printf("# Objects : %6s # PartObj: %6s ORatio:%6s%%\n", b1, b2, b3); | 950 | printf("# Objects : %15s # PartObj: %15s ORatio:%6s%%\n", b1, b2, b3); |
946 | 951 | ||
947 | printf("\n"); | 952 | printf("\n"); |
948 | printf("Per Cache Average Min Max Total\n"); | 953 | printf("Per Cache Average " |
949 | printf("---------------------------------------------------------\n"); | 954 | "Min Max Total\n"); |
955 | printf("---------------------------------------" | ||
956 | "-------------------------------------\n"); | ||
950 | 957 | ||
951 | store_size(b1, avg_objects);store_size(b2, min_objects); | 958 | store_size(b1, avg_objects);store_size(b2, min_objects); |
952 | store_size(b3, max_objects);store_size(b4, total_objects); | 959 | store_size(b3, max_objects);store_size(b4, total_objects); |
953 | printf("#Objects %10s %10s %10s %10s\n", | 960 | printf("#Objects %15s %15s %15s %15s\n", |
954 | b1, b2, b3, b4); | 961 | b1, b2, b3, b4); |
955 | 962 | ||
956 | store_size(b1, avg_slabs);store_size(b2, min_slabs); | 963 | store_size(b1, avg_slabs);store_size(b2, min_slabs); |
957 | store_size(b3, max_slabs);store_size(b4, total_slabs); | 964 | store_size(b3, max_slabs);store_size(b4, total_slabs); |
958 | printf("#Slabs %10s %10s %10s %10s\n", | 965 | printf("#Slabs %15s %15s %15s %15s\n", |
959 | b1, b2, b3, b4); | 966 | b1, b2, b3, b4); |
960 | 967 | ||
961 | store_size(b1, avg_partial);store_size(b2, min_partial); | 968 | store_size(b1, avg_partial);store_size(b2, min_partial); |
962 | store_size(b3, max_partial);store_size(b4, total_partial); | 969 | store_size(b3, max_partial);store_size(b4, total_partial); |
963 | printf("#PartSlab %10s %10s %10s %10s\n", | 970 | printf("#PartSlab %15s %15s %15s %15s\n", |
964 | b1, b2, b3, b4); | 971 | b1, b2, b3, b4); |
965 | store_size(b1, avg_ppart);store_size(b2, min_ppart); | 972 | store_size(b1, avg_ppart);store_size(b2, min_ppart); |
966 | store_size(b3, max_ppart); | 973 | store_size(b3, max_ppart); |
967 | store_size(b4, total_partial * 100 / total_slabs); | 974 | store_size(b4, total_partial * 100 / total_slabs); |
968 | printf("%%PartSlab%10s%% %10s%% %10s%% %10s%%\n", | 975 | printf("%%PartSlab%15s%% %15s%% %15s%% %15s%%\n", |
969 | b1, b2, b3, b4); | 976 | b1, b2, b3, b4); |
970 | 977 | ||
971 | store_size(b1, avg_partobj);store_size(b2, min_partobj); | 978 | store_size(b1, avg_partobj);store_size(b2, min_partobj); |
972 | store_size(b3, max_partobj); | 979 | store_size(b3, max_partobj); |
973 | store_size(b4, total_partobj); | 980 | store_size(b4, total_partobj); |
974 | printf("PartObjs %10s %10s %10s %10s\n", | 981 | printf("PartObjs %15s %15s %15s %15s\n", |
975 | b1, b2, b3, b4); | 982 | b1, b2, b3, b4); |
976 | 983 | ||
977 | store_size(b1, avg_ppartobj);store_size(b2, min_ppartobj); | 984 | store_size(b1, avg_ppartobj);store_size(b2, min_ppartobj); |
978 | store_size(b3, max_ppartobj); | 985 | store_size(b3, max_ppartobj); |
979 | store_size(b4, total_partobj * 100 / total_objects); | 986 | store_size(b4, total_partobj * 100 / total_objects); |
980 | printf("%% PartObj%10s%% %10s%% %10s%% %10s%%\n", | 987 | printf("%% PartObj%15s%% %15s%% %15s%% %15s%%\n", |
981 | b1, b2, b3, b4); | 988 | b1, b2, b3, b4); |
982 | 989 | ||
983 | store_size(b1, avg_size);store_size(b2, min_size); | 990 | store_size(b1, avg_size);store_size(b2, min_size); |
984 | store_size(b3, max_size);store_size(b4, total_size); | 991 | store_size(b3, max_size);store_size(b4, total_size); |
985 | printf("Memory %10s %10s %10s %10s\n", | 992 | printf("Memory %15s %15s %15s %15s\n", |
986 | b1, b2, b3, b4); | 993 | b1, b2, b3, b4); |
987 | 994 | ||
988 | store_size(b1, avg_used);store_size(b2, min_used); | 995 | store_size(b1, avg_used);store_size(b2, min_used); |
989 | store_size(b3, max_used);store_size(b4, total_used); | 996 | store_size(b3, max_used);store_size(b4, total_used); |
990 | printf("Used %10s %10s %10s %10s\n", | 997 | printf("Used %15s %15s %15s %15s\n", |
991 | b1, b2, b3, b4); | 998 | b1, b2, b3, b4); |
992 | 999 | ||
993 | store_size(b1, avg_waste);store_size(b2, min_waste); | 1000 | store_size(b1, avg_waste);store_size(b2, min_waste); |
994 | store_size(b3, max_waste);store_size(b4, total_waste); | 1001 | store_size(b3, max_waste);store_size(b4, total_waste); |
995 | printf("Loss %10s %10s %10s %10s\n", | 1002 | printf("Loss %15s %15s %15s %15s\n", |
996 | b1, b2, b3, b4); | 1003 | b1, b2, b3, b4); |
997 | 1004 | ||
998 | printf("\n"); | 1005 | printf("\n"); |
999 | printf("Per Object Average Min Max\n"); | 1006 | printf("Per Object Average " |
1000 | printf("---------------------------------------------\n"); | 1007 | "Min Max\n"); |
1008 | printf("---------------------------------------" | ||
1009 | "--------------------\n"); | ||
1001 | 1010 | ||
1002 | store_size(b1, avg_memobj);store_size(b2, min_memobj); | 1011 | store_size(b1, avg_memobj);store_size(b2, min_memobj); |
1003 | store_size(b3, max_memobj); | 1012 | store_size(b3, max_memobj); |
1004 | printf("Memory %10s %10s %10s\n", | 1013 | printf("Memory %15s %15s %15s\n", |
1005 | b1, b2, b3); | 1014 | b1, b2, b3); |
1006 | store_size(b1, avg_objsize);store_size(b2, min_objsize); | 1015 | store_size(b1, avg_objsize);store_size(b2, min_objsize); |
1007 | store_size(b3, max_objsize); | 1016 | store_size(b3, max_objsize); |
1008 | printf("User %10s %10s %10s\n", | 1017 | printf("User %15s %15s %15s\n", |
1009 | b1, b2, b3); | 1018 | b1, b2, b3); |
1010 | 1019 | ||
1011 | store_size(b1, avg_objwaste);store_size(b2, min_objwaste); | 1020 | store_size(b1, avg_objwaste);store_size(b2, min_objwaste); |
1012 | store_size(b3, max_objwaste); | 1021 | store_size(b3, max_objwaste); |
1013 | printf("Loss %10s %10s %10s\n", | 1022 | printf("Loss %15s %15s %15s\n", |
1014 | b1, b2, b3); | 1023 | b1, b2, b3); |
1015 | } | 1024 | } |
1016 | 1025 | ||
@@ -1112,7 +1121,7 @@ static void alias(void) | |||
1112 | active = a->slab->name; | 1121 | active = a->slab->name; |
1113 | } | 1122 | } |
1114 | else | 1123 | else |
1115 | printf("%-20s -> %s\n", a->name, a->slab->name); | 1124 | printf("%-15s -> %s\n", a->name, a->slab->name); |
1116 | } | 1125 | } |
1117 | if (active) | 1126 | if (active) |
1118 | printf("\n"); | 1127 | printf("\n"); |
@@ -1296,14 +1305,14 @@ static void xtotals(void) | |||
1296 | rename_slabs(); | 1305 | rename_slabs(); |
1297 | 1306 | ||
1298 | printf("\nSlabs sorted by size\n"); | 1307 | printf("\nSlabs sorted by size\n"); |
1299 | printf("----------------------\n"); | 1308 | printf("--------------------\n"); |
1300 | sort_loss = 0; | 1309 | sort_loss = 0; |
1301 | sort_size = 1; | 1310 | sort_size = 1; |
1302 | sort_slabs(); | 1311 | sort_slabs(); |
1303 | output_slabs(); | 1312 | output_slabs(); |
1304 | 1313 | ||
1305 | printf("\nSlabs sorted by loss\n"); | 1314 | printf("\nSlabs sorted by loss\n"); |
1306 | printf("----------------------\n"); | 1315 | printf("--------------------\n"); |
1307 | line = 0; | 1316 | line = 0; |
1308 | sort_loss = 1; | 1317 | sort_loss = 1; |
1309 | sort_size = 0; | 1318 | sort_size = 0; |
@@ -1335,6 +1344,7 @@ struct option opts[] = { | |||
1335 | { "lines", required_argument, NULL, 'N'}, | 1344 | { "lines", required_argument, NULL, 'N'}, |
1336 | { "Loss", no_argument, NULL, 'L'}, | 1345 | { "Loss", no_argument, NULL, 'L'}, |
1337 | { "Xtotals", no_argument, NULL, 'X'}, | 1346 | { "Xtotals", no_argument, NULL, 'X'}, |
1347 | { "Bytes", no_argument, NULL, 'B'}, | ||
1338 | { NULL, 0, NULL, 0 } | 1348 | { NULL, 0, NULL, 0 } |
1339 | }; | 1349 | }; |
1340 | 1350 | ||
@@ -1346,7 +1356,7 @@ int main(int argc, char *argv[]) | |||
1346 | 1356 | ||
1347 | page_size = getpagesize(); | 1357 | page_size = getpagesize(); |
1348 | 1358 | ||
1349 | while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LX", | 1359 | while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LXB", |
1350 | opts, NULL)) != -1) | 1360 | opts, NULL)) != -1) |
1351 | switch (c) { | 1361 | switch (c) { |
1352 | case '1': | 1362 | case '1': |
@@ -1422,6 +1432,10 @@ int main(int argc, char *argv[]) | |||
1422 | if (output_lines == -1) | 1432 | if (output_lines == -1) |
1423 | output_lines = 1; | 1433 | output_lines = 1; |
1424 | extended_totals = 1; | 1434 | extended_totals = 1; |
1435 | show_bytes = 1; | ||
1436 | break; | ||
1437 | case 'B': | ||
1438 | show_bytes = 1; | ||
1425 | break; | 1439 | break; |
1426 | default: | 1440 | default: |
1427 | fatal("%s: Invalid option '%c'\n", argv[0], optopt); | 1441 | fatal("%s: Invalid option '%c'\n", argv[0], optopt); |