]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
srcu: Use irq_work to start GP in tiny SRCU
authorJoel Fernandes <joelagnelf@nvidia.com>
Tue, 24 Mar 2026 00:14:18 +0000 (20:14 -0400)
committerBoqun Feng <boqun@kernel.org>
Wed, 25 Mar 2026 16:00:05 +0000 (09:00 -0700)
commita6fc88b22bc8d12ad52e8412c667ec0f5bf055af
tree6396eaf57af049fd4c5c2b03e44fb90c95f8179d
parent7c405fb3279b39244b260b54f1bd6488689ae235
srcu: Use irq_work to start GP in tiny SRCU

Tiny SRCU's srcu_gp_start_if_needed() directly calls schedule_work(),
which acquires the workqueue pool->lock.

This causes a lockdep splat when call_srcu() is called with a scheduler
lock held, due to:

  call_srcu() [holding pi_lock]
    srcu_gp_start_if_needed()
      schedule_work() -> pool->lock

  workqueue_init() / create_worker() [holding pool->lock]
    wake_up_process() -> try_to_wake_up() -> pi_lock

Also add irq_work_sync() to cleanup_srcu_struct() to prevent a
use-after-free if a queued irq_work fires after cleanup begins.

Tested with rcutorture SRCU-T and no lockdep warnings.

[ Thanks to Boqun for similar fix in patch "rcu: Use an intermediate irq_work
to start process_srcu()" ]

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun@kernel.org>
include/linux/srcutiny.h
kernel/rcu/srcutiny.c