lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 21 May 2021 14:11:25 +0200
From:   glittao@...il.com
To:     cl@...ux.com, penberg@...nel.org, rientjes@...gle.com,
        iamjoonsoo.kim@....com, akpm@...ux-foundation.org, vbabka@...e.cz
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        faiyazm@...eaurora.org, Oliver Glitta <glittao@...il.com>
Subject: [RFC 1/3] mm/slub: aggregate objects in cache by stack trace

From: Oliver Glitta <glittao@...il.com>

Aggregate objects in slub cache by stack trace in addition to caller
address during alloc_calls and free_calls implementation
in debugfs. Add stack trace to output.

Add all_objects implementation to debugfs to print information
about all objects.

Signed-off-by: Oliver Glitta <glittao@...il.com>
---
Based on next-20210518 and
https://lore.kernel.org/r/1621341949-26762-1-git-send-email-faiyazm@codeaurora.org/

 mm/slub.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index e9b84eddc50d..d5ed6ed7d68b 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4770,6 +4770,7 @@ EXPORT_SYMBOL(validate_slab_cache);
  */

 struct location {
+	depot_stack_handle_t handle;
 	unsigned long count;
 	unsigned long addr;
 	long long sum_time;
@@ -4822,9 +4823,15 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
 {
 	long start, end, pos;
 	struct location *l;
-	unsigned long caddr;
+	unsigned long caddr, chandle;
 	unsigned long age = jiffies - track->when;
+	depot_stack_handle_t handle;

+#ifdef CONFIG_STACKDEPOT
+	handle = READ_ONCE(track->handle);
+#else
+	handle = 0;
+#endif
 	start = -1;
 	end = t->count;

@@ -4839,7 +4846,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
 			break;

 		caddr = t->loc[pos].addr;
-		if (track->addr == caddr) {
+		chandle = t->loc[pos].handle;
+		if ((track->addr == caddr) && (handle == chandle)) {

 			l = &t->loc[pos];
 			l->count++;
@@ -4864,6 +4872,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,

 		if (track->addr < caddr)
 			end = pos;
+		else if (track->addr == caddr && handle < chandle)
+			end = pos;
 		else
 			start = pos;
 	}
@@ -4886,6 +4896,7 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
 	l->max_time = age;
 	l->min_pid = track->pid;
 	l->max_pid = track->pid;
+	l->handle = handle;
 	cpumask_clear(to_cpumask(l->cpus));
 	cpumask_set_cpu(track->cpu, to_cpumask(l->cpus));
 	nodes_clear(l->nodes);
@@ -5837,6 +5848,21 @@ static int slab_debugfs_show(struct seq_file *seq, void *v)
 			seq_printf(seq, " nodes=%*pbl",
 				 nodemask_pr_args(&l->nodes));

+#ifdef CONFIG_STACKDEPOT
+		{
+			depot_stack_handle_t handle;
+			unsigned long *entries;
+			unsigned int nr_entries, j;
+
+			handle = READ_ONCE(l->handle);
+			if (handle) {
+				nr_entries = stack_depot_fetch(handle, &entries);
+				seq_puts(seq, "\n");
+				for (j = 0; j < nr_entries; j++)
+					seq_printf(seq, "\t%pS\n", (void *)entries[j]);
+			}
+		}
+#endif
 		seq_puts(seq, "\n");
 	}

--
2.31.1.272.g89b43f80a5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ