Skip to content

Commit 9ae58d7

Browse files
committed
rcu-tasks: Add Kconfig option to mediate smp_mb() vs. IPI
This commit provides a new TASKS_TRACE_RCU_READ_MB Kconfig option that enables use of read-side memory barriers by both rcu_read_lock_trace() and rcu_read_unlock_trace() when the are executed with the current->trc_reader_special.b.need_mb flag set. This flag is currently never set. Doing that is the subject of a later commit. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 238dbce commit 9ae58d7

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

include/linux/rcupdate_trace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ static inline void rcu_read_lock_trace(void)
5050
struct task_struct *t = current;
5151

5252
WRITE_ONCE(t->trc_reader_nesting, READ_ONCE(t->trc_reader_nesting) + 1);
53-
if (t->trc_reader_special.b.need_mb)
53+
if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB) &&
54+
t->trc_reader_special.b.need_mb)
5455
smp_mb(); // Pairs with update-side barriers
5556
rcu_lock_acquire(&rcu_trace_lock_map);
5657
}

kernel/rcu/Kconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,22 @@ config RCU_NOCB_CPU
234234
Say Y here if you want to help to debug reduced OS jitter.
235235
Say N here if you are unsure.
236236

237+
config TASKS_TRACE_RCU_READ_MB
238+
bool "Tasks Trace RCU readers use memory barriers in user and idle"
239+
depends on RCU_EXPERT
240+
default PREEMPT_RT || NR_CPUS < 8
241+
help
242+
Use this option to further reduce the number of IPIs sent
243+
to CPUs executing in userspace or idle during tasks trace
244+
RCU grace periods. Given that a reasonable setting of
245+
the rcupdate.rcu_task_ipi_delay kernel boot parameter
246+
eliminates such IPIs for many workloads, proper setting
247+
of this Kconfig option is important mostly for aggressive
248+
real-time installations and for battery-powered devices,
249+
hence the default chosen above.
250+
251+
Say Y here if you hate IPIs.
252+
Say N here if you hate read-side memory barriers.
253+
Take the default if you are unsure.
254+
237255
endmenu # "RCU Subsystem"

kernel/rcu/tasks.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,8 @@ void rcu_read_unlock_trace_special(struct task_struct *t, int nesting)
734734
{
735735
int nq = t->trc_reader_special.b.need_qs;
736736

737-
if (t->trc_reader_special.b.need_mb)
737+
if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB) &&
738+
t->trc_reader_special.b.need_mb)
738739
smp_mb(); // Pairs with update-side barriers.
739740
// Update .need_qs before ->trc_reader_nesting for irq/NMI handlers.
740741
if (nq)

0 commit comments

Comments
 (0)