From: "David Wang" <00107082@163.com>
To: "Suren Baghdasaryan" <surenb@google.com>
Cc: akpm@linux-foundation.org, vbabka@suse.cz, harry.yoo@oracle.com,
cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re:[PATCH v2 1/1] mm/slab: mark alloc tags empty for sheafs allocated with __GFP_NO_OBJ_EXT
Date: Wed, 25 Feb 2026 10:50:35 +0800 (CST) [thread overview]
Message-ID: <6bebf90c.1ff0.19c92b4998d.Coremail.00107082@163.com> (raw)
In-Reply-To: <20260224221132.1702713-1-surenb@google.com>
At 2026-02-25 06:11:32, "Suren Baghdasaryan" <surenb@google.com> wrote:
>alloc_empty_sheaf() allocates sheafs from SLAB_KMALLOC caches using
>__GFP_NO_OBJ_EXT to avoid recursion, however it does not mark their
>allocation tags empty before freeing, which results in a warning when
>CONFIG_MEM_ALLOC_PROFILING_DEBUG is set. Fix this by marking allocation
>tags for such allocations as empty.
>
>Reported-by: David Wang <00107082@163.com>
>Closes: https://lore.kernel.org/all/20260223155128.3849-1-00107082@163.com/
>Analyzed-by: Harry Yoo <harry.yoo@oracle.com>
>Signed-off-by: Suren Baghdasaryan <surenb@google.com>
>---
> mm/slab.h | 4 ++--
> mm/slub.c | 23 +++++++++++++++--------
> 2 files changed, 17 insertions(+), 10 deletions(-)
>
>diff --git a/mm/slab.h b/mm/slab.h
>index 71c7261bf822..f6ef862b60ef 100644
>--- a/mm/slab.h
>+++ b/mm/slab.h
>@@ -290,14 +290,14 @@ static inline void *nearest_obj(struct kmem_cache *cache,
>
> /* Determine object index from a given position */
> static inline unsigned int __obj_to_index(const struct kmem_cache *cache,
>- void *addr, void *obj)
>+ void *addr, const void *obj)
> {
> return reciprocal_divide(kasan_reset_tag(obj) - addr,
> cache->reciprocal_size);
> }
>
> static inline unsigned int obj_to_index(const struct kmem_cache *cache,
>- const struct slab *slab, void *obj)
>+ const struct slab *slab, const void *obj)
> {
> if (is_kfence_address(obj))
> return 0;
>diff --git a/mm/slub.c b/mm/slub.c
>index 862642c165ed..5c76e55eee7d 100644
>--- a/mm/slub.c
>+++ b/mm/slub.c
>@@ -2041,18 +2041,18 @@ static inline void dec_slabs_node(struct kmem_cache *s, int node,
>
> #ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG
>
>-static inline void mark_objexts_empty(struct slabobj_ext *obj_exts)
>+static inline void mark_objexts_empty(const void *obj)
> {
>- struct slab *obj_exts_slab;
>+ struct slab *obj_slab;
> unsigned long slab_exts;
>
>- obj_exts_slab = virt_to_slab(obj_exts);
>- slab_exts = slab_obj_exts(obj_exts_slab);
>+ obj_slab = virt_to_slab(obj);
>+ slab_exts = slab_obj_exts(obj_slab);
> if (slab_exts) {
> get_slab_obj_exts(slab_exts);
>- unsigned int offs = obj_to_index(obj_exts_slab->slab_cache,
>- obj_exts_slab, obj_exts);
>- struct slabobj_ext *ext = slab_obj_ext(obj_exts_slab,
>+ unsigned int offs = obj_to_index(obj_slab->slab_cache,
>+ obj_slab, obj);
>+ struct slabobj_ext *ext = slab_obj_ext(obj_slab,
> slab_exts, offs);
>
> if (unlikely(is_codetag_empty(&ext->ref))) {
>@@ -2090,7 +2090,7 @@ static inline void handle_failed_objexts_alloc(unsigned long obj_exts,
>
> #else /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
>
>-static inline void mark_objexts_empty(struct slabobj_ext *obj_exts) {}
>+static inline void mark_objexts_empty(const void *obj) {}
> static inline bool mark_failed_objexts_alloc(struct slab *slab) { return false; }
> static inline void handle_failed_objexts_alloc(unsigned long obj_exts,
> struct slabobj_ext *vec, unsigned int objects) {}
>@@ -2312,6 +2312,10 @@ static void alloc_slab_obj_exts_early(struct kmem_cache *s, struct slab *slab)
>
> #else /* CONFIG_SLAB_OBJ_EXT */
>
>+static inline void mark_objexts_empty(const void *obj)
>+{
>+}
>+
> static inline void init_slab_obj_exts(struct slab *slab)
> {
> }
>@@ -2783,6 +2787,9 @@ static inline struct slab_sheaf *alloc_empty_sheaf(struct kmem_cache *s,
>
> static void free_empty_sheaf(struct kmem_cache *s, struct slab_sheaf *sheaf)
> {
>+ if (s->flags & SLAB_KMALLOC)
>+ mark_objexts_empty(sheaf);
>+
> kfree(sheaf);
>
> stat(s, SHEAF_FREE);
>
>base-commit: 7dff99b354601dd01829e1511711846e04340a69
>--
>2.53.0.414.gf7e9f6c205-goog
Tested-by: David Wang <00107082@163.com>
David
prev parent reply other threads:[~2026-02-25 2:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 22:11 [PATCH " Suren Baghdasaryan
2026-02-25 2:26 ` Harry Yoo
2026-02-25 2:50 ` David Wang [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=6bebf90c.1ff0.19c92b4998d.Coremail.00107082@163.com \
--to=00107082@163.com \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=harry.yoo@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
/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