From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: "Harry Yoo (Oracle)" <harry@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Suren Baghdasaryan <surenb@google.com>, Hao Ge <hao.ge@linux.dev>,
Kees Cook <kees@kernel.org>, Pedro Falcato <pfalcato@suse.de>,
Shakeel Butt <shakeel.butt@linux.dev>,
Danielle Constantino <dcostantino@meta.com>,
"Liam R. Howlett" <liam@infradead.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH slab/for-next-fixes v2 0/3] mm/slab: fix unbounded recursion in free path with memalloc profiling
Date: Fri, 10 Jul 2026 15:07:32 +0200 [thread overview]
Message-ID: <32a056e2-e641-4aaa-887e-586d997feefc@kernel.org> (raw)
In-Reply-To: <20260710-kmalloc-no-objext-v2-0-2709afb6a030@kernel.org>
On 7/10/26 08:03, Harry Yoo (Oracle) wrote:
> This is a follow-up fix after the recent discussion [1].
> See patch 2 for the detailed description on the bug.
>
> Based on slab/for-next-fixes (72bb229f916) and will be soon available
> at git.kernel.org [2].
>
> Instead preventing cycles by bumping up the allocation size of obj_exts
> arrays, it introduces a new kmalloc type called KMALLOC_NO_OBJ_EXT and
> disallow formation of cycles between kmalloc types when allocating
> obj_exts arrays. obj_exts arrays of normal kmalloc caches are served
> from KMALLOC_NO_OBJ_EXT caches (that don't have obj_exts), and all other
> obj_exts arrays are served from normal kmalloc caches.
Since we agreed to investigate later whether it makes sense to start
allocating all obj_ext allocations from the new type, I wonder if for now we
should not create them at all if they won't be used - if anything to avoid
polluting slabinfo. AFAIU that means only create them with mem alloc
profiling is config-enabled and mem_profiling_support == true?
(Or probably also with SLUB_TINY && MEMCG, as nonsensical as it is...)
> I tried to reuse SLAB_ALLOC_NO_RECURSE to make kmalloc_slab() select
> KMALLOC_NO_OBJ_EXT, but it was not great because it does not allow
> sheaves for those caches. So I introduced a new slab alloc flag
> SLAB_ALLOC_NO_OBJ_EXT.
>
> To avoid huge confusion, I had to decouple "disallowing sheaves"
> semantics from SLAB_NO_OBJ_EXT and introduced SLAB_NO_SHEAVES.
>
> While this cannot be directly backported to v6.18 and v6.12 due to lack
> of SLAB_ALLOC_* flags and kmalloc_flags(), I don't this will be
> particularily challenging to backport it. Instead of a new slab alloc
> flag, we can use __GFP_NO_OBJ_EXT to select KMALLOC_NO_OBJ_EXT as
> kmalloc caches don't have sheaves in v6.18 anyway.
>
> [1] https://lore.kernel.org/linux-mm/9a139365-28e6-4f1e-b35b-7f6091e9aa14@kernel.org
>
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/harry/linux.git/log/?h=kmalloc-no-objext-v2r2
>
> [ "v2r2" because after exposing v2r1 I adjusted some of Vlastimil's
> feedback and fixed a memory leak due to bootstrapping twice when
> kmalloc caches are aliased ]
>
> Signed-off-by: Harry Yoo (Oracle) <harry@kernel.org>
> ---
> Changes in v2:
> - Fix a memory leak when kmalloc caches are aliased (patch 1).
> This is included as part of this series as patch 3 makes it
> easier to trigger the leak.
>
> - Fix a warning in MEM_ALLOC_PROFILING_DEBUG by dropping
> mark_obj_codetag_empty() for obj_exts. Sashiko raised this and
> I reproduced it and confirmed that the warnings are gone.
> https://sashiko.dev/#/patchset/20260702-kmalloc-no-objext-v1-0-167175008538%40kernel.org
>
> - Added R-b from Vlastimil on patch 2, thanks!
> - Adjusted Vlastimil's feedback on RFC v1
> - Link to v1: https://lore.kernel.org/r/20260702-kmalloc-no-objext-v1-0-167175008538@kernel.org
>
> ---
> Harry Yoo (Oracle) (3):
> mm/slab: fix a memory leak due to bootstrapping sheaves twice
> mm/slab: decouple SLAB_NO_SHEAVES from SLAB_NO_OBJ_EXT
> mm/slab: prevent unbounded recursion in free path with new kmalloc type
>
> include/linux/slab.h | 16 +++++++-
> mm/slab.h | 15 +++++--
> mm/slab_common.c | 18 ++++++++-
> mm/slub.c | 109 +++++++++++++++++++++------------------------------
> 4 files changed, 88 insertions(+), 70 deletions(-)
> ---
> base-commit: 72bb229f9161a1efcd5df32141b69fcc6ae81a13
> change-id: 20260702-kmalloc-no-objext-2619c1e06083
>
> Best regards,
next prev parent reply other threads:[~2026-07-10 13:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 6:03 [PATCH slab/for-next-fixes v2 0/3] mm/slab: fix unbounded recursion in free path with memalloc profiling Harry Yoo (Oracle)
2026-07-10 6:03 ` [PATCH slab/for-next-fixes v2 1/3] mm/slab: fix a memory leak due to bootstrapping sheaves twice Harry Yoo (Oracle)
2026-07-10 6:03 ` [PATCH slab/for-next-fixes v2 2/3] mm/slab: decouple SLAB_NO_SHEAVES from SLAB_NO_OBJ_EXT Harry Yoo (Oracle)
2026-07-10 6:03 ` [PATCH slab/for-next-fixes v2 3/3] mm/slab: prevent unbounded recursion in free path with new kmalloc type Harry Yoo (Oracle)
2026-07-10 13:07 ` Vlastimil Babka (SUSE) [this message]
2026-07-10 13:44 ` [PATCH slab/for-next-fixes v2 0/3] mm/slab: fix unbounded recursion in free path with memalloc profiling Harry Yoo
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=32a056e2-e641-4aaa-887e-586d997feefc@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=dcostantino@meta.com \
--cc=hao.ge@linux.dev \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=kees@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pfalcato@suse.de \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--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 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.