From: glittao@gmail.com
To: cl@linux.com, penberg@kernel.org, rientjes@google.com,
iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
vbabka@suse.cz
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
faiyazm@codeaurora.org, Oliver Glitta <glittao@gmail.com>
Subject: [RFC 2/3] mm/slub: sort objects in cache by frequency of stack trace
Date: Fri, 21 May 2021 14:11:26 +0200 [thread overview]
Message-ID: <20210521121127.24653-2-glittao@gmail.com> (raw)
In-Reply-To: <20210521121127.24653-1-glittao@gmail.com>
From: Oliver Glitta <glittao@gmail.com>
Sort objects in slub cache by the frequency of stack trace used
in object location in alloc_calls and free_calls implementation
in debugfs. Most frequently used stack traces will be the first.
Signed-off-by: Oliver Glitta <glittao@gmail.com>
---
mm/slub.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index d5ed6ed7d68b..247983d647cd 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -37,6 +37,7 @@
#include <linux/memcontrol.h>
#include <linux/random.h>
#include <kunit/test.h>
+#include <linux/sort.h>
#include <linux/debugfs.h>
#include <trace/events/kmem.h>
@@ -5893,6 +5894,17 @@ static void *slab_debugfs_next(struct seq_file *seq, void *v, loff_t *ppos)
return NULL;
}
+static int cmp_loc_by_count(const void *a, const void *b, const void *data)
+{
+ struct location *loc1 = (struct location *)a;
+ struct location *loc2 = (struct location *)b;
+
+ if (loc1->count > loc2->count)
+ return -1;
+ else
+ return 1;
+}
+
static void *slab_debugfs_start(struct seq_file *seq, loff_t *ppos)
{
struct kmem_cache_node *n;
@@ -5944,6 +5956,11 @@ static void *slab_debugfs_start(struct seq_file *seq, loff_t *ppos)
process_slab(&t, s, page, alloc);
spin_unlock_irqrestore(&n->list_lock, flags);
}
+
+ /* Sort locations by count */
+ sort_r(t.loc, t.count, sizeof(struct location),
+ cmp_loc_by_count, NULL, NULL);
+
}
if (*ppos < t.count) {
--
2.31.1.272.g89b43f80a5
next prev parent reply other threads:[~2021-05-21 12:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-21 12:11 [RFC 1/3] mm/slub: aggregate objects in cache by " glittao
2021-05-21 12:11 ` glittao [this message]
2021-05-26 14:06 ` [RFC 2/3] mm/slub: sort objects in cache by frequency of " Vlastimil Babka
2021-05-21 12:11 ` [RFC 3/3] mm/slub: add all_objects implementation in debugfs glittao
2021-05-26 14:26 ` Vlastimil Babka
2021-05-26 14:05 ` [RFC 1/3] mm/slub: aggregate objects in cache by stack trace Vlastimil Babka
2021-06-08 8:45 ` [RFC 4/4] docs: add description of debugfs files for SLUB cache glittao
2021-06-14 0:08 ` David Rientjes
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=20210521121127.24653-2-glittao@gmail.com \
--to=glittao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=faiyazm@codeaurora.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox