mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: glittao@gmail.com, cl@linux.com, penberg@kernel.org,
	rientjes@google.com, iamjoonsoo.kim@lge.com,
	akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, faiyazm@codeaurora.org
Subject: Re: [RFC 1/3] mm/slub: aggregate objects in cache by stack trace
Date: Wed, 26 May 2021 16:05:38 +0200	[thread overview]
Message-ID: <127bfde8-7356-8c2a-6a5a-7fa17db7fa33@suse.cz> (raw)
In-Reply-To: <20210521121127.24653-1-glittao@gmail.com>

On 5/21/21 2:11 PM, glittao@gmail.com wrote:
> From: Oliver Glitta <glittao@gmail.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.

Yes, the immediate callers alone often don't tell much.

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

Looks like this sentence applies only to patch 3/3.

> Signed-off-by: Oliver Glitta <glittao@gmail.com>

Reviewed-by: Vlastimil Babka <vbabka@suse.cz>

> ---
> 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
> 


  parent reply	other threads:[~2021-05-26 14:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 12:11 glittao
2021-05-21 12:11 ` [RFC 2/3] mm/slub: sort objects in cache by frequency of " glittao
2021-05-26 14:06   ` 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 ` Vlastimil Babka [this message]
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=127bfde8-7356-8c2a-6a5a-7fa17db7fa33@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=faiyazm@codeaurora.org \
    --cc=glittao@gmail.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    /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

all inboxes | Powered by JetHome®