diff options
author | Matthew Wilcox <mawilcox@microsoft.com> | 2017-07-10 18:51:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-10 19:32:34 -0400 |
commit | e5af323c9badd5dc09af7ccf9d45616ebffc623c (patch) | |
tree | da5f5087eb7c2eb2c5953bd34e5facc714de9d67 /lib | |
parent | 3cc78125a081bb79eb38f3e9a585e5a81bb81cb1 (diff) |
bitmap: optimise bitmap_set and bitmap_clear of a single bit
We have eight users calling bitmap_clear for a single bit and seventeen
calling bitmap_set for a single bit. Rather than fix all of them to
call __clear_bit or __set_bit, turn bitmap_clear and bitmap_set into
inline functions and make this special case efficient.
Link: http://lkml.kernel.org/r/20170628153221.11322-3-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bitmap.c | 8 | ||||
-rw-r--r-- | lib/test_bitmap.c | 3 |
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 08c6ef3a2b6f..9a532805364b 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -251,7 +251,7 @@ int __bitmap_weight(const unsigned long *bitmap, unsigned int bits) | |||
251 | } | 251 | } |
252 | EXPORT_SYMBOL(__bitmap_weight); | 252 | EXPORT_SYMBOL(__bitmap_weight); |
253 | 253 | ||
254 | void bitmap_set(unsigned long *map, unsigned int start, int len) | 254 | void __bitmap_set(unsigned long *map, unsigned int start, int len) |
255 | { | 255 | { |
256 | unsigned long *p = map + BIT_WORD(start); | 256 | unsigned long *p = map + BIT_WORD(start); |
257 | const unsigned int size = start + len; | 257 | const unsigned int size = start + len; |
@@ -270,9 +270,9 @@ void bitmap_set(unsigned long *map, unsigned int start, int len) | |||
270 | *p |= mask_to_set; | 270 | *p |= mask_to_set; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | EXPORT_SYMBOL(bitmap_set); | 273 | EXPORT_SYMBOL(__bitmap_set); |
274 | 274 | ||
275 | void bitmap_clear(unsigned long *map, unsigned int start, int len) | 275 | void __bitmap_clear(unsigned long *map, unsigned int start, int len) |
276 | { | 276 | { |
277 | unsigned long *p = map + BIT_WORD(start); | 277 | unsigned long *p = map + BIT_WORD(start); |
278 | const unsigned int size = start + len; | 278 | const unsigned int size = start + len; |
@@ -291,7 +291,7 @@ void bitmap_clear(unsigned long *map, unsigned int start, int len) | |||
291 | *p &= ~mask_to_clear; | 291 | *p &= ~mask_to_clear; |
292 | } | 292 | } |
293 | } | 293 | } |
294 | EXPORT_SYMBOL(bitmap_clear); | 294 | EXPORT_SYMBOL(__bitmap_clear); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | * bitmap_find_next_zero_area_off - find a contiguous aligned zero area | 297 | * bitmap_find_next_zero_area_off - find a contiguous aligned zero area |
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 252d3bddbe7d..2526a2975c51 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c | |||
@@ -333,9 +333,6 @@ static void __init test_bitmap_u32_array_conversions(void) | |||
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | #define __bitmap_set(a, b, c) bitmap_set(a, b, c) | ||
337 | #define __bitmap_clear(a, b, c) bitmap_clear(a, b, c) | ||
338 | |||
339 | static void noinline __init test_mem_optimisations(void) | 336 | static void noinline __init test_mem_optimisations(void) |
340 | { | 337 | { |
341 | DECLARE_BITMAP(bmap1, 1024); | 338 | DECLARE_BITMAP(bmap1, 1024); |