From c4e98d7f89c2c35550d82b10cddbfe93fef75dab Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Tue, 17 Jan 2017 12:30:12 -0500 Subject: [PATCH] LU-4423 libcfs: remove IS_PO2 and __is_po2 Removes IS_PO2 and __is_po2 since the uses of IS_PO2 have been replaced by is_power_of_2 Linux-commit: d4891039904fa25edf1ca793a0469633ed81df3f The following commit message is the same for the following patches: hash.c: Replace IS_PO2 by is_power_of_2 Linux-commit: 71872e9cc2af4dca1903ebc57daa15f08c795d86 selftest.h: replace IS_PO2 by is_power_of_2 Linux-commit: b3367164f4ff8ff2c1aa8bd79c7548f113b62b83 workitem.c: replace IS_PO2 by is_power_of_2 Linux-commit: 57b573d14b0fb9f83575a2cf155862d251c8f0d1 ldlm_extent.c: replace IS_PO2 by is_power_of_2 Linux-commit: 5f4179e04b31441b0b7995d14320a457aafba01b Replaces IS_PO2 by is_power_of_2. It is more accurate to use is_power_of_2 since it returns 1 for numbers that are powers of 2 only whereas IS_PO2 returns 1 for 0 and numbers that are powers of 2. Change-Id: Ic8bb40394b46ea433e3096c878abe467eacc7996 Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/24577 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Jian Yu --- libcfs/include/libcfs/libcfs.h | 6 ------ libcfs/libcfs/hash.c | 3 ++- libcfs/libcfs/workitem.c | 2 +- lnet/lnet/peer.c | 2 +- lnet/selftest/selftest.h | 2 +- lustre/ldlm/ldlm_extent.c | 2 +- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index 0f80224..23f29d5 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -39,12 +39,6 @@ #define LIBCFS_VERSION "0.5.0" -static inline int __is_po2(unsigned long long val) -{ - return !(val & (val - 1)); -} - -#define IS_PO2(val) __is_po2((unsigned long long)(val)) #define PO2_ROUNDUP_TYPED(x, po2, type) (-(-(type)(x) & -(type)(po2))) #define LOWEST_BIT_SET(x) ((x) & ~((x) - 1)) diff --git a/libcfs/libcfs/hash.c b/libcfs/libcfs/hash.c index bae84df..228cf0b 100644 --- a/libcfs/libcfs/hash.c +++ b/libcfs/libcfs/hash.c @@ -103,6 +103,7 @@ * table. Also, user can break the iteration by return 1 in callback. */ #include +#include #include #include @@ -1808,7 +1809,7 @@ cfs_hash_rehash_cancel_locked(struct cfs_hash *hs) for (i = 2; cfs_hash_is_rehashing(hs); i++) { cfs_hash_unlock(hs, 1); /* raise console warning while waiting too long */ - CDEBUG(IS_PO2(i >> 3) ? D_WARNING : D_INFO, + CDEBUG(is_power_of_2(i >> 3) ? D_WARNING : D_INFO, "hash %s is still rehashing, rescheded %d\n", hs->hs_name, i - 1); cond_resched(); diff --git a/libcfs/libcfs/workitem.c b/libcfs/libcfs/workitem.c index 40d5331..fb4fd64 100644 --- a/libcfs/libcfs/workitem.c +++ b/libcfs/libcfs/workitem.c @@ -313,7 +313,7 @@ cfs_wi_sched_destroy(struct cfs_wi_sched *sched) int i = 2; while (sched->ws_nthreads > 0) { - CDEBUG(IS_PO2(++i) ? D_WARNING : D_NET, + CDEBUG(is_power_of_2(++i) ? D_WARNING : D_NET, "waiting for %d threads of WI sched[%s] to " "terminate\n", sched->ws_nthreads, sched->ws_name); diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index a5758fa..01ee5ca 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -382,7 +382,7 @@ lnet_peer_ni_finalize_wait(struct lnet_peer_table *ptable) while (ptable->pt_zombies) { spin_unlock(&ptable->pt_zombie_lock); - if (IS_PO2(i)) { + if (is_power_of_2(i)) { CDEBUG(D_WARNING, "Waiting for %d zombies on peer table\n", ptable->pt_zombies); diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h index 9fecaad..b8c1e04 100644 --- a/lnet/selftest/selftest.h +++ b/lnet/selftest/selftest.h @@ -573,7 +573,7 @@ swi_state2str (int state) do { \ int __I = 2; \ while (!(cond)) { \ - CDEBUG(IS_PO2(++__I) ? D_WARNING : D_NET, \ + CDEBUG(is_power_of_2(++__I) ? D_WARNING : D_NET, \ fmt, ## __VA_ARGS__); \ spin_unlock(&(lock)); \ \ diff --git a/lustre/ldlm/ldlm_extent.c b/lustre/ldlm/ldlm_extent.c index 374834f..3388876 100644 --- a/lustre/ldlm/ldlm_extent.c +++ b/lustre/ldlm/ldlm_extent.c @@ -1065,7 +1065,7 @@ static inline int ldlm_mode_to_index(enum ldlm_mode mode) int index; LASSERT(mode != 0); - LASSERT(IS_PO2(mode)); + LASSERT(is_power_of_2(mode)); for (index = -1; mode != 0; index++, mode >>= 1) /* do nothing */; LASSERT(index < LCK_MODE_NUM); -- 1.8.3.1