Whamcloud - gitweb
LU-4423 libcfs: remove IS_PO2 and __is_po2 77/24577/3
authorAya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Tue, 17 Jan 2017 17:30:12 +0000 (12:30 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 7 Feb 2017 06:16:56 +0000 (06:16 +0000)
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 <mahfouz.saif.elyazal@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/24577
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
libcfs/include/libcfs/libcfs.h
libcfs/libcfs/hash.c
libcfs/libcfs/workitem.c
lnet/lnet/peer.c
lnet/selftest/selftest.h
lustre/ldlm/ldlm_extent.c

index 0f80224..23f29d5 100644 (file)
 
 #define LIBCFS_VERSION "0.5.0"
 
 
 #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))
 
 #define PO2_ROUNDUP_TYPED(x, po2, type) (-(-(type)(x) & -(type)(po2)))
 #define LOWEST_BIT_SET(x) ((x) & ~((x) - 1))
 
index bae84df..228cf0b 100644 (file)
  *   table. Also, user can break the iteration by return 1 in callback.
  */
 #include <linux/seq_file.h>
  *   table. Also, user can break the iteration by return 1 in callback.
  */
 #include <linux/seq_file.h>
+#include <linux/log2.h>
 
 #include <libcfs/linux/linux-list.h>
 #include <libcfs/libcfs.h>
 
 #include <libcfs/linux/linux-list.h>
 #include <libcfs/libcfs.h>
@@ -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 */
         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();
                       "hash %s is still rehashing, rescheded %d\n",
                       hs->hs_name, i - 1);
                cond_resched();
index 40d5331..fb4fd64 100644 (file)
@@ -313,7 +313,7 @@ cfs_wi_sched_destroy(struct cfs_wi_sched *sched)
                int i = 2;
 
                while (sched->ws_nthreads > 0) {
                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);
                               "waiting for %d threads of WI sched[%s] to "
                               "terminate\n", sched->ws_nthreads,
                               sched->ws_name);
index a5758fa..01ee5ca 100644 (file)
@@ -382,7 +382,7 @@ lnet_peer_ni_finalize_wait(struct lnet_peer_table *ptable)
        while (ptable->pt_zombies) {
                spin_unlock(&ptable->pt_zombie_lock);
 
        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);
                        CDEBUG(D_WARNING,
                               "Waiting for %d zombies on peer table\n",
                               ptable->pt_zombies);
index 9fecaad..b8c1e04 100644 (file)
@@ -573,7 +573,7 @@ swi_state2str (int state)
 do {                                                                   \
        int __I = 2;                                                    \
        while (!(cond)) {                                               \
 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));                                   \
                                                                        \
                       fmt, ## __VA_ARGS__);                            \
                spin_unlock(&(lock));                                   \
                                                                        \
index 374834f..3388876 100644 (file)
@@ -1065,7 +1065,7 @@ static inline int ldlm_mode_to_index(enum ldlm_mode mode)
        int index;
 
        LASSERT(mode != 0);
        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);
        for (index = -1; mode != 0; index++, mode >>= 1)
                /* do nothing */;
        LASSERT(index < LCK_MODE_NUM);