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

rcu: Eliminate array-index-based RCU primitives

Now that rcu_access_index() and rcu_dereference_index_check() are no
longer used, the commit removes them from the RCU API. This means that
RCU's data dependencies now involve only pointers, give or take the
occasional cast to and then back from an integer type to do pointer
arithmetic. This in turn eliminates the need for a number of operations
on values carrying RCU data dependencies.

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>

-50
-50
include/linux/rcupdate.h
··· 628 628 ((typeof(*p) __force __kernel *)(p)); \ 629 629 }) 630 630 631 - #define __rcu_access_index(p, space) \ 632 - ({ \ 633 - typeof(p) _________p1 = READ_ONCE(p); \ 634 - rcu_dereference_sparse(p, space); \ 635 - (_________p1); \ 636 - }) 637 - #define __rcu_dereference_index_check(p, c) \ 638 - ({ \ 639 - /* Dependency order vs. p above. */ \ 640 - typeof(p) _________p1 = lockless_dereference(p); \ 641 - rcu_lockdep_assert(c, \ 642 - "suspicious rcu_dereference_index_check() usage"); \ 643 - (_________p1); \ 644 - }) 645 - 646 631 /** 647 632 * RCU_INITIALIZER() - statically initialize an RCU-protected global variable 648 633 * @v: The value to statically initialize with. ··· 770 785 * rcu_read_lock_held(). 771 786 */ 772 787 #define rcu_dereference_raw_notrace(p) __rcu_dereference_check((p), 1, __rcu) 773 - 774 - /** 775 - * rcu_access_index() - fetch RCU index with no dereferencing 776 - * @p: The index to read 777 - * 778 - * Return the value of the specified RCU-protected index, but omit the 779 - * smp_read_barrier_depends() and keep the READ_ONCE(). This is useful 780 - * when the value of this index is accessed, but the index is not 781 - * dereferenced, for example, when testing an RCU-protected index against 782 - * -1. Although rcu_access_index() may also be used in cases where 783 - * update-side locks prevent the value of the index from changing, you 784 - * should instead use rcu_dereference_index_protected() for this use case. 785 - */ 786 - #define rcu_access_index(p) __rcu_access_index((p), __rcu) 787 - 788 - /** 789 - * rcu_dereference_index_check() - rcu_dereference for indices with debug checking 790 - * @p: The pointer to read, prior to dereferencing 791 - * @c: The conditions under which the dereference will take place 792 - * 793 - * Similar to rcu_dereference_check(), but omits the sparse checking. 794 - * This allows rcu_dereference_index_check() to be used on integers, 795 - * which can then be used as array indices. Attempting to use 796 - * rcu_dereference_check() on an integer will give compiler warnings 797 - * because the sparse address-space mechanism relies on dereferencing 798 - * the RCU-protected pointer. Dereferencing integers is not something 799 - * that even gcc will put up with. 800 - * 801 - * Note that this function does not implicitly check for RCU read-side 802 - * critical sections. If this function gains lots of uses, it might 803 - * make sense to provide versions for each flavor of RCU, but it does 804 - * not make sense as of early 2010. 805 - */ 806 - #define rcu_dereference_index_check(p, c) \ 807 - __rcu_dereference_index_check((p), (c)) 808 788 809 789 /** 810 790 * rcu_dereference_protected() - fetch RCU pointer when updates prevented