Skip to content

Commit

Permalink
rcu: Make SRCU mandatory
Browse files Browse the repository at this point in the history
Kernels configured with CONFIG_PRINTK=n and CONFIG_SRCU=n get build
failures.  This causes trouble for deep embedded systems.  But given
that there are more than 25 instances of "select SRCU" in the kernel,
it is hard to believe that there are many kernels running in production
without SRCU.  This commit therefore makes SRCU mandatory.  The SRCU
Kconfig option remains for backwards compatibility, and will be removed
when it is no longer used.

Reported-by: John Ogness <john.ogness@linutronix.de>
Reported-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: <linux-arch@vger.kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Reviewed-by: John Ogness <john.ogness@linutronix.de>
  • Loading branch information
paulmckrcu committed Nov 23, 2022
1 parent 485cb93 commit 4e3f7d2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 33 deletions.
4 changes: 0 additions & 4 deletions include/linux/rcutiny.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ static inline bool rcu_preempt_need_deferred_qs(struct task_struct *t)
return false;
}
static inline void rcu_preempt_deferred_qs(struct task_struct *t) { }
#ifdef CONFIG_SRCU
void rcu_scheduler_starting(void);
#else /* #ifndef CONFIG_SRCU */
static inline void rcu_scheduler_starting(void) { }
#endif /* #else #ifndef CONFIG_SRCU */
static inline void rcu_end_inkernel_boot(void) { }
static inline bool rcu_inkernel_boot_has_ended(void) { return true; }
static inline bool rcu_is_watching(void) { return true; }
Expand Down
4 changes: 0 additions & 4 deletions include/linux/srcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ static inline void __srcu_read_unlock_nmisafe(struct srcu_struct *ssp, int idx)
}
#endif /* CONFIG_NEED_SRCU_NMI_SAFE */

#ifdef CONFIG_SRCU
void srcu_init(void);
#else /* #ifdef CONFIG_SRCU */
static inline void srcu_init(void) { }
#endif /* #else #ifdef CONFIG_SRCU */

#ifdef CONFIG_DEBUG_LOCK_ALLOC

Expand Down
11 changes: 3 additions & 8 deletions kernel/rcu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,17 @@ config RCU_EXPERT
Say N if you are unsure.

config SRCU
bool
help
This option selects the sleepable version of RCU. This version
permits arbitrary sleeping or blocking within RCU read-side critical
sections.
def_bool y

config TINY_SRCU
bool
default y if SRCU && TINY_RCU
default y if TINY_RCU
help
This option selects the single-CPU non-preemptible version of SRCU.

config TREE_SRCU
bool
default y if SRCU && !TINY_RCU
default y if !TINY_RCU
help
This option selects the full-fledged version of SRCU.

Expand All @@ -77,7 +73,6 @@ config NEED_SRCU_NMI_SAFE

config TASKS_RCU_GENERIC
def_bool TASKS_RCU || TASKS_RUDE_RCU || TASKS_TRACE_RCU
select SRCU
help
This option enables generic infrastructure code supporting
task-based RCU implementations. Not for manual selection.
Expand Down
3 changes: 0 additions & 3 deletions kernel/rcu/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ config RCU_SCALE_TEST
tristate "performance tests for RCU"
depends on DEBUG_KERNEL
select TORTURE_TEST
select SRCU
default n
help
This option provides a kernel module that runs performance
Expand All @@ -43,7 +42,6 @@ config RCU_TORTURE_TEST
tristate "torture tests for RCU"
depends on DEBUG_KERNEL
select TORTURE_TEST
select SRCU
default n
help
This option provides a kernel module that runs torture tests
Expand All @@ -59,7 +57,6 @@ config RCU_REF_SCALE_TEST
tristate "Scalability tests for read-side synchronization (RCU and others)"
depends on DEBUG_KERNEL
select TORTURE_TEST
select SRCU
default n
help
This option provides a kernel module that runs performance tests
Expand Down
4 changes: 2 additions & 2 deletions kernel/rcu/rcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void rcu_test_sync_prims(void);
*/
extern void resched_cpu(int cpu);

#if defined(CONFIG_SRCU) || !defined(CONFIG_TINY_RCU)
#if !defined(CONFIG_TINY_RCU)

#include <linux/rcu_node_tree.h>

Expand Down Expand Up @@ -438,7 +438,7 @@ do { \
#define raw_lockdep_assert_held_rcu_node(p) \
lockdep_assert_held(&ACCESS_PRIVATE(p, lock))

#endif /* #if defined(CONFIG_SRCU) || !defined(CONFIG_TINY_RCU) */
#endif /* !defined(CONFIG_TINY_RCU) */

#ifdef CONFIG_TINY_RCU
/* Tiny RCU doesn't expedite, as its purpose in life is instead to be tiny. */
Expand Down
20 changes: 8 additions & 12 deletions kernel/rcu/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void rcu_test_sync_prims(void)
synchronize_rcu_expedited();
}

#if !defined(CONFIG_TINY_RCU) || defined(CONFIG_SRCU)
#if !defined(CONFIG_TINY_RCU)

/*
* Switch to run-time mode once RCU has fully initialized.
Expand All @@ -239,7 +239,7 @@ static int __init rcu_set_runtime_mode(void)
}
core_initcall(rcu_set_runtime_mode);

#endif /* #if !defined(CONFIG_TINY_RCU) || defined(CONFIG_SRCU) */
#endif /* #if !defined(CONFIG_TINY_RCU) */

#ifdef CONFIG_DEBUG_LOCK_ALLOC
static struct lock_class_key rcu_lock_key;
Expand Down Expand Up @@ -561,10 +561,8 @@ static void early_boot_test_call_rcu(void)
struct early_boot_kfree_rcu *rhp;

call_rcu(&head, test_callback);
if (IS_ENABLED(CONFIG_SRCU)) {
early_srcu_cookie = start_poll_synchronize_srcu(&early_srcu);
call_srcu(&early_srcu, &shead, test_callback);
}
early_srcu_cookie = start_poll_synchronize_srcu(&early_srcu);
call_srcu(&early_srcu, &shead, test_callback);
rhp = kmalloc(sizeof(*rhp), GFP_KERNEL);
if (!WARN_ON_ONCE(!rhp))
kfree_rcu(rhp, rh);
Expand All @@ -587,12 +585,10 @@ static int rcu_verify_early_boot_tests(void)
if (rcu_self_test) {
early_boot_test_counter++;
rcu_barrier();
if (IS_ENABLED(CONFIG_SRCU)) {
early_boot_test_counter++;
srcu_barrier(&early_srcu);
WARN_ON_ONCE(!poll_state_synchronize_srcu(&early_srcu, early_srcu_cookie));
cleanup_srcu_struct(&early_srcu);
}
early_boot_test_counter++;
srcu_barrier(&early_srcu);
WARN_ON_ONCE(!poll_state_synchronize_srcu(&early_srcu, early_srcu_cookie));
cleanup_srcu_struct(&early_srcu);
}
if (rcu_self_test_counter != early_boot_test_counter) {
WARN_ON(1);
Expand Down

0 comments on commit 4e3f7d2

Please sign in to comment.