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

Configure Feed

Select the types of activity you want to include in your feed.

linkmode: convert linkmode_{test,set,clear,mod}_bit() to macros

Since commit b03fc1173c0c ("bitops: let optimize out non-atomic bitops
on compile-time constants"), the non-atomic bitops are macros which can
be expanded by the compilers into compile-time expressions, which will
result in better optimized object code. Unfortunately, turned out that
passing `volatile` to those macros discards any possibility of
optimization, as the compilers then don't even try to look whether
the passed bitmap is known at compilation time. In addition to that,
the mentioned linkmode helpers are marked with `inline`, not
`__always_inline`, meaning that it's not guaranteed some compiler won't
uninline them for no reason, which will also effectively prevent them
from being optimized (it's a well-known thing the compilers sometimes
uninline `2 + 2`).
Convert linkmode_*_bit() from inlines to macros. Their calling
convention are 1:1 with the corresponding bitops, so that it's not even
needed to enumerate and map the arguments, only the names. No changes in
vmlinux' object code (compiled by LLVM for x86_64) whatsoever, but that
doesn't necessarily means the change is meaningless.

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Alexander Lobakin and committed by
David S. Miller
8fab6a9d 5259401e

+4 -23
+4 -23
include/linux/linkmode.h
··· 43 43 return bitmap_andnot(dst, src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS); 44 44 } 45 45 46 - static inline void linkmode_set_bit(int nr, volatile unsigned long *addr) 47 - { 48 - __set_bit(nr, addr); 49 - } 50 - 51 - static inline void linkmode_clear_bit(int nr, volatile unsigned long *addr) 52 - { 53 - __clear_bit(nr, addr); 54 - } 55 - 56 - static inline void linkmode_mod_bit(int nr, volatile unsigned long *addr, 57 - int set) 58 - { 59 - if (set) 60 - linkmode_set_bit(nr, addr); 61 - else 62 - linkmode_clear_bit(nr, addr); 63 - } 64 - 65 - static inline int linkmode_test_bit(int nr, const volatile unsigned long *addr) 66 - { 67 - return test_bit(nr, addr); 68 - } 46 + #define linkmode_test_bit test_bit 47 + #define linkmode_set_bit __set_bit 48 + #define linkmode_clear_bit __clear_bit 49 + #define linkmode_mod_bit __assign_bit 69 50 70 51 static inline void linkmode_set_bit_array(const int *array, int array_size, 71 52 unsigned long *addr)