aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2014-09-30 18:07:07 -0400
committerBrian Behlendorf <[email protected]>2014-10-17 15:11:50 -0700
commit87f8055a91940e6408420091e1a1601113f7912e (patch)
treea86d510d856546a22fdb0c9aa22c6dacdf00ec35 /module
parent9c91800d199c65c7d893445bae9b9a9a5590c335 (diff)
Map highbit64() to fls64()
The fls64() function has been available since Linux 2.6.16 and it should be used to implemented highbit64(). This allows us to provide an optimized implementation and simplify the code. Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module')
-rw-r--r--module/spl/spl-generic.c62
-rw-r--r--module/spl/spl-kmem.c2
2 files changed, 1 insertions, 63 deletions
diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c
index 3e8f874de..1059fb3cc 100644
--- a/module/spl/spl-generic.c
+++ b/module/spl/spl-generic.c
@@ -64,68 +64,6 @@ DECLARE_WAIT_QUEUE_HEAD(spl_kallsyms_lookup_name_waitq);
kallsyms_lookup_name_t spl_kallsyms_lookup_name_fn = SYMBOL_POISON;
#endif
-int
-highbit(unsigned long i)
-{
- register int h = 1;
- SENTRY;
-
- if (i == 0)
- SRETURN(0);
-#if BITS_PER_LONG == 64
- if (i & 0xffffffff00000000ul) {
- h += 32; i >>= 32;
- }
-#endif
- if (i & 0xffff0000) {
- h += 16; i >>= 16;
- }
- if (i & 0xff00) {
- h += 8; i >>= 8;
- }
- if (i & 0xf0) {
- h += 4; i >>= 4;
- }
- if (i & 0xc) {
- h += 2; i >>= 2;
- }
- if (i & 0x2) {
- h += 1;
- }
- SRETURN(h);
-}
-EXPORT_SYMBOL(highbit);
-
-int
-highbit64(uint64_t i)
-{
- register int h = 1;
- SENTRY;
-
- if (i == 0)
- SRETURN(0);
- if (i & 0xffffffff00000000ull) {
- h += 32; i >>= 32;
- }
- if (i & 0xffff0000) {
- h += 16; i >>= 16;
- }
- if (i & 0xff00) {
- h += 8; i >>= 8;
- }
- if (i & 0xf0) {
- h += 4; i >>= 4;
- }
- if (i & 0xc) {
- h += 2; i >>= 2;
- }
- if (i & 0x2) {
- h += 1;
- }
- SRETURN(h);
-}
-EXPORT_SYMBOL(highbit64);
-
#if BITS_PER_LONG == 32
/*
* Support 64/64 => 64 division on a 32-bit platform. While the kernel
diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
index 55b265696..8b52dfede 100644
--- a/module/spl/spl-kmem.c
+++ b/module/spl/spl-kmem.c
@@ -977,7 +977,7 @@ spl_sko_from_obj(spl_kmem_cache_t *skc, void *obj)
static inline uint32_t
spl_offslab_size(spl_kmem_cache_t *skc)
{
- return 1UL << (highbit(spl_obj_size(skc)) + 1);
+ return 1UL << (fls64(spl_obj_size(skc)) + 1);
}
/*