Skip to content

Commit da2ac56

Browse files
paulmckrcufbq
authored andcommitted
srcu: Make Tiny SRCU able to operate in preemptible kernels
Given that SRCU allows its read-side critical sections are not just preemptible, but also allow general blocking, there is not much reason to restrict Tiny SRCU to non-preemptible kernels. This commit therefore removes Tiny SRCU dependencies on non-preemptibility, primarily surrounding its interaction with rcutorture and early boot. Signed-off-by: Paul E. McKenney <[email protected]> Cc: Ankur Arora <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: <[email protected]> Signed-off-by: Boqun Feng <[email protected]>
1 parent 2014c95 commit da2ac56

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

kernel/rcu/rcu.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,6 @@ void srcutorture_get_gp_data(struct srcu_struct *sp, int *flags,
611611
static inline bool rcu_watching_zero_in_eqs(int cpu, int *vp) { return false; }
612612
static inline unsigned long rcu_get_gp_seq(void) { return 0; }
613613
static inline unsigned long rcu_exp_batches_completed(void) { return 0; }
614-
static inline unsigned long
615-
srcu_batches_completed(struct srcu_struct *sp) { return 0; }
616614
static inline void rcu_force_quiescent_state(void) { }
617615
static inline bool rcu_check_boost_fail(unsigned long gp_state, int *cpup) { return true; }
618616
static inline void show_rcu_gp_kthreads(void) { }
@@ -624,7 +622,6 @@ static inline void rcu_gp_slow_unregister(atomic_t *rgssp) { }
624622
bool rcu_watching_zero_in_eqs(int cpu, int *vp);
625623
unsigned long rcu_get_gp_seq(void);
626624
unsigned long rcu_exp_batches_completed(void);
627-
unsigned long srcu_batches_completed(struct srcu_struct *sp);
628625
bool rcu_check_boost_fail(unsigned long gp_state, int *cpup);
629626
void show_rcu_gp_kthreads(void);
630627
int rcu_get_gp_kthreads_prio(void);
@@ -636,6 +633,12 @@ void rcu_gp_slow_register(atomic_t *rgssp);
636633
void rcu_gp_slow_unregister(atomic_t *rgssp);
637634
#endif /* #else #ifdef CONFIG_TINY_RCU */
638635

636+
#ifdef CONFIG_TINY_SRCU
637+
static inline unsigned long srcu_batches_completed(struct srcu_struct *sp) { return 0; }
638+
#else // #ifdef CONFIG_TINY_SRCU
639+
unsigned long srcu_batches_completed(struct srcu_struct *sp);
640+
#endif // #else // #ifdef CONFIG_TINY_SRCU
641+
639642
#ifdef CONFIG_RCU_NOCB_CPU
640643
void rcu_bind_current_to_nocb(void);
641644
#else

kernel/rcu/srcutiny.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
#include "rcu_segcblist.h"
2121
#include "rcu.h"
2222

23+
#ifndef CONFIG_TREE_RCU
2324
int rcu_scheduler_active __read_mostly;
25+
#else // #ifndef CONFIG_TREE_RCU
26+
extern int rcu_scheduler_active;
27+
#endif // #else // #ifndef CONFIG_TREE_RCU
2428
static LIST_HEAD(srcu_boot_list);
2529
static bool srcu_init_done;
2630

@@ -282,11 +286,13 @@ bool poll_state_synchronize_srcu(struct srcu_struct *ssp, unsigned long cookie)
282286
}
283287
EXPORT_SYMBOL_GPL(poll_state_synchronize_srcu);
284288

289+
#ifndef CONFIG_TREE_RCU
285290
/* Lockdep diagnostics. */
286291
void __init rcu_scheduler_starting(void)
287292
{
288293
rcu_scheduler_active = RCU_SCHEDULER_RUNNING;
289294
}
295+
#endif // #ifndef CONFIG_TREE_RCU
290296

291297
/*
292298
* Queue work for srcu_struct structures with early boot callbacks.

0 commit comments

Comments
 (0)