Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 891d9b3e authored by Faiyaz Mohammed's avatar Faiyaz Mohammed
Browse files

mm: slub: update slab_alloc interface to capture slab stacks



Update /sys/kernel/debug/slab/alloc_trace interface to capture
slab stack along with slab object details.

Now output of alloc_trace is:
alloc_list: call_site=mempool_alloc_slab+0x1c/0x28 count=2 object_size=1024
slab_size=1472 slab_name=sgpool-32

mempool_alloc_slab+0x1c/0x28

mempool_init_node+0xdc/0x238

mempool_create+0x58/0x88

sg_pool_init+0x70/0xf8

do_one_initcall+0x15c/0x2e8

kernel_init_freeable+0x334/0x3d8

kernel_init+0x18/0x298

ret_from_fork+0x10/0x18.

Change-Id: I19da702bfd22e5526e2c9a04d22717dc70700ae7
Signed-off-by: default avatarFaiyaz Mohammed <faiyazm@codeaurora.org>
parent 37cdb7af
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -4568,6 +4568,9 @@ struct location {
	long max_pid;
	DECLARE_BITMAP(cpus, NR_CPUS);
	nodemask_t nodes;
#ifdef CONFIG_STACKTRACE
	unsigned long addrs[TRACK_ADDRS_COUNT]; /* Called from address */
#endif
};

struct loc_track {
@@ -4610,6 +4613,7 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
	struct location *l;
	unsigned long caddr;
	unsigned long age = jiffies - track->when;
	unsigned int i = 0;

	start = -1;
	end = t->count;
@@ -4667,6 +4671,15 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
	t->count++;
	l->count = 1;
	l->addr = track->addr;
#ifdef CONFIG_STACKTRACE
	for (i = 0; i < TRACK_ADDRS_COUNT; i++)
		if (l->addrs[i]) {
			l->addrs[i] = track->addrs[i];
			continue;
		} else
			break;

#endif
	l->sum_time = age;
	l->min_time = age;
	l->max_time = age;
@@ -6126,10 +6139,19 @@ static int alloc_trace_locations(struct seq_file *seq, struct kmem_cache *s,

	for (i = 0; i < t.count; i++) {
		struct location *l = &t.loc[i];
		unsigned int j = 0;

		seq_printf(seq,
		"alloc_list: call_site=%pS count=%zu object_size=%zu slab_size=%zu slab_name=%s\n",
			l->addr, l->count, s->object_size, s->size, s->name);
#ifdef CONFIG_STACKTRACE
		for (j = 0; j < TRACK_ADDRS_COUNT; j++)
			if (l->addrs[j]) {
				seq_printf(seq, "%pS\n", l->addrs[j]);
				continue;
			} else
				break;
#endif
	}

	free_loc_track(&t);