All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: "Stéphane Graber" <stgraber@ubuntu.com>, linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Faiyaz Mohammed <faiyazm@codeaurora.org>,
	stable@vger.kernel.org, Christoph Lameter <cl@linux.com>,
	David Rientjes <rientjes@google.com>,
	Pekka Enberg <penberg@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>
Subject: Re: [PATCH RESEND] tools/vm/slabinfo: Handle files in debugfs
Date: Fri, 24 Jun 2022 11:08:50 +0200	[thread overview]
Message-ID: <73c277f2-7189-81ee-8d6c-624cbd145d4c@suse.cz> (raw)
In-Reply-To: <YrTfEHvpysJAVWWr@castiana>

On 6/23/22 23:45, Stéphane Graber wrote:
> Commit 64dd68497be76 relocated and renamed the alloc_calls and
> free_calls files from /sys/kernel/slab/NAME/*_calls over to
> /sys/kernel/debug/slab/NAME/*_calls but didn't update the slabinfo tool
> with the new location.
> 
> This change will now have slabinfo look at the new location (and filenames)
> with a fallback to the prior files.
> 
> Fixes: 64dd68497be76 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs")
> Cc: stable@vger.kernel.org
> Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
> Tested-by: Stéphane Graber <stgraber@ubuntu.com>

Thanks, added to slab/for-5.20/debug

> ---
>  tools/vm/slabinfo.c | 26 ++++++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
> index 9b68658b6bb8..5b98f3ee58a5 100644
> --- a/tools/vm/slabinfo.c
> +++ b/tools/vm/slabinfo.c
> @@ -233,6 +233,24 @@ static unsigned long read_slab_obj(struct slabinfo *s, const char *name)
>  	return l;
>  }
>  
> +static unsigned long read_debug_slab_obj(struct slabinfo *s, const char *name)
> +{
> +	char x[128];
> +	FILE *f;
> +	size_t l;
> +
> +	snprintf(x, 128, "/sys/kernel/debug/slab/%s/%s", s->name, name);
> +	f = fopen(x, "r");
> +	if (!f) {
> +		buffer[0] = 0;
> +		l = 0;
> +	} else {
> +		l = fread(buffer, 1, sizeof(buffer), f);
> +		buffer[l] = 0;
> +		fclose(f);
> +	}
> +	return l;
> +}
>  
>  /*
>   * Put a size string together
> @@ -409,14 +427,18 @@ static void show_tracking(struct slabinfo *s)
>  {
>  	printf("\n%s: Kernel object allocation\n", s->name);
>  	printf("-----------------------------------------------------------------------\n");
> -	if (read_slab_obj(s, "alloc_calls"))
> +	if (read_debug_slab_obj(s, "alloc_traces"))
> +		printf("%s", buffer);
> +	else if (read_slab_obj(s, "alloc_calls"))
>  		printf("%s", buffer);
>  	else
>  		printf("No Data\n");
>  
>  	printf("\n%s: Kernel object freeing\n", s->name);
>  	printf("------------------------------------------------------------------------\n");
> -	if (read_slab_obj(s, "free_calls"))
> +	if (read_debug_slab_obj(s, "free_traces"))
> +		printf("%s", buffer);
> +	else if (read_slab_obj(s, "free_calls"))
>  		printf("%s", buffer);
>  	else
>  		printf("No Data\n");


      reply	other threads:[~2022-06-24  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 21:45 [PATCH RESEND] tools/vm/slabinfo: Handle files in debugfs Stéphane Graber
2022-06-24  9:08 ` Vlastimil Babka [this message]

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=73c277f2-7189-81ee-8d6c-624cbd145d4c@suse.cz \
    --to=vbabka@suse.cz \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=faiyazm@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=stable@vger.kernel.org \
    --cc=stgraber@ubuntu.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 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.