Skip to content

Commit

Permalink
tools/vm/slabinfo: add option to sort by partial slabs
Browse files Browse the repository at this point in the history
We would like to get a better view of the level of fragmentation within
the SLUB allocator.  Total number of partial slabs is an indicator of
fragmentation.

Add a command line option (-P | --partial) to sort the slab list by total
number of partial slabs.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Tobin C. Harding <[email protected]>
Cc: Alexander Duyck <[email protected]>
Cc: Brendan Gregg <[email protected]>,
Cc: Christoph Lameter <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Jesper Dangaard Brouer <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Qian Cai <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Tobin C. Harding authored and torvalds committed Jul 12, 2019
1 parent 1106b20 commit 53a83f9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/vm/slabinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static void fatal(const char *x, ...)
static void usage(void)
{
printf("slabinfo 4/15/2011. (c) 2007 sgi/(c) 2011 Linux Foundation.\n\n"
"slabinfo [-aABDefhilLnorsStTUvXz1] [N=K] [-dafzput] [slab-regexp]\n"
"slabinfo [-aABDefhilLnoPrsStTUvXz1] [N=K] [-dafzput] [slab-regexp]\n"
"-a|--aliases Show aliases\n"
"-A|--activity Most active slabs first\n"
"-B|--Bytes Show size in bytes\n"
Expand All @@ -125,6 +125,7 @@ static void usage(void)
"-n|--numa Show NUMA information\n"
"-N|--lines=K Show the first K slabs\n"
"-o|--ops Show kmem_cache_ops\n"
"-P|--partial Sort by number of partial slabs\n"
"-r|--report Detailed report on single slabs\n"
"-s|--shrink Shrink slabs\n"
"-S|--Size Sort by size\n"
Expand Down Expand Up @@ -1361,6 +1362,7 @@ struct option opts[] = {
{ "numa", no_argument, NULL, 'n' },
{ "lines", required_argument, NULL, 'N'},
{ "ops", no_argument, NULL, 'o' },
{ "partial", no_argument, NULL, 'p'},
{ "report", no_argument, NULL, 'r' },
{ "shrink", no_argument, NULL, 's' },
{ "Size", no_argument, NULL, 'S'},
Expand All @@ -1382,7 +1384,7 @@ int main(int argc, char *argv[])

page_size = getpagesize();

while ((c = getopt_long(argc, argv, "aABd::DefhilLnN:orsStTUvXz1",
while ((c = getopt_long(argc, argv, "aABd::DefhilLnN:oPrsStTUvXz1",
opts, NULL)) != -1)
switch (c) {
case 'a':
Expand Down Expand Up @@ -1436,6 +1438,9 @@ int main(int argc, char *argv[])
case 'r':
show_report = 1;
break;
case 'P':
sort_partial = 1;
break;
case 's':
shrink = 1;
break;
Expand Down

0 comments on commit 53a83f9

Please sign in to comment.