From: "Tobin C. Harding" <tobin@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Tobin C. Harding" <tobin@kernel.org>,
Jesper Dangaard Brouer <brouer@redhat.com>,
Pekka Enberg <penberg@iki.fi>, Vlastimil Babka <vbabka@suse.cz>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>, Tejun Heo <tj@kernel.org>,
Qian Cai <cai@lca.pw>,
Linus Torvalds <torvalds@linux-foundation.org>,
Mel Gorman <mgorman@techsingularity.net>,
Alexander Duyck <alexander.duyck@gmail.com>,
Michal Hocko <mhocko@kernel.org>,
Brendan Gregg <brendan.d.gregg@gmail.com>,
linux-mm@kvack.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] tools/vm/slabinfo: Add partial slab listing to -X
Date: Fri, 26 Apr 2019 12:26:20 +1000 [thread overview]
Message-ID: <20190426022622.4089-3-tobin@kernel.org> (raw)
In-Reply-To: <20190426022622.4089-1-tobin@kernel.org>
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`.
Signed-off-by: Tobin C. Harding <tobin@kernel.org>
---
tools/vm/slabinfo.c | 41 ++++++++++++++++++++++++++++-------------
1 file 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;
int sort_active;
int set_debug;
int show_ops;
+int sort_partial;
int show_activity;
int output_lines = -1;
int sort_loss;
@@ -1047,6 +1048,8 @@ static void sort_slabs(void)
result = slab_activity(s1) < slab_activity(s2);
else if (sort_loss)
result = slab_waste(s1) < slab_waste(s2);
+ else if (sort_partial)
+ result = s1->partial < s2->partial;
else
result = strcasecmp(s1->name, s2->name);
@@ -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)
{
+ char *heading, *underline;
+
totals();
link_slabs();
rename_slabs();
- printf("\nSlabs sorted by size\n");
- printf("--------------------\n");
- sort_loss = 0;
- sort_size = 1;
- sort_slabs();
- output_slabs();
+ heading = "\nSlabs sorted by size\n";
+ underline = "--------------------\n";
+ _xtotals(heading, underline, 0, 1, 0);
+
+ heading = "\nSlabs sorted by loss\n";
+ 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");
}
--
2.21.0
next prev parent reply other threads:[~2019-04-26 2:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 2:26 [PATCH 0/4] tools/vm/slabinfo: Add fragmentation output Tobin C. Harding
2019-04-26 2:26 ` [PATCH 1/4] tools/vm/slabinfo: Order command line options Tobin C. Harding
2019-04-26 2:26 ` Tobin C. Harding [this message]
2019-04-26 2:26 ` [PATCH 3/4] tools/vm/slabinfo: Add option to sort by partial slabs Tobin C. Harding
2019-04-26 2:26 ` [PATCH 4/4] tools/vm/slabinfo: Add sorting info to help menu Tobin C. Harding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190426022622.4089-3-tobin@kernel.org \
--to=tobin@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.duyck@gmail.com \
--cc=brendan.d.gregg@gmail.com \
--cc=brouer@redhat.com \
--cc=cai@lca.pw \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=penberg@iki.fi \
--cc=rientjes@google.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.