mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 02:36:02 +00:00
4e58aaeebb
Although the RCU CPU stall notifiers can be useful for dumping state when tracking down delicate forward-progress bugs where NUMA effects cause cache lines to be delivered to a given CPU regularly, but always in a state that prevents that CPU from making forward progress. These bugs can be detected by the RCU CPU stall-warning mechanism, but in some cases, the stall-warnings printk()s disrupt the forward-progress bug before any useful state can be obtained. Unfortunately, the notifier mechanism added by commit5b404fdaba
("rcu: Add RCU CPU stall notifier") can make matters worse if used at all carelessly. For example, if the stall warning was caused by a lock not being released, then any attempt to acquire that lock in the notifier will hang. This will prevent not only the notifier from producing any useful output, but it will also prevent the stall-warning message from ever appearing. This commit therefore hides this new RCU CPU stall notifier mechanism under a new RCU_CPU_STALL_NOTIFIER Kconfig option that depends on both DEBUG_KERNEL and RCU_EXPERT. In addition, the rcupdate.rcu_cpu_stall_notifiers=1 kernel boot parameter must also be specified. The RCU_CPU_STALL_NOTIFIER Kconfig option's help text contains a warning and explains the dangers of careless use, recommending lockless notifier code. In addition, a WARN() is triggered each time that an attempt is made to register a stall-warning notifier in kernels built with CONFIG_RCU_CPU_STALL_NOTIFIER=y. This combination of measures will keep use of this mechanism confined to debug kernels and away from routine deployments. [ paulmck: Apply Dan Carpenter feedback. ] Fixes:5b404fdaba
("rcu: Add RCU CPU stall notifier") Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.iitr10@gmail.com>
33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* Read-Copy Update notifiers, initially RCU CPU stall notifier.
|
|
* Separate from rcupdate.h to avoid #include loops.
|
|
*
|
|
* Copyright (C) 2023 Paul E. McKenney.
|
|
*/
|
|
|
|
#ifndef __LINUX_RCU_NOTIFIER_H
|
|
#define __LINUX_RCU_NOTIFIER_H
|
|
|
|
// Actions for RCU CPU stall notifier calls.
|
|
#define RCU_STALL_NOTIFY_NORM 1
|
|
#define RCU_STALL_NOTIFY_EXP 2
|
|
|
|
#if defined(CONFIG_RCU_STALL_COMMON) && defined(CONFIG_RCU_CPU_STALL_NOTIFIER)
|
|
|
|
#include <linux/notifier.h>
|
|
#include <linux/types.h>
|
|
|
|
int rcu_stall_chain_notifier_register(struct notifier_block *n);
|
|
int rcu_stall_chain_notifier_unregister(struct notifier_block *n);
|
|
|
|
#else // #if defined(CONFIG_RCU_STALL_COMMON) && defined(CONFIG_RCU_CPU_STALL_NOTIFIER)
|
|
|
|
// No RCU CPU stall warnings in Tiny RCU.
|
|
static inline int rcu_stall_chain_notifier_register(struct notifier_block *n) { return -EEXIST; }
|
|
static inline int rcu_stall_chain_notifier_unregister(struct notifier_block *n) { return -ENOENT; }
|
|
|
|
#endif // #else // #if defined(CONFIG_RCU_STALL_COMMON) && defined(CONFIG_RCU_CPU_STALL_NOTIFIER)
|
|
|
|
#endif /* __LINUX_RCU_NOTIFIER_H */
|