History

rcu: Refactor rcu_barrier() empty-list handling

This commit saves a few lines by checking first for an empty callback list. If the callback list is empty, then that CPU is taken care of, regardless of its online or nocb state. Also simplify tracing accordingly and fold a few lines together.

Paul E. McKenney committed 4 years ago

Commit 0cabb471 parent 82980b12 files · +12 −22Browse files

Unified · Split

2 files
  1. include/trace/events/rcu.h +4 −5
  2. kernel/rcu/tree.c +8 −17
include/trace/events/rcu.h+4−5
@@ -794,16 +794,15 @@ TRACE_EVENT_RCU(rcu_torture_read, · 793 unmodified lines
794794 * Tracepoint for rcu_barrier() execution. The string "s" describes
795795 * the rcu_barrier phase:
796796 * "Begin": rcu_barrier() started.
797+ * "CB": An rcu_barrier_callback() invoked a callback, not the last.
797798 * "EarlyExit": rcu_barrier() piggybacked, thus early exit.
798799 * "Inc1": rcu_barrier() piggyback check counter incremented.
799− * "OfflineNoCBQ": rcu_barrier() found offline no-CBs CPU with callbacks.
800− * "OnlineQ": rcu_barrier() found online CPU with callbacks.
801− * "OnlineNQ": rcu_barrier() found online CPU, no callbacks.
800+ * "Inc2": rcu_barrier() piggyback check counter incremented.
802801 * "IRQ": An rcu_barrier_callback() callback posted on remote CPU.
803802 * "IRQNQ": An rcu_barrier_callback() callback found no callbacks.
804− * "CB": An rcu_barrier_callback() invoked a callback, not the last.
805803 * "LastCB": An rcu_barrier_callback() invoked the last callback.
806− * "Inc2": rcu_barrier() piggyback check counter incremented.
804+ * "NQ": rcu_barrier() found a CPU with no callbacks.
805+ * "OnlineQ": rcu_barrier() found online CPU with callbacks.
807806 * The "cpu" argument is the CPU or -1 if meaningless, the "cnt" argument
808807 * is the count of remaining callbacks, and "done" is the piggybacking count.
809808 */
kernel/rcu/tree.c+8−17
@@ -4030,8 +4030,7 @@ void rcu_barrier(void) · 4029 unmodified lines
40304030
40314031 /* Did someone else do our work for us? */
40324032 if (rcu_seq_done(&rcu_state.barrier_sequence, s)) {
4033− rcu_barrier_trace(TPS("EarlyExit"), -1,
4034− rcu_state.barrier_sequence);
4033+ rcu_barrier_trace(TPS("EarlyExit"), -1, rcu_state.barrier_sequence);
40354034 smp_mb(); /* caller's subsequent code after above check. */
40364035 mutex_unlock(&rcu_state.barrier_mutex);
40374036 return;
@@ -4059,26 +4058,18 @@ void rcu_barrier(void) · 21 unmodified lines
40594058 */
40604059 for_each_possible_cpu(cpu) {
40614060 rdp = per_cpu_ptr(&rcu_data, cpu);
4062− if (cpu_is_offline(cpu) &&
4063− !rcu_rdp_is_offloaded(rdp))
4061+ if (!rcu_segcblist_n_cbs(&rdp->cblist)) {
4062+ rcu_barrier_trace(TPS("NQ"), cpu, rcu_state.barrier_sequence);
40644063 continue;
4065− if (rcu_segcblist_n_cbs(&rdp->cblist) && cpu_online(cpu)) {
4066− rcu_barrier_trace(TPS("OnlineQ"), cpu,
4067− rcu_state.barrier_sequence);
4064+ }
4065+ if (cpu_online(cpu)) {
4066+ rcu_barrier_trace(TPS("OnlineQ"), cpu, rcu_state.barrier_sequence);
40684067 smp_call_function_single(cpu, rcu_barrier_func, (void *)cpu, 1);
4069− } else if (rcu_segcblist_n_cbs(&rdp->cblist) &&
4070− cpu_is_offline(cpu)) {
4071− rcu_barrier_trace(TPS("OfflineNoCBQ"), cpu,
4072− rcu_state.barrier_sequence);
4068+ } else {
4069+ rcu_barrier_trace(TPS("OfflineNoCBQ"), cpu, rcu_state.barrier_sequence);
40734070 local_irq_disable();
40744071 rcu_barrier_func((void *)cpu);
40754072 local_irq_enable();
4076− } else if (cpu_is_offline(cpu)) {
4077− rcu_barrier_trace(TPS("OfflineNoCBNoQ"), cpu,
4078− rcu_state.barrier_sequence);
4079− } else {
4080− rcu_barrier_trace(TPS("OnlineNQ"), cpu,
4081− rcu_state.barrier_sequence);
40824073 }
40834074 }
40844075 cpus_read_unlock();