linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Faiyaz Mohammed <faiyazm@codeaurora.org>,
	cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org, greg@kroah.com,
	glittao@gmail.com
Cc: vinmenon@codeaurora.org
Subject: Re: [PATCH v10] mm: slub: move sysfs slab alloc/free interfaces to debugfs
Date: Mon, 7 Jun 2021 12:12:04 +0200	[thread overview]
Message-ID: <c12f642f-0f04-5a58-0966-41cbeb74c066@suse.cz> (raw)
In-Reply-To: <1622996045-25826-1-git-send-email-faiyazm@codeaurora.org>

On 6/6/21 6:14 PM, Faiyaz Mohammed wrote:
> alloc_calls and free_calls implementation in sysfs have two issues,
> one is PAGE_SIZE limitiation of sysfs and other is it does not adhere
> to "one value per file" rule.
> 
> To overcome this issues, move the alloc_calls and free_calls implemeation
> to debugfs.
> 
> Debugfs cache will be created if SLAB_STORE_USER flag is set.
> 
> Rename the alloc_calls/free_calls to alloc_traces/free_traces,
> to be inline with what it does.
> 
> Signed-off-by: Faiyaz Mohammed <faiyazm@codeaurora.org>
> ---
>  mm/slab.h        |   8 ++
>  mm/slab_common.c |   2 +
>  mm/slub.c        | 292 +++++++++++++++++++++++++++++++++++++------------------
>  3 files changed, 209 insertions(+), 93 deletions(-)
> 

...

> +static int slab_debug_trace_open(struct inode *inode, struct file *filep)
> +{
> +
> +	struct kmem_cache_node *n;
> +	enum track_item alloc;
> +	int node;
> +	struct loc_track *t = __seq_open_private(filep, &slab_debugfs_sops,
> +						sizeof(struct loc_track));
> +	struct kmem_cache *s = file_inode(filep)->i_private;
> +
> +	if (strcmp(filep->f_path.dentry->d_name.name, "alloc_traces") == 0)
> +		alloc =  TRACK_ALLOC;

			^ extra space here?

> +	else
> +		alloc =  TRACK_FREE;

same here

> +
> +	if (!alloc_loc_track(t, PAGE_SIZE / sizeof(struct location), GFP_KERNEL)) {
> +		pr_err("Out of memory\n");

Hm I would remove this. It doesn't print any context, so it's not useful to let
users know where/why we ran out of memory. Also if a GFP_KERNEL allocation
fails, there will be a big warning including stacktrace from the page allocator
anyway.

> +		return -ENOMEM;
> +	}
> +
> +	/* Push back cpu slabs */
> +	flush_all(s);
> +
> +	for_each_kmem_cache_node(s, node, n) {
> +		unsigned long flags;
> +		struct page *page;
> +
> +		if (!atomic_long_read(&n->nr_slabs))
> +			continue;
> +
> +		spin_lock_irqsave(&n->list_lock, flags);
> +		list_for_each_entry(page, &n->partial, slab_list)
> +			process_slab(t, s, page, alloc);
> +		list_for_each_entry(page, &n->full, slab_list)
> +			process_slab(t, s, page, alloc);
> +			spin_unlock_irqrestore(&n->list_lock, flags);

At least this is not Python, so it's just a visual flaw :)

> +	}
> +
> +	return 0;
> +}
> +
> +static int slab_debug_trace_release(struct inode *inode, struct file *file)
> +{
> +	struct seq_file *seq = file->private_data;
> +	struct loc_track *t = seq->private;
> +
> +	free_loc_track(t);
> +	kfree(seq->private);
> +	seq->private = NULL;
> +	return seq_release(inode, file);

You can call seq_release_private() instead and deal just with free_loc_track here.

Thanks!
Vlastimil

      parent reply	other threads:[~2021-06-07 10:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-06 16:14 [PATCH v10] mm: slub: move sysfs slab alloc/free interfaces to debugfs Faiyaz Mohammed
2021-06-06 18:44 ` kernel test robot
2021-06-06 20:31 ` Andy Shevchenko
2021-06-07  2:40   ` Faiyaz Mohammed
2021-06-07  8:42     ` Andy Shevchenko
2021-06-07 13:54   ` Faiyaz Mohammed
2021-06-07 16:42     ` Andy Shevchenko
2021-06-07  2:01 ` Faiyaz Mohammed
2021-06-07 10:12 ` 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=c12f642f-0f04-5a58-0966-41cbeb74c066@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=faiyazm@codeaurora.org \
    --cc=glittao@gmail.com \
    --cc=greg@kroah.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 \
    --cc=vinmenon@codeaurora.org \
    /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;
as well as URLs for NNTP newsgroup(s).