mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Harry Yoo <harry@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Vlastimil Babka <vbabka@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>
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 for-next v3 0/9] mm/slab: introduce kfree_rcu_nolock() and improve slub_kunit coverage
Date: Tue, 16 Jun 2026 13:57:30 +0900	[thread overview]
Message-ID: <1f95030c-0671-40ce-88fd-69a1127237d0@kernel.org> (raw)
In-Reply-To: <DJ9WNQFQ2B2R.1JSNL1RNABV6Q@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 4275 bytes --]



On 6/16/26 5:28 AM, Alexei Starovoitov wrote:
> On Mon Jun 15, 2026 at 4:05 AM PDT, Harry Yoo (Oracle) wrote:
>> Not the best time to post a series, but didn't want to delay posting
>> the series for too long. no pressures ;)  This is aimed to be queued
>> for review and testing after the merge window closes.
>>
>> This series is based on next-20260612, and is also available on
>> git.kernel.org [3].
>>
>> To RCU folks: It would be great if you could kindly take a quick look at
>> patch 4 and either ack or nack the patch ;)
>>
>> To BPF folks: Ulad asked to share workloads to measure performance
>> of kfree_rcu_nolock(). Unfortunately, I focused more on correctness
>> and have not spent much effort on that. It would be nice if BPF folks
>> could help evaluate it on their relevant workloads.
> 
> kfree_rcu_nolock() needs to replace bpf_mem_alloc which is backbone
> of bpf maps and bpf local storage.

> So all of the selftests/bpf/benchs/run_bench_*.sh

Didn't notice it was a thing, thanks!

> will exercise it one way or the other the replacement is complete.
> In other words performance is absolutely critical.
>
>> To PREEMPT_RT folks: The most relevant part is allowing
>> kfree_rcu_sheaf() on PREEMPT_RT (patch 6). It carefully avoids sleeping
>> by acquiring the locks via local_trylock() or spin_trylock_irqsave()
>> to avoid sleeping within a raw spinlock. When trylock or unlock is
>> unsafe, kmalloc_nolock() always fails.
>>
>> Changes since RFC v2
>> ====================
>>
>> Reduced complexity and intrusiveness (Uladzislau Rezki)
>> -------------------------------------------------------
>>
>> While discussing concerns about the complexity of adding allow_spin
>> handling with Ulad (Thanks!), I realized that adding complexity to the
>> kvfree_rcu batching is not strictly necessary: only slab objects need to
>> be batched, they are already batched by rcu sheaves, and slab already
>> supports unknown context. So it is enough to implement only a minimal
>> fallback for the sheaves path.
>>
>> I tried to avoid making intrusive changes to the existing kvfree_rcu
>> path as much as possible. struct rcu_ptr is renamed to kfree_rcu_head
>> following Vlastimil's suggestion, and it is used only in the
>> kfree_rcu_nolock() path for now.
>>
>> As a result, the complexity is significantly reduced and the series
>> became much less intrusive. This is also reflected well in the diffstat
>> below.
> 
> Overall looks good to me.

Thanks!

> btw sashiko was confused in few cases.
> Not everything that it flags needs a fix. Sometimes it's not an issue at all.
> It only sounds like one.

Right, most of the comments are false positives.
But there is one comment that looks like a real bug...

Sashiko wrote:
> This is a pre-existing issue, but can concurrent lockless calls to
> deferred_work_barrier() cause an rcuwait race on PREEMPT_RT, leading to
> permanent task hangs?
>
> The function iterates over all CPUs, invoking irq_work_sync() on each
> CPU's deferred work object. On PREEMPT_RT, irq_work_sync() relies on
> rcuwait_wait_event() to block until completion,

Yes. If CONFIG_PREEPMT_RT is enabled and irq_work doesn't have
IRQ_WORK_HARD_IRQ, irq_work_sync() calls rcuwait_wait_event().

> and the rcuwait
> synchronization primitive strictly allows only one waiter at a time.

Hmm yeah, include/linux/rcuwait.h says:
| The caller is responsible for locking around rcuwait_wait_event(),
| and [prepare_to/finish]_rcuwait() such that writes to @task are
| properly serialized.

> Because deferred_work_barrier() is called without any global
> serialization (for instance, in kmem_cache_destroy() and
> kvfree_rcu_barrier_on_cache(), and now in flush_all_rcu_sheaves()),

Yes, without slab_mutex held.

> multiple threads can enter irq_work_sync() for the same work object
> concurrently.
> 
> This overwrites the waiter task pointer, meaning only one task will be
> woken up when the work completes, leaving the other tasks hanging
> permanently in an uninterruptible sleep.

I think this is indeed a pre-existing issue that needs to be resolved.
Looks like we now have one more bug to fix ;-)

-- 
Cheers,
Harry / Hyeonggon

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2026-06-16  4:57 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 11:05 Harry Yoo (Oracle)
2026-06-15 11:05 ` [PATCH for-next v3 1/9] slub_kunit: fall back to SW perf events when HW PMU is not available Harry Yoo (Oracle)
2026-06-15 11:14   ` sashiko-bot
2026-06-15 12:58   ` Harry Yoo
2026-06-15 20:01   ` Alexei Starovoitov
2026-06-16  5:23     ` Harry Yoo
2026-06-15 11:05 ` [PATCH for-next v3 2/9] mm/slab, slub_kunit: register kprobe to trigger _nolock APIs Harry Yoo (Oracle)
2026-06-15 11:25   ` sashiko-bot
2026-06-15 20:04   ` Alexei Starovoitov
2026-06-16  6:57   ` Vlastimil Babka (SUSE)
2026-06-24 13:41   ` Pedro Falcato
2026-06-29  7:34     ` Harry Yoo
2026-06-29  8:20       ` Harry Yoo
2026-06-15 11:05 ` [PATCH for-next v3 3/9] mm/slab: handle the !allow_spin case in kfree_rcu_sheaf() Harry Yoo (Oracle)
2026-06-15 11:24   ` sashiko-bot
2026-06-16  7:55   ` Vlastimil Babka (SUSE)
2026-06-16  9:20     ` Vlastimil Babka (SUSE)
2026-06-17  5:32     ` Harry Yoo
2026-06-17  5:58       ` Vlastimil Babka (SUSE)
2026-06-24 14:28   ` Pedro Falcato
2026-06-29  8:01     ` Harry Yoo
2026-06-15 11:05 ` [PATCH for-next v3 4/9] mm/slab: use call_rcu() in unknown context if irqs are enabled Harry Yoo (Oracle)
2026-06-15 11:25   ` sashiko-bot
2026-06-16  9:51   ` Vlastimil Babka (SUSE)
2026-06-24 14:30   ` Pedro Falcato
2026-06-29  8:19     ` Harry Yoo
2026-06-15 11:05 ` [PATCH for-next v3 5/9] mm/slab: extend deferred free mechanism to handle rcu sheaves Harry Yoo (Oracle)
2026-06-15 11:24   ` sashiko-bot
2026-06-16 13:03   ` Vlastimil Babka (SUSE)
2026-06-24 14:37   ` Pedro Falcato
2026-06-15 11:06 ` [PATCH for-next v3 6/9] mm/slab: allow kfree_rcu_sheaf() on PREEMPT_RT Harry Yoo (Oracle)
2026-06-15 11:19   ` sashiko-bot
2026-06-16 17:24   ` Vlastimil Babka (SUSE)
2026-06-17  5:14     ` Harry Yoo
2026-06-17  5:38       ` Vlastimil Babka (SUSE)
2026-06-17 20:40         ` Paul E. McKenney
2026-06-18 12:46           ` Harry Yoo
2026-06-18 16:26             ` Paul E. McKenney
2026-06-15 11:06 ` [PATCH for-next v3 7/9] mm/slab: introduce kfree_rcu_nolock() Harry Yoo (Oracle)
2026-06-15 11:22   ` sashiko-bot
2026-06-16 17:28   ` Vlastimil Babka (SUSE)
2026-06-21  0:29   ` XIAO WU
2026-06-22  5:28     ` Harry Yoo
2026-06-22 14:56       ` XIAO WU
2026-06-25  5:27         ` Harry Yoo
2026-06-15 11:06 ` [PATCH for-next v3 8/9] mm/slab: introduce struct kfree_rcu_head and use in kfree_rcu_nolock() Harry Yoo (Oracle)
2026-06-15 11:22   ` sashiko-bot
2026-06-16 17:36   ` Vlastimil Babka (SUSE)
2026-06-15 11:06 ` [PATCH for-next v3 9/9] slub_kunit: extend the test for kfree_rcu_nolock() Harry Yoo (Oracle)
2026-06-16 17:38   ` Vlastimil Babka (SUSE)
2026-06-15 11:43 ` [PATCH for-next v3 0/9] mm/slab: introduce kfree_rcu_nolock() and improve slub_kunit coverage Harry Yoo
2026-06-15 20:28 ` Alexei Starovoitov
2026-06-16  4:57   ` Harry Yoo [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=1f95030c-0671-40ce-88fd-69a1127237d0@kernel.org \
    --to=harry@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexei.starovoitov@gmail.com \
    --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=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

Powered by JetHome