Commit 1106b205 authored by Tobin C. Harding's avatar Tobin C. Harding Committed by Linus Torvalds

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.orgSigned-off-by: default avatarTobin 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d9149996
...@@ -79,6 +79,7 @@ int sort_size; ...@@ -79,6 +79,7 @@ int sort_size;
int sort_active; int sort_active;
int set_debug; int set_debug;
int show_ops; int show_ops;
int sort_partial;
int show_activity; int show_activity;
int output_lines = -1; int output_lines = -1;
int sort_loss; int sort_loss;
...@@ -1047,6 +1048,8 @@ static void sort_slabs(void) ...@@ -1047,6 +1048,8 @@ static void sort_slabs(void)
result = slab_activity(s1) < slab_activity(s2); result = slab_activity(s1) < slab_activity(s2);
else if (sort_loss) else if (sort_loss)
result = slab_waste(s1) < slab_waste(s2); result = slab_waste(s1) < slab_waste(s2);
else if (sort_partial)
result = s1->partial < s2->partial;
else else
result = strcasecmp(s1->name, s2->name); result = strcasecmp(s1->name, s2->name);
...@@ -1307,27 +1310,39 @@ static void output_slabs(void) ...@@ -1307,27 +1310,39 @@ static void output_slabs(void)
} }
} }
static void _xtotals(char *heading, char *underline,
int loss, int size, int partial)
{
printf("%s%s", heading, underline);
line = 0;
sort_loss = loss;
sort_size = size;
sort_partial = partial;
sort_slabs();
output_slabs();
}
static void xtotals(void) static void xtotals(void)
{ {
char *heading, *underline;
totals(); totals();
link_slabs(); link_slabs();
rename_slabs(); rename_slabs();
printf("\nSlabs sorted by size\n"); heading = "\nSlabs sorted by size\n";
printf("--------------------\n"); underline = "--------------------\n";
sort_loss = 0; _xtotals(heading, underline, 0, 1, 0);
sort_size = 1;
sort_slabs(); heading = "\nSlabs sorted by loss\n";
output_slabs(); underline = "--------------------\n";
_xtotals(heading, underline, 1, 0, 0);
heading = "\nSlabs sorted by number of partial slabs\n";
underline = "---------------------------------------\n";
_xtotals(heading, underline, 0, 0, 1);
printf("\nSlabs sorted by loss\n");
printf("--------------------\n");
line = 0;
sort_loss = 1;
sort_size = 0;
sort_slabs();
output_slabs();
printf("\n"); printf("\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment