From: Harry Yoo <harry@kernel.org>
To: hu.shengming@zte.com.cn
Cc: vbabka@kernel.org, akpm@linux-foundation.org, hao.li@linux.dev,
cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev,
ast@kernel.org, andrii@kernel.org, puranjay@kernel.org,
ameryhung@gmail.com, bigeasy@linutronix.de, clrkwllms@kernel.org,
rostedt@goodmis.org, paulmck@kernel.org, frederic@kernel.org,
neeraj.upadhyay@kernel.org, joelagnelf@nvidia.com,
josh@joshtriplett.org, boqun@kernel.org, urezki@gmail.com,
mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,
qiang.zhang@linux.dev, pfalcato@suse.de, surenb@google.com,
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 4/8] mm/slab: extend deferred free mechanism to handle rcu sheaves
Date: Fri, 24 Jul 2026 20:42:52 +0900 [thread overview]
Message-ID: <07adab0f-12cc-4f48-bf23-4aaef67ab405@kernel.org> (raw)
In-Reply-To: <20260723182727858gUQJ4TgRU2b6v1kdgpkfV@zte.com.cn>
[-- Attachment #1.1: Type: text/plain, Size: 2833 bytes --]
On 7/23/26 7:27 PM, hu.shengming@zte.com.cn wrote:
> Harry wrote:
>> __kfree_rcu_sheaf() cannot invoke call_rcu() when spinning is not
>> allowed and IRQs are disabled. To relax the limitation, extend the
>> deferred free fallback so that a full rcu sheaf can be submitted to
>> call_rcu() via the existing IRQ work.
>>
>> Since the deferred mechanism does more than deferred freeing of objects,
>> rename the struct to deferred_percpu_work and adjust names accordingly.
>>
>> When a sheaf is queued on an IRQ work, it is detached from
>> pcs->rcu_free but call_rcu() is not invoked until the irq_work runs.
>> To keep the kvfree_rcu barrier's promise, call irq_work_sync() on each
>> CPU before calling rcu_barrier().
>>
>> In the meantime, remove the TODO item as apparently there is no simple
>> and effective way to achieve that. This is because, unlike sheaves,
>> kfree_rcu() batches objects from different caches together.
>>
>> Suggested-by: Alexei Starovoitov <ast@kernel.org>
>> Reviewed-by: Pedro Falcato <pfalcato@suse.de>
>> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
>> Signed-off-by: Harry Yoo (Oracle) <harry@kernel.org>
>> ---
>> mm/slab.h | 2 +-
>> mm/slab_common.c | 7 ++---
>> mm/slub.c | 85 +++++++++++++++++++++++++++++++++-----------------------
>> 3 files changed, 53 insertions(+), 41 deletions(-)
>>
>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>> index e07b4e6d6679..9c9ae1384f47 100644
>> --- a/mm/slab_common.c
>> +++ b/mm/slab_common.c
>> @@ -551,7 +551,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
>> }
>>
>> /* Wait for deferred work from kmalloc/kfree_nolock() */
>> - defer_free_barrier();
>> + deferred_work_barrier();
>>
>> cpus_read_lock();
>> mutex_lock(&slab_mutex);
>
> Hi Harry,
Hi Shengming,
> I noticed that your fix in [1] serializes defer_free_barrier() to
> avoid concurrent irq_work_sync() waiters.
Right.
> However, this patch still calls the renamed deferred_work_barrier()
> outside that serialization scope, including the new call sites in
> kvfree_rcu_barrier_on_cache() and flush_all_rcu_sheaves().
Good point!
I didn't _fix_ that as part of this patch since that would be confusing
and the fix didn't land the mainline or slab yet.
> Is this series expected to depend on [1], with these call sites
> moved under the same serialization? Or am I missing something?
I was thinking of rebasing the fixes as there won't be much conflicts,
nobody except for sashiko complained about this, and we're not going to
backport them anyway.
> [1]
> https://lore.kernel.org/all/20260624-kmalloc-nolock-fixes-v1-4-fdf4d17351dd@kernel.org/
>
> thanks,
>
> --
> With Best Regards,
> Shengming
--
Cheers,
Harry / Hyeonggon
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-07-24 11:43 UTC|newest]
Thread overview: 27+ 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-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-21 10:07 ` Vlastimil Babka (SUSE)
2026-07-22 7:28 ` Harry Yoo
2026-07-22 7:37 ` Vlastimil Babka (SUSE)
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 12:44 ` [PATCH slab/for-next v4 4/8] mm/slab: extend deferred free mechanism to handle rcu sheaves Harry Yoo (Oracle)
2026-07-23 10:27 ` hu.shengming
2026-07-24 11:42 ` Harry Yoo [this message]
2026-07-24 14:10 ` hu.shengming
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-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-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-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=07adab0f-12cc-4f48-bf23-4aaef67ab405@kernel.org \
--to=harry@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=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 \
--cc=vbabka@kernel.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