diff options
author | Tobin C. Harding <tobin@kernel.org> | 2019-07-11 23:59:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-12 14:05:46 -0400 |
commit | 1106b205a3fe034beafad24045b7c00a7eb89669 (patch) | |
tree | 074303cf543acbf27b66634e143aa93dacd9d8f2 | |
parent | d914999689609d45b36db2b0fabb05cf7fc1fa1f (diff) |
tools/vm/slabinfo: add partial slab listing to -X
We would like to see how fragmented the SLUB allocator is, one window into
fragmentation is the total number of partial slabs.
Currently `slabinfo -X` shows slabs sorted by loss and by size. We can
use this option to also show slabs sorted by number of partial slabs.
Option '-X' can be used in conjunction with '-N' to control the number of
slabs shown e.g. list of top 5 slabs:
slabinfo -X -N5
Add list of slabs ordered by number of partial slabs to output of
`slabinfo -X`.
Link: http://lkml.kernel.org/r/20190426022622.4089-3-tobin@kernel.org
Signed-off-by: Tobin C. Harding <tobin@kernel.org>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>,
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Pekka Enberg <penberg@iki.fi>
Cc: Qian Cai <cai@lca.pw>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | tools/vm/slabinfo.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c index e9b5437b2f28..3f3a2db65794 100644 --- a/tools/vm/slabinfo.c +++ b/tools/vm/slabinfo.c | |||
@@ -79,6 +79,7 @@ int sort_size; | |||
79 | int sort_active; | 79 | int sort_active; |
80 | int set_debug; | 80 | int set_debug; |
81 | int show_ops; | 81 | int show_ops; |
82 | int sort_partial; | ||
82 | int show_activity; | 83 | int show_activity; |
83 | int output_lines = -1; | 84 | int output_lines = -1; |
84 | int sort_loss; | 85 | int sort_loss; |
@@ -1047,6 +1048,8 @@ static void sort_slabs(void) | |||
1047 | result = slab_activity(s1) < slab_activity(s2); | 1048 | result = slab_activity(s1) < slab_activity(s2); |
1048 | else if (sort_loss) | 1049 | else if (sort_loss) |
1049 | result = slab_waste(s1) < slab_waste(s2); | 1050 | result = slab_waste(s1) < slab_waste(s2); |
1051 | else if (sort_partial) | ||
1052 | result = s1->partial < s2->partial; | ||
1050 | else | 1053 | else |
1051 | result = strcasecmp(s1->name, s2->name); | 1054 | result = strcasecmp(s1->name, s2->name); |
1052 | 1055 | ||
@@ -1307,27 +1310,39 @@ static void output_slabs(void) | |||
1307 | } | 1310 | } |
1308 | } | 1311 | } |
1309 | 1312 | ||
1313 | static void _xtotals(char *heading, char *underline, | ||
1314 | int loss, int size, int partial) | ||
1315 | { | ||
1316 | printf("%s%s", heading, underline); | ||
1317 | line = 0; | ||
1318 | sort_loss = loss; | ||
1319 | sort_size = size; | ||
1320 | sort_partial = partial; | ||
1321 | sort_slabs(); | ||
1322 | output_slabs(); | ||
1323 | } | ||
1324 | |||
1310 | static void xtotals(void) | 1325 | static void xtotals(void) |
1311 | { | 1326 | { |
1327 | char *heading, *underline; | ||
1328 | |||
1312 | totals(); | 1329 | totals(); |
1313 | 1330 | ||
1314 | link_slabs(); | 1331 | link_slabs(); |
1315 | rename_slabs(); | 1332 | rename_slabs(); |
1316 | 1333 | ||
1317 | printf("\nSlabs sorted by size\n"); | 1334 | heading = "\nSlabs sorted by size\n"; |
1318 | printf("--------------------\n"); | 1335 | underline = "--------------------\n"; |
1319 | sort_loss = 0; | 1336 | _xtotals(heading, underline, 0, 1, 0); |
1320 | sort_size = 1; | 1337 | |
1321 | sort_slabs(); | 1338 | heading = "\nSlabs sorted by loss\n"; |
1322 | output_slabs(); | 1339 | underline = "--------------------\n"; |
1340 | _xtotals(heading, underline, 1, 0, 0); | ||
1341 | |||
1342 | heading = "\nSlabs sorted by number of partial slabs\n"; | ||
1343 | underline = "---------------------------------------\n"; | ||
1344 | _xtotals(heading, underline, 0, 0, 1); | ||
1323 | 1345 | ||
1324 | printf("\nSlabs sorted by loss\n"); | ||
1325 | printf("--------------------\n"); | ||
1326 | line = 0; | ||
1327 | sort_loss = 1; | ||
1328 | sort_size = 0; | ||
1329 | sort_slabs(); | ||
1330 | output_slabs(); | ||
1331 | printf("\n"); | 1346 | printf("\n"); |
1332 | } | 1347 | } |
1333 | 1348 | ||