From: Wang Qing <wangqing@vivo.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Dennis Zhou <dennis@kernel.org>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
David Sterba <dsterba@suse.com>,
Josef Bacik <josef@toxicpanda.com>,
Stefano Brivio <sbrivio@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
William Breathitt Gray <vilhelm.gray@gmail.com>,
Randy Dunlap <rdunlap@infradead.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Yury Norov <yury.norov@gmail.com>, Wang Qing <wangqing@vivo.com>,
linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: [PATCH] Bitmap: Optimized division operation to shift operation
Date: Wed, 15 Apr 2020 15:27:40 +0800 [thread overview]
Message-ID: <1586935667-4792-1-git-send-email-wangqing@vivo.com> (raw)
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@vivo.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
next reply other threads:[~2020-04-15 7:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 7:27 Wang Qing [this message]
2020-04-15 7:47 ` Joe Perches
2020-04-15 8:56 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1586935667-4792-1-git-send-email-wangqing@vivo.com \
--to=wangqing@vivo.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dennis@kernel.org \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-kernel@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=rdunlap@infradead.org \
--cc=sbrivio@redhat.com \
--cc=tglx@linutronix.de \
--cc=vilhelm.gray@gmail.com \
--cc=wsa+renesas@sang-engineering.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®