linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Suren Baghdasaryan <surenb@google.com>, akpm@linux-foundation.org
Cc: kent.overstreet@linux.dev, pasha.tatashin@soleen.com,
	souravpanda@google.com, keescook@chromium.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH 1/1] mm/slab: fix 'variable obj_exts set but not used' warning
Date: Mon, 17 Jun 2024 12:04:28 +0200	[thread overview]
Message-ID: <18a30d5c-abf3-4ceb-a7fd-2edfd8bee2a8@suse.cz> (raw)
In-Reply-To: <20240614225951.3845577-1-surenb@google.com>

On 6/15/24 12:59 AM, Suren Baghdasaryan wrote:
> slab_post_alloc_hook() uses prepare_slab_obj_exts_hook() to obtain
> slabobj_ext object. Currently the only user of slabobj_ext object in
> this path is memory allocation profiling, therefore when it's not enabled
> this object is not needed. This also generates a warning when compiling
> with CONFIG_MEM_ALLOC_PROFILING=n. Move the code under this configuration
> to fix the warning. If more slabobj_ext users appear in the future, the
> code will have to be changed back to call prepare_slab_obj_exts_hook().
> 
> Fixes: 4b8736964640 ("mm/slab: add allocation accounting into slab allocation and free paths")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202406150444.F6neSaiy-lkp@intel.com/
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>

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

But it seems to me we could remove the whole #ifdef if current->alloc_tag
(which doesn't exist with !MEM_ALLOC_PROFILING) had an access helper, or
there was a alloc_tag_add_current() variant?

> ---
>  mm/slub.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 1373ac365a46..4927edec6a8c 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3902,7 +3902,6 @@ bool slab_post_alloc_hook(struct kmem_cache *s, struct list_lru *lru,
>  			  unsigned int orig_size)
>  {
>  	unsigned int zero_size = s->object_size;
> -	struct slabobj_ext *obj_exts;
>  	bool kasan_init = init;
>  	size_t i;
>  	gfp_t init_flags = flags & gfp_allowed_mask;
> @@ -3945,9 +3944,11 @@ bool slab_post_alloc_hook(struct kmem_cache *s, struct list_lru *lru,
>  		kmemleak_alloc_recursive(p[i], s->object_size, 1,
>  					 s->flags, init_flags);
>  		kmsan_slab_alloc(s, p[i], init_flags);
> +#ifdef CONFIG_MEM_ALLOC_PROFILING
>  		if (need_slab_obj_ext()) {
> +			struct slabobj_ext *obj_exts;
> +
>  			obj_exts = prepare_slab_obj_exts_hook(s, flags, p[i]);
> -#ifdef CONFIG_MEM_ALLOC_PROFILING
>  			/*
>  			 * Currently obj_exts is used only for allocation profiling.
>  			 * If other users appear then mem_alloc_profiling_enabled()
> @@ -3955,8 +3956,8 @@ bool slab_post_alloc_hook(struct kmem_cache *s, struct list_lru *lru,
>  			 */
>  			if (likely(obj_exts))
>  				alloc_tag_add(&obj_exts->ref, current->alloc_tag, s->size);
> -#endif
>  		}
> +#endif
>  	}
>  
>  	return memcg_slab_post_alloc_hook(s, lru, flags, size, p);
> 
> base-commit: c286c21ff94252f778515b21b6bebe749454a852



  reply	other threads:[~2024-06-17 10:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14 22:59 Suren Baghdasaryan
2024-06-17 10:04 ` Vlastimil Babka [this message]
2024-06-30 19:20   ` Suren Baghdasaryan
2024-07-02  9:31     ` Vlastimil Babka
2024-07-02 15:16       ` Suren Baghdasaryan
2024-07-03  1:58         ` Suren Baghdasaryan

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=18a30d5c-abf3-4ceb-a7fd-2edfd8bee2a8@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=souravpanda@google.com \
    --cc=surenb@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