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

mce: Stop using array-index-based RCU primitives

Because mce is arch-specific x86 code, there is little or no
performance benefit of using rcu_dereference_index_check() over using
smp_load_acquire(). It also turns out that mce is the only place that
array-index-based RCU is used, and it would be convenient to drop
this portion of the RCU API.

This patch therefore changes rcu_dereference_index_check() uses to
smp_load_acquire(), but keeping the lockdep diagnostics, and also
changes rcu_access_index() uses to READ_ONCE().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: linux-edac@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Acked-by: Borislav Petkov <bp@suse.de>

+7 -4
+7 -4
arch/x86/kernel/cpu/mcheck/mce.c
··· 53 53 static DEFINE_MUTEX(mce_chrdev_read_mutex); 54 54 55 55 #define rcu_dereference_check_mce(p) \ 56 - rcu_dereference_index_check((p), \ 57 - rcu_read_lock_sched_held() || \ 58 - lockdep_is_held(&mce_chrdev_read_mutex)) 56 + ({ \ 57 + rcu_lockdep_assert(rcu_read_lock_sched_held() || \ 58 + lockdep_is_held(&mce_chrdev_read_mutex), \ 59 + "suspicious rcu_dereference_check_mce() usage"); \ 60 + smp_load_acquire(&(p)); \ 61 + }) 59 62 60 63 #define CREATE_TRACE_POINTS 61 64 #include <trace/events/mce.h> ··· 1887 1884 static unsigned int mce_chrdev_poll(struct file *file, poll_table *wait) 1888 1885 { 1889 1886 poll_wait(file, &mce_chrdev_wait, wait); 1890 - if (rcu_access_index(mcelog.next)) 1887 + if (READ_ONCE(mcelog.next)) 1891 1888 return POLLIN | POLLRDNORM; 1892 1889 if (!mce_apei_read_done && apei_check_mce()) 1893 1890 return POLLIN | POLLRDNORM;