diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-08-31 21:37:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-08-31 21:37:33 -0400 |
commit | 5757bd6157f523ff0d448a4ec93938523ca441a9 (patch) | |
tree | 713885bff513324e1935874653e546162cdbe540 | |
parent | 7073bc66126e3ab742cce9416ad6b4be8b03c4f7 (diff) | |
parent | accd0b9ec015d611eb7783dd86f1bb31bf8d62ab (diff) |
Merge branch 'core-types-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull inlining tuning from Ingo Molnar:
"A handful of inlining optimizations inspired by x86 work but
applicable in general"
* 'core-types-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
jiffies: Force inlining of {m,u}msecs_to_jiffies()
x86/hweight: Force inlining of __arch_hweight{32,64}()
linux/bitmap: Force inlining of bitmap weight functions
-rw-r--r-- | arch/x86/include/asm/arch_hweight.h | 13 | ||||
-rw-r--r-- | include/linux/bitmap.h | 2 | ||||
-rw-r--r-- | include/linux/bitops.h | 6 | ||||
-rw-r--r-- | include/linux/jiffies.h | 4 |
4 files changed, 14 insertions, 11 deletions
diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h index 9686c3d9ff73..259a7c1ef709 100644 --- a/arch/x86/include/asm/arch_hweight.h +++ b/arch/x86/include/asm/arch_hweight.h | |||
@@ -21,7 +21,7 @@ | |||
21 | * ARCH_HWEIGHT_CFLAGS in <arch/x86/Kconfig> for the respective | 21 | * ARCH_HWEIGHT_CFLAGS in <arch/x86/Kconfig> for the respective |
22 | * compiler switches. | 22 | * compiler switches. |
23 | */ | 23 | */ |
24 | static inline unsigned int __arch_hweight32(unsigned int w) | 24 | static __always_inline unsigned int __arch_hweight32(unsigned int w) |
25 | { | 25 | { |
26 | unsigned int res = 0; | 26 | unsigned int res = 0; |
27 | 27 | ||
@@ -42,20 +42,23 @@ static inline unsigned int __arch_hweight8(unsigned int w) | |||
42 | return __arch_hweight32(w & 0xff); | 42 | return __arch_hweight32(w & 0xff); |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifdef CONFIG_X86_32 | ||
45 | static inline unsigned long __arch_hweight64(__u64 w) | 46 | static inline unsigned long __arch_hweight64(__u64 w) |
46 | { | 47 | { |
47 | unsigned long res = 0; | ||
48 | |||
49 | #ifdef CONFIG_X86_32 | ||
50 | return __arch_hweight32((u32)w) + | 48 | return __arch_hweight32((u32)w) + |
51 | __arch_hweight32((u32)(w >> 32)); | 49 | __arch_hweight32((u32)(w >> 32)); |
50 | } | ||
52 | #else | 51 | #else |
52 | static __always_inline unsigned long __arch_hweight64(__u64 w) | ||
53 | { | ||
54 | unsigned long res = 0; | ||
55 | |||
53 | asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT) | 56 | asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT) |
54 | : "="REG_OUT (res) | 57 | : "="REG_OUT (res) |
55 | : REG_IN (w)); | 58 | : REG_IN (w)); |
56 | #endif /* CONFIG_X86_32 */ | ||
57 | 59 | ||
58 | return res; | 60 | return res; |
59 | } | 61 | } |
62 | #endif /* CONFIG_X86_32 */ | ||
60 | 63 | ||
61 | #endif | 64 | #endif |
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index ea17cca9e685..9653fdb76a42 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -295,7 +295,7 @@ static inline int bitmap_full(const unsigned long *src, unsigned int nbits) | |||
295 | return find_first_zero_bit(src, nbits) == nbits; | 295 | return find_first_zero_bit(src, nbits) == nbits; |
296 | } | 296 | } |
297 | 297 | ||
298 | static inline int bitmap_weight(const unsigned long *src, unsigned int nbits) | 298 | static __always_inline int bitmap_weight(const unsigned long *src, unsigned int nbits) |
299 | { | 299 | { |
300 | if (small_const_nbits(nbits)) | 300 | if (small_const_nbits(nbits)) |
301 | return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)); | 301 | return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)); |
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 297f5bda4fdf..e63553386ae7 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -57,7 +57,7 @@ extern unsigned long __sw_hweight64(__u64 w); | |||
57 | (bit) < (size); \ | 57 | (bit) < (size); \ |
58 | (bit) = find_next_zero_bit((addr), (size), (bit) + 1)) | 58 | (bit) = find_next_zero_bit((addr), (size), (bit) + 1)) |
59 | 59 | ||
60 | static __inline__ int get_bitmask_order(unsigned int count) | 60 | static inline int get_bitmask_order(unsigned int count) |
61 | { | 61 | { |
62 | int order; | 62 | int order; |
63 | 63 | ||
@@ -65,7 +65,7 @@ static __inline__ int get_bitmask_order(unsigned int count) | |||
65 | return order; /* We could be slightly more clever with -1 here... */ | 65 | return order; /* We could be slightly more clever with -1 here... */ |
66 | } | 66 | } |
67 | 67 | ||
68 | static __inline__ int get_count_order(unsigned int count) | 68 | static inline int get_count_order(unsigned int count) |
69 | { | 69 | { |
70 | int order; | 70 | int order; |
71 | 71 | ||
@@ -75,7 +75,7 @@ static __inline__ int get_count_order(unsigned int count) | |||
75 | return order; | 75 | return order; |
76 | } | 76 | } |
77 | 77 | ||
78 | static inline unsigned long hweight_long(unsigned long w) | 78 | static __always_inline unsigned long hweight_long(unsigned long w) |
79 | { | 79 | { |
80 | return sizeof(w) == 4 ? hweight32(w) : hweight64(w); | 80 | return sizeof(w) == 4 ? hweight32(w) : hweight64(w); |
81 | } | 81 | } |
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 535fd3bb1ba8..1ba48a18c1d7 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h | |||
@@ -351,7 +351,7 @@ static inline unsigned long _msecs_to_jiffies(const unsigned int m) | |||
351 | * directly here and from __msecs_to_jiffies() in the case where | 351 | * directly here and from __msecs_to_jiffies() in the case where |
352 | * constant folding is not possible. | 352 | * constant folding is not possible. |
353 | */ | 353 | */ |
354 | static inline unsigned long msecs_to_jiffies(const unsigned int m) | 354 | static __always_inline unsigned long msecs_to_jiffies(const unsigned int m) |
355 | { | 355 | { |
356 | if (__builtin_constant_p(m)) { | 356 | if (__builtin_constant_p(m)) { |
357 | if ((int)m < 0) | 357 | if ((int)m < 0) |
@@ -405,7 +405,7 @@ static inline unsigned long _usecs_to_jiffies(const unsigned int u) | |||
405 | * directly here and from __msecs_to_jiffies() in the case where | 405 | * directly here and from __msecs_to_jiffies() in the case where |
406 | * constant folding is not possible. | 406 | * constant folding is not possible. |
407 | */ | 407 | */ |
408 | static inline unsigned long usecs_to_jiffies(const unsigned int u) | 408 | static __always_inline unsigned long usecs_to_jiffies(const unsigned int u) |
409 | { | 409 | { |
410 | if (__builtin_constant_p(u)) { | 410 | if (__builtin_constant_p(u)) { |
411 | if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) | 411 | if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) |