diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2017-09-08 19:17:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-08 21:26:51 -0400 |
commit | f22ef333c32cc683922d7e3361a83ebc31b2ac6d (patch) | |
tree | 57173374d87f88a280e80a6b7b8ee3eb237d2c0b /include | |
parent | 0ce2c2029312ed78e37b56b08fa0f59ba97ef50b (diff) |
cpumask: make cpumask_next() out-of-line
Every for_each_XXX_cpu() invocation calls cpumask_next() which is an
inline function:
static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
{
/* -1 is a legal arg here. */
if (n != -1)
cpumask_check(n);
return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1);
}
However!
find_next_bit() is regular out-of-line function which means "nr_cpu_ids"
load and increment happen at the caller resulting in a lot of bloat
x86_64 defconfig:
add/remove: 3/0 grow/shrink: 8/373 up/down: 155/-5668 (-5513)
x86_64 allyesconfig-ish:
add/remove: 3/1 grow/shrink: 57/634 up/down: 3515/-28177 (-24662) !!!
Some archs redefine find_next_bit() but it is OK:
m68k inline but SMP is not supported
arm out-of-line
unicore32 out-of-line
Function call will happen anyway, so move load and increment into callee.
Link: http://lkml.kernel.org/r/20170824230010.GA1593@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/cpumask.h | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 68c5a8290275..cd415b733c2a 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -178,20 +178,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp) | |||
178 | return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits); | 178 | return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits); |
179 | } | 179 | } |
180 | 180 | ||
181 | /** | 181 | unsigned int cpumask_next(int n, const struct cpumask *srcp); |
182 | * cpumask_next - get the next cpu in a cpumask | ||
183 | * @n: the cpu prior to the place to search (ie. return will be > @n) | ||
184 | * @srcp: the cpumask pointer | ||
185 | * | ||
186 | * Returns >= nr_cpu_ids if no further cpus set. | ||
187 | */ | ||
188 | static inline unsigned int cpumask_next(int n, const struct cpumask *srcp) | ||
189 | { | ||
190 | /* -1 is a legal arg here. */ | ||
191 | if (n != -1) | ||
192 | cpumask_check(n); | ||
193 | return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1); | ||
194 | } | ||
195 | 182 | ||
196 | /** | 183 | /** |
197 | * cpumask_next_zero - get the next unset cpu in a cpumask | 184 | * cpumask_next_zero - get the next unset cpu in a cpumask |