Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <paulmck@kernel.org>

+22 -2
+2 -1
include/linux/rcupdate_trace.h
··· 50 50 struct task_struct *t = current; 51 51 52 52 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) 54 55 smp_mb(); // Pairs with update-side barriers 55 56 rcu_lock_acquire(&rcu_trace_lock_map); 56 57 }
+18
kernel/rcu/Kconfig
··· 234 234 Say Y here if you want to help to debug reduced OS jitter. 235 235 Say N here if you are unsure. 236 236 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 + 237 255 endmenu # "RCU Subsystem"
+2 -1
kernel/rcu/tasks.h
··· 734 734 { 735 735 int nq = t->trc_reader_special.b.need_qs; 736 736 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) 738 739 smp_mb(); // Pairs with update-side barriers. 739 740 // Update .need_qs before ->trc_reader_nesting for irq/NMI handlers. 740 741 if (nq)