[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1586935667-4792-1-git-send-email-wangqing@vivo.com>
Date: Wed, 15 Apr 2020 15:27:40 +0800
From: Wang Qing <wangqing@...o.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Dennis Zhou <dennis@...nel.org>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
David Sterba <dsterba@...e.com>,
Josef Bacik <josef@...icpanda.com>,
Stefano Brivio <sbrivio@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
William Breathitt Gray <vilhelm.gray@...il.com>,
Randy Dunlap <rdunlap@...radead.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Yury Norov <yury.norov@...il.com>,
Wang Qing <wangqing@...o.com>, linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com
Subject: [PATCH] Bitmap: Optimized division operation to shift operation
On some processors, the / operate will call the compiler`s div lib,
which is low efficient. Bitmap is performance sensitive, We can
replace the / operation with shift.
Signed-off-by: Wang Qing <wangqing@...o.com>
---
include/linux/bitmap.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 99058eb..85ff982 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -337,7 +337,7 @@ static inline int bitmap_equal(const unsigned long *src1,
return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
if (__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
- return !memcmp(src1, src2, nbits / 8);
+ return !memcmp(src1, src2, nbits >> 3);
return __bitmap_equal(src1, src2, nbits);
}
@@ -411,7 +411,7 @@ static __always_inline void bitmap_set(unsigned long *map, unsigned int start,
IS_ALIGNED(start, BITMAP_MEM_ALIGNMENT) &&
__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
- memset((char *)map + start / 8, 0xff, nbits / 8);
+ memset((char *)map + (start >> 3), 0xff, nbits >> 3);
else
__bitmap_set(map, start, nbits);
}
@@ -425,7 +425,7 @@ static __always_inline void bitmap_clear(unsigned long *map, unsigned int start,
IS_ALIGNED(start, BITMAP_MEM_ALIGNMENT) &&
__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
- memset((char *)map + start / 8, 0, nbits / 8);
+ memset((char *)map + (start >> 3), 0, nbits >> 3);
else
__bitmap_clear(map, start, nbits);
}
--
2.7.4
Powered by blists - more mailing lists