Linux kernel source tree
Go to file
Zhiguo Niu a6f88ac32c lockdep: fix deadlock issue between lockdep and rcu
There is a deadlock scenario between lockdep and rcu when
rcu nocb feature is enabled, just as following call stack:

     rcuop/x
-000|queued_spin_lock_slowpath(lock = 0xFFFFFF817F2A8A80, val = ?)
-001|queued_spin_lock(inline) // try to hold nocb_gp_lock
-001|do_raw_spin_lock(lock = 0xFFFFFF817F2A8A80)
-002|__raw_spin_lock_irqsave(inline)
-002|_raw_spin_lock_irqsave(lock = 0xFFFFFF817F2A8A80)
-003|wake_nocb_gp_defer(inline)
-003|__call_rcu_nocb_wake(rdp = 0xFFFFFF817F30B680)
-004|__call_rcu_common(inline)
-004|call_rcu(head = 0xFFFFFFC082EECC28, func = ?)
-005|call_rcu_zapped(inline)
-005|free_zapped_rcu(ch = ?)// hold graph lock
-006|rcu_do_batch(rdp = 0xFFFFFF817F245680)
-007|nocb_cb_wait(inline)
-007|rcu_nocb_cb_kthread(arg = 0xFFFFFF817F245680)
-008|kthread(_create = 0xFFFFFF80803122C0)
-009|ret_from_fork(asm)

     rcuop/y
-000|queued_spin_lock_slowpath(lock = 0xFFFFFFC08291BBC8, val = 0)
-001|queued_spin_lock()
-001|lockdep_lock()
-001|graph_lock() // try to hold graph lock
-002|lookup_chain_cache_add()
-002|validate_chain()
-003|lock_acquire
-004|_raw_spin_lock_irqsave(lock = 0xFFFFFF817F211D80)
-005|lock_timer_base(inline)
-006|mod_timer(inline)
-006|wake_nocb_gp_defer(inline)// hold nocb_gp_lock
-006|__call_rcu_nocb_wake(rdp = 0xFFFFFF817F2A8680)
-007|__call_rcu_common(inline)
-007|call_rcu(head = 0xFFFFFFC0822E0B58, func = ?)
-008|call_rcu_hurry(inline)
-008|rcu_sync_call(inline)
-008|rcu_sync_func(rhp = 0xFFFFFFC0822E0B58)
-009|rcu_do_batch(rdp = 0xFFFFFF817F266680)
-010|nocb_cb_wait(inline)
-010|rcu_nocb_cb_kthread(arg = 0xFFFFFF817F266680)
-011|kthread(_create = 0xFFFFFF8080363740)
-012|ret_from_fork(asm)

rcuop/x and rcuop/y are rcu nocb threads with the same nocb gp thread.
This patch release the graph lock before lockdep call_rcu.

Fixes: a0b0fd53e1 ("locking/lockdep: Free lock classes that are no longer in use")
Cc: stable@vger.kernel.org
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Waiman Long <longman@redhat.com>
Cc: Carlos Llamas <cmllamas@google.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
Reviewed-by: Waiman Long <longman@redhat.com>
Reviewed-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Acked-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20240620225436.3127927-1-cmllamas@google.com
2024-08-06 10:46:42 -07:00
arch locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void 2024-07-17 16:28:19 +02:00
block for-6.11/block-20240710 2024-07-15 14:20:22 -07:00
certs
crypto
Documentation cleanup: Add usage and style documentation 2024-08-05 16:54:41 +02:00
drivers Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
fs Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
include cleanup: Add usage and style documentation 2024-08-05 16:54:41 +02:00
init
io_uring Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
ipc ipc: mqueue: remove assignment from IS_ERR argument 2024-07-09 06:47:40 +02:00
kernel lockdep: fix deadlock issue between lockdep and rcu 2024-08-06 10:46:42 -07:00
lib Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
LICENSES
mm linux_kselftest-kunit-6.11-rc1 2024-07-16 17:42:14 -07:00
net Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
rust for-6.11/block-20240710 2024-07-15 14:20:22 -07:00
samples
scripts Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
security Performance events changes for v6.11: 2024-07-16 17:13:31 -07:00
sound Updates for timers, timekeeping and related functionality: 2024-07-15 15:03:09 -07:00
tools Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
usr
virt
.clang-format
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap soc: dt updates for 6.11 2024-07-16 11:43:51 -07:00
.rustfmt.toml
COPYING
CREDITS Scheduler changes for v6.11: 2024-07-16 17:00:50 -07:00
Kbuild
Kconfig
MAINTAINERS Networking changes for 6.11. Not much excitement - a handful of large 2024-07-16 19:28:34 -07:00
Makefile asm-generic updates for 6.11 2024-07-16 12:09:03 -07:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.