Skip to content

Commit f759081

Browse files
committed
rcu/nocb: Code-style nits in callback-offloading toggling
This commit addresses a few code-style nits in callback-offloading toggling, including one that predates this toggling. Cc: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 3d0cef5 commit f759081

4 files changed

Lines changed: 30 additions & 37 deletions

File tree

‎kernel/rcu/rcu_segcblist.h‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,12 @@ static inline bool rcu_segcblist_is_enabled(struct rcu_segcblist *rsclp)
8080
return rcu_segcblist_test_flags(rsclp, SEGCBLIST_ENABLED);
8181
}
8282

83-
/* Is the specified rcu_segcblist offloaded? */
83+
/* Is the specified rcu_segcblist offloaded, or is SEGCBLIST_SOFTIRQ_ONLY set? */
8484
static inline bool rcu_segcblist_is_offloaded(struct rcu_segcblist *rsclp)
8585
{
86-
if (IS_ENABLED(CONFIG_RCU_NOCB_CPU)) {
87-
/*
88-
* Complete de-offloading happens only when SEGCBLIST_SOFTIRQ_ONLY
89-
* is set.
90-
*/
91-
if (!rcu_segcblist_test_flags(rsclp, SEGCBLIST_SOFTIRQ_ONLY))
92-
return true;
93-
}
86+
if (IS_ENABLED(CONFIG_RCU_NOCB_CPU) &&
87+
!rcu_segcblist_test_flags(rsclp, SEGCBLIST_SOFTIRQ_ONLY))
88+
return true;
9489

9590
return false;
9691
}
@@ -99,10 +94,8 @@ static inline bool rcu_segcblist_completely_offloaded(struct rcu_segcblist *rscl
9994
{
10095
int flags = SEGCBLIST_KTHREAD_CB | SEGCBLIST_KTHREAD_GP | SEGCBLIST_OFFLOADED;
10196

102-
if (IS_ENABLED(CONFIG_RCU_NOCB_CPU)) {
103-
if ((rsclp->flags & flags) == flags)
104-
return true;
105-
}
97+
if (IS_ENABLED(CONFIG_RCU_NOCB_CPU) && (rsclp->flags & flags) == flags)
98+
return true;
10699

107100
return false;
108101
}

‎kernel/rcu/rcutorture.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ rcu_torture_stats_print(void)
16061606
data_race(n_barrier_successes),
16071607
data_race(n_barrier_attempts),
16081608
data_race(n_rcu_torture_barrier_error));
1609-
pr_cont("read-exits: %ld ", data_race(n_read_exits));
1609+
pr_cont("read-exits: %ld ", data_race(n_read_exits)); // Statistic.
16101610
pr_cont("nocb-toggles: %ld:%ld\n",
16111611
atomic_long_read(&n_nocb_offload), atomic_long_read(&n_nocb_deoffload));
16121612

‎kernel/rcu/tree_plugin.h‎

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,17 +1962,17 @@ static inline bool nocb_gp_update_state(struct rcu_data *rdp, bool *needwake_sta
19621962
*needwake_state = true;
19631963
}
19641964
return true;
1965-
} else {
1966-
/*
1967-
* De-offloading. Clear our flag and notify the de-offload worker.
1968-
* We will ignore this rdp until it ever gets re-offloaded.
1969-
*/
1970-
WARN_ON_ONCE(!rcu_segcblist_test_flags(cblist, SEGCBLIST_KTHREAD_GP));
1971-
rcu_segcblist_clear_flags(cblist, SEGCBLIST_KTHREAD_GP);
1972-
if (!rcu_segcblist_test_flags(cblist, SEGCBLIST_KTHREAD_CB))
1973-
*needwake_state = true;
1974-
return false;
19751965
}
1966+
1967+
/*
1968+
* De-offloading. Clear our flag and notify the de-offload worker.
1969+
* We will ignore this rdp until it ever gets re-offloaded.
1970+
*/
1971+
WARN_ON_ONCE(!rcu_segcblist_test_flags(cblist, SEGCBLIST_KTHREAD_GP));
1972+
rcu_segcblist_clear_flags(cblist, SEGCBLIST_KTHREAD_GP);
1973+
if (!rcu_segcblist_test_flags(cblist, SEGCBLIST_KTHREAD_CB))
1974+
*needwake_state = true;
1975+
return false;
19761976
}
19771977

19781978

@@ -2005,6 +2005,7 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
20052005
WARN_ON_ONCE(my_rdp->nocb_gp_rdp != my_rdp);
20062006
for (rdp = my_rdp; rdp; rdp = rdp->nocb_next_cb_rdp) {
20072007
bool needwake_state = false;
2008+
20082009
if (!nocb_gp_enabled_cb(rdp))
20092010
continue;
20102011
trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("Check"));
@@ -2160,11 +2161,11 @@ static inline bool nocb_cb_wait_cond(struct rcu_data *rdp)
21602161
static void nocb_cb_wait(struct rcu_data *rdp)
21612162
{
21622163
struct rcu_segcblist *cblist = &rdp->cblist;
2163-
struct rcu_node *rnp = rdp->mynode;
2164-
bool needwake_state = false;
2165-
bool needwake_gp = false;
21662164
unsigned long cur_gp_seq;
21672165
unsigned long flags;
2166+
bool needwake_state = false;
2167+
bool needwake_gp = false;
2168+
struct rcu_node *rnp = rdp->mynode;
21682169

21692170
local_irq_save(flags);
21702171
rcu_momentary_dyntick_idle();
@@ -2217,8 +2218,8 @@ static void nocb_cb_wait(struct rcu_data *rdp)
22172218
swait_event_interruptible_exclusive(rdp->nocb_cb_wq,
22182219
nocb_cb_wait_cond(rdp));
22192220

2220-
/* ^^^ Ensure CB invocation follows _sleep test. */
2221-
if (smp_load_acquire(&rdp->nocb_cb_sleep)) {
2221+
// VVV Ensure CB invocation follows _sleep test.
2222+
if (smp_load_acquire(&rdp->nocb_cb_sleep)) { // ^^^
22222223
WARN_ON(signal_pending(current));
22232224
trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("WokeEmpty"));
22242225
}
@@ -2323,7 +2324,7 @@ static int __rcu_nocb_rdp_deoffload(struct rcu_data *rdp)
23232324
unsigned long flags;
23242325
int ret;
23252326

2326-
printk("De-offloading %d\n", rdp->cpu);
2327+
pr_info("De-offloading %d\n", rdp->cpu);
23272328

23282329
rcu_nocb_lock_irqsave(rdp, flags);
23292330
/*
@@ -2384,11 +2385,10 @@ int rcu_nocb_cpu_deoffload(int cpu)
23842385
mutex_lock(&rcu_state.barrier_mutex);
23852386
cpus_read_lock();
23862387
if (rcu_segcblist_is_offloaded(&rdp->cblist)) {
2387-
if (cpu_online(cpu)) {
2388+
if (cpu_online(cpu))
23882389
ret = work_on_cpu(cpu, rcu_nocb_rdp_deoffload, rdp);
2389-
} else {
2390+
else
23902391
ret = __rcu_nocb_rdp_deoffload(rdp);
2391-
}
23922392
if (!ret)
23932393
cpumask_clear_cpu(cpu, rcu_nocb_mask);
23942394
}
@@ -2412,7 +2412,7 @@ static int __rcu_nocb_rdp_offload(struct rcu_data *rdp)
24122412
if (!rdp->nocb_gp_rdp)
24132413
return -EINVAL;
24142414

2415-
printk("Offloading %d\n", rdp->cpu);
2415+
pr_info("Offloading %d\n", rdp->cpu);
24162416
/*
24172417
* Can't use rcu_nocb_lock_irqsave() while we are in
24182418
* SEGCBLIST_SOFTIRQ_ONLY mode.
@@ -2460,11 +2460,10 @@ int rcu_nocb_cpu_offload(int cpu)
24602460
mutex_lock(&rcu_state.barrier_mutex);
24612461
cpus_read_lock();
24622462
if (!rcu_segcblist_is_offloaded(&rdp->cblist)) {
2463-
if (cpu_online(cpu)) {
2463+
if (cpu_online(cpu))
24642464
ret = work_on_cpu(cpu, rcu_nocb_rdp_offload, rdp);
2465-
} else {
2465+
else
24662466
ret = __rcu_nocb_rdp_offload(rdp);
2467-
}
24682467
if (!ret)
24692468
cpumask_set_cpu(cpu, rcu_nocb_mask);
24702469
}

‎kernel/time/timer.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ bool timer_curr_running(struct timer_list *timer)
12431243

12441244
for (i = 0; i < NR_BASES; i++) {
12451245
struct timer_base *base = this_cpu_ptr(&timer_bases[i]);
1246+
12461247
if (base->running_timer == timer)
12471248
return true;
12481249
}

0 commit comments

Comments
 (0)