From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Harry Yoo <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>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Puranjay Mohan <puranjay@kernel.org>,
Amery Hung <ameryhung@gmail.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>, Pedro Falcato <pfalcato@suse.de>,
Suren Baghdasaryan <surenb@google.com>,
Shengming Hu <hu.shengming@zte.com.cn>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev, rcu@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH slab/for-next v4 2/8] mm/slab: handle the !allow_spin case in kfree_rcu_sheaf()
Date: Wed, 22 Jul 2026 09:37:43 +0200 [thread overview]
Message-ID: <c66cf308-943d-4fc3-ae84-e81bdbb384ec@kernel.org> (raw)
In-Reply-To: <0ce88f37-f231-4a00-b06b-95b0910c2db0@kernel.org>
On 7/22/26 09:28, Harry Yoo wrote:
>> Nits below:
>>
>>> ---
>>> mm/slab.h | 18 +++++++++++++++++-
>>> mm/slab_common.c | 2 +-
>>> mm/slub.c | 36 ++++++++++++++++++++++++++++--------
>>> 3 files changed, 46 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/mm/slab.h b/mm/slab.h
>>> index 281a65233795..85ef2ebc9812 100644
>>> --- a/mm/slab.h
>>> +++ b/mm/slab.h
>>> @@ -429,7 +445,7 @@ static inline bool is_kmalloc_normal(struct kmem_cache *s)
>>> return !(s->flags & (SLAB_CACHE_DMA|SLAB_ACCOUNT|SLAB_RECLAIM_ACCOUNT));
>>> }
>>>
>>> -bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj);
>>> +bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj, unsigned int free_flags);
>>> void flush_all_rcu_sheaves(void);
>>> void flush_rcu_sheaves_on_cache(struct kmem_cache *s);
>>>
>>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>>> index b6426d7ceec9..e07b4e6d6679 100644
>>> --- a/mm/slab_common.c
>>> +++ b/mm/slab_common.c
>>> @@ -1605,7 +1605,7 @@ static bool kfree_rcu_sheaf(void *obj)
>>>
>>> s = slab->slab_cache;
>>> if (likely(!IS_ENABLED(CONFIG_NUMA) || slab_nid(slab) == numa_mem_id()))
>>> - return __kfree_rcu_sheaf(s, obj);
>>> + return __kfree_rcu_sheaf(s, obj, SLAB_FREE_DEFAULT);
>>>
>>> return false;
>>> }
>>> diff --git a/mm/slub.c b/mm/slub.c
>>> index e32a68677537..0c350274fbff 100644
>>> --- a/mm/slub.c
>>> +++ b/mm/slub.c
>>> @@ -2814,10 +2814,14 @@ static inline struct slab_sheaf *alloc_empty_sheaf(struct kmem_cache *s,
>>>
>>> gfp &= ~OBJCGS_CLEAR_MASK;
>>>
>>> + if (alloc_flags & SLAB_ALLOC_NOLOCK)
>>> + gfp &= ~__GFP_RECLAIM;
>>
>> So in general we expect gfp and alloc flags to be compatible and warn if
>> they are not. This now performs an auto-adjustment, which makes it unusual.
>
> That's fair.
>
>> But AFAICS only one caller relies on it - __kfree_rcu_sheaf(). So maybe we
>> could just do it there?
>
> Will do. I don't have strong preference on this.
Thanks!
>>> return __alloc_empty_sheaf(s, gfp, alloc_flags, s->sheaf_capacity);
>>> }
>>>
>>> -static void free_empty_sheaf(struct kmem_cache *s, struct slab_sheaf *sheaf)
>>> +static void __free_empty_sheaf(struct kmem_cache *s, struct slab_sheaf *sheaf,
>>> + bool allow_spin)
>>
>> Why not free_flags instead of allow_spin? Since you already introduced them.
>
> Indeed I tried that but gave up on doing that as part of series
> after realizing free_empty_sheaf() alone has 12 callers :)
Yeah but I meant __free_empty_sheaf() only. It's fine to leave the wrapper
without the new parameter for the most common case, like you did.
> But I think it's worth teaching those functions (including
> free_empty_sheaf()) to handle SLAB_ALLOC_* and SLAB_FREE_* flags
> rather than propagating allow_spin.
It doesn't have to be now :)
next prev parent reply other threads:[~2026-07-22 7:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 12:44 [PATCH slab/for-next v4 0/8] mm/slab: introduce kfree_rcu_nolock() and improve slub_kunit coverage Harry Yoo (Oracle)
2026-07-20 12:44 ` [PATCH slab/for-next v4 1/8] mm/slab, slub_kunit: register kprobe to trigger _nolock APIs Harry Yoo (Oracle)
2026-07-20 12:56 ` sashiko-bot
2026-07-22 3:27 ` hu.shengming
2026-07-22 7:16 ` Harry Yoo
2026-07-22 8:32 ` hu.shengming
2026-07-20 12:44 ` [PATCH slab/for-next v4 2/8] mm/slab: handle the !allow_spin case in kfree_rcu_sheaf() Harry Yoo (Oracle)
2026-07-20 13:11 ` sashiko-bot
2026-07-21 10:07 ` Vlastimil Babka (SUSE)
2026-07-22 7:28 ` Harry Yoo
2026-07-22 7:37 ` Vlastimil Babka (SUSE) [this message]
2026-07-22 7:39 ` Harry Yoo
2026-07-20 12:44 ` [PATCH slab/for-next v4 3/8] mm/slab: use call_rcu() in unknown context if irqs are enabled Harry Yoo (Oracle)
2026-07-20 13:01 ` sashiko-bot
2026-07-20 12:44 ` [PATCH slab/for-next v4 4/8] mm/slab: extend deferred free mechanism to handle rcu sheaves Harry Yoo (Oracle)
2026-07-20 13:03 ` sashiko-bot
2026-07-20 12:44 ` [PATCH slab/for-next v4 5/8] mm/slab: allow kfree_rcu_sheaf() on PREEMPT_RT Harry Yoo (Oracle)
2026-07-20 12:56 ` sashiko-bot
2026-07-21 10:46 ` Vlastimil Babka (SUSE)
2026-07-22 7:41 ` Harry Yoo
2026-07-20 12:44 ` [PATCH slab/for-next v4 6/8] mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching Harry Yoo (Oracle)
2026-07-20 13:09 ` sashiko-bot
2026-07-21 11:06 ` Vlastimil Babka (SUSE)
2026-07-22 7:42 ` Harry Yoo
2026-07-20 12:44 ` [PATCH slab/for-next v4 7/8] mm/slab: introduce kfree_rcu_nolock() Harry Yoo (Oracle)
2026-07-20 13:07 ` sashiko-bot
2026-07-21 13:09 ` Vlastimil Babka (SUSE)
2026-07-22 8:15 ` Harry Yoo
2026-07-22 10:05 ` Vlastimil Babka (SUSE)
2026-07-22 13:03 ` Harry Yoo
2026-07-20 12:44 ` [PATCH slab/for-next v4 8/8] slub_kunit: extend the test for kfree_rcu_nolock() Harry Yoo (Oracle)
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=c66cf308-943d-4fc3-ae84-e81bdbb384ec@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=boqun@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cl@gentwo.org \
--cc=clrkwllms@kernel.org \
--cc=frederic@kernel.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=hu.shengming@zte.com.cn \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=pfalcato@suse.de \
--cc=puranjay@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--cc=urezki@gmail.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.