Skip to content

Commit 7aeba70

Browse files
Frederic WeisbeckerNeeraj Upadhyay
authored andcommitted
rcu/nocb: Introduce RCU_NOCB_LOCKDEP_WARN()
Checking for races against concurrent (de-)offloading implies the creation of !CONFIG_RCU_NOCB_CPU stubs to check if each relevant lock is held. For now this only implies the nocb_lock but more are to be expected. Create instead a NOCB specific version of RCU_LOCKDEP_WARN() to avoid the proliferation of stubs. Signed-off-by: Frederic Weisbecker <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Reviewed-by: Paul E. McKenney <[email protected]> Signed-off-by: Neeraj Upadhyay <[email protected]>
1 parent 8400291 commit 7aeba70

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

include/linux/rcupdate.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,18 @@ void rcu_init_nohz(void);
144144
int rcu_nocb_cpu_offload(int cpu);
145145
int rcu_nocb_cpu_deoffload(int cpu);
146146
void rcu_nocb_flush_deferred_wakeup(void);
147+
148+
#define RCU_NOCB_LOCKDEP_WARN(c, s) RCU_LOCKDEP_WARN(c, s)
149+
147150
#else /* #ifdef CONFIG_RCU_NOCB_CPU */
151+
148152
static inline void rcu_init_nohz(void) { }
149153
static inline int rcu_nocb_cpu_offload(int cpu) { return -EINVAL; }
150154
static inline int rcu_nocb_cpu_deoffload(int cpu) { return 0; }
151155
static inline void rcu_nocb_flush_deferred_wakeup(void) { }
156+
157+
#define RCU_NOCB_LOCKDEP_WARN(c, s)
158+
152159
#endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */
153160

154161
/*

kernel/rcu/tree_nocb.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#ifdef CONFIG_RCU_NOCB_CPU
1717
static cpumask_var_t rcu_nocb_mask; /* CPUs to have callbacks offloaded. */
1818
static bool __read_mostly rcu_nocb_poll; /* Offload kthread are to poll. */
19-
static inline int rcu_lockdep_is_held_nocb(struct rcu_data *rdp)
20-
{
21-
return lockdep_is_held(&rdp->nocb_lock);
22-
}
2319

2420
static inline bool rcu_current_is_nocb_kthread(struct rcu_data *rdp)
2521
{
@@ -1653,16 +1649,6 @@ static void show_rcu_nocb_state(struct rcu_data *rdp)
16531649

16541650
#else /* #ifdef CONFIG_RCU_NOCB_CPU */
16551651

1656-
static inline int rcu_lockdep_is_held_nocb(struct rcu_data *rdp)
1657-
{
1658-
return 0;
1659-
}
1660-
1661-
static inline bool rcu_current_is_nocb_kthread(struct rcu_data *rdp)
1662-
{
1663-
return false;
1664-
}
1665-
16661652
/* No ->nocb_lock to acquire. */
16671653
static void rcu_nocb_lock(struct rcu_data *rdp)
16681654
{

kernel/rcu/tree_plugin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ static bool rcu_rdp_is_offloaded(struct rcu_data *rdp)
2424
* timers have their own means of synchronization against the
2525
* offloaded state updaters.
2626
*/
27-
RCU_LOCKDEP_WARN(
27+
RCU_NOCB_LOCKDEP_WARN(
2828
!(lockdep_is_held(&rcu_state.barrier_mutex) ||
2929
(IS_ENABLED(CONFIG_HOTPLUG_CPU) && lockdep_is_cpus_held()) ||
30-
rcu_lockdep_is_held_nocb(rdp) ||
30+
lockdep_is_held(&rdp->nocb_lock) ||
3131
(!(IS_ENABLED(CONFIG_PREEMPT_COUNT) && preemptible()) &&
3232
rdp == this_cpu_ptr(&rcu_data)) ||
3333
rcu_current_is_nocb_kthread(rdp)),

0 commit comments

Comments
 (0)