[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v3 02/10] xen/bitmap: Drop {bitmap, cpumask, nodes}_shift_{left, right}()



These operations have never been used in Xen since their introduction, and it
doesn't seem likely that they will in the future.

Bloat-o-meter reports that they aren't the smalled when compiled, either.

  add/remove: 0/2 grow/shrink: 0/0 up/down: 0/-814 (-814)
  Function                                     old     new   delta
  __bitmap_shift_left                          366       -    -366
  __bitmap_shift_right                         448       -    -448
  Total: Before=3323730, After=3322916, chg -0.02%

Suggested-by: Jan Beulich <JBeulich@xxxxxxxx>
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>

v3:
 * New
---
 xen/common/bitmap.c        | 88 ----------------------------------------------
 xen/include/xen/bitmap.h   | 22 ------------
 xen/include/xen/cpumask.h  | 15 --------
 xen/include/xen/nodemask.h | 19 ----------
 4 files changed, 144 deletions(-)

diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c
index 34de387880..fd070bee97 100644
--- a/xen/common/bitmap.c
+++ b/xen/common/bitmap.c
@@ -109,94 +109,6 @@ void __bitmap_complement(unsigned long *dst, const 
unsigned long *src, int bits)
 }
 EXPORT_SYMBOL(__bitmap_complement);
 
-/*
- * __bitmap_shift_right - logical right shift of the bits in a bitmap
- *   @dst - destination bitmap
- *   @src - source bitmap
- *   @nbits - shift by this many bits
- *   @bits - bitmap size, in bits
- *
- * Shifting right (dividing) means moving bits in the MS -> LS bit
- * direction.  Zeros are fed into the vacated MS positions and the
- * LS bits shifted off the bottom are lost.
- */
-void __bitmap_shift_right(unsigned long *dst,
-                       const unsigned long *src, int shift, int bits)
-{
-       int k, lim = BITS_TO_LONGS(bits), left = bits % BITS_PER_LONG;
-       int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG;
-       unsigned long mask = (1UL << left) - 1;
-       for (k = 0; off + k < lim; ++k) {
-               unsigned long upper, lower;
-
-               /*
-                * If shift is not word aligned, take lower rem bits of
-                * word above and make them the top rem bits of result.
-                */
-               if (!rem || off + k + 1 >= lim)
-                       upper = 0;
-               else {
-                       upper = src[off + k + 1];
-                       if (off + k + 1 == lim - 1 && left)
-                               upper &= mask;
-               }
-               lower = src[off + k];
-               if (left && off + k == lim - 1)
-                       lower &= mask;
-               dst[k] = rem
-                        ? (upper << (BITS_PER_LONG - rem)) | (lower >> rem)
-                        : lower;
-               if (left && k == lim - 1)
-                       dst[k] &= mask;
-       }
-       if (off)
-               memset(&dst[lim - off], 0, off*sizeof(unsigned long));
-}
-EXPORT_SYMBOL(__bitmap_shift_right);
-
-
-/*
- * __bitmap_shift_left - logical left shift of the bits in a bitmap
- *   @dst - destination bitmap
- *   @src - source bitmap
- *   @nbits - shift by this many bits
- *   @bits - bitmap size, in bits
- *
- * Shifting left (multiplying) means moving bits in the LS -> MS
- * direction.  Zeros are fed into the vacated LS bit positions
- * and those MS bits shifted off the top are lost.
- */
-
-void __bitmap_shift_left(unsigned long *dst,
-                       const unsigned long *src, int shift, int bits)
-{
-       int k, lim = BITS_TO_LONGS(bits), left = bits % BITS_PER_LONG;
-       int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG;
-       for (k = lim - off - 1; k >= 0; --k) {
-               unsigned long upper, lower;
-
-               /*
-                * If shift is not word aligned, take upper rem bits of
-                * word below and make them the bottom rem bits of result.
-                */
-               if (rem && k > 0)
-                       lower = src[k - 1];
-               else
-                       lower = 0;
-               upper = src[k];
-               if (left && k == lim - 1)
-                       upper &= (1UL << left) - 1;
-               dst[k + off] = rem ? (lower >> (BITS_PER_LONG - rem))
-                                     | (upper << rem)
-                                  : upper;
-               if (left && k + off == lim - 1)
-                       dst[k + off] &= (1UL << left) - 1;
-       }
-       if (off)
-               memset(dst, 0, off*sizeof(unsigned long));
-}
-EXPORT_SYMBOL(__bitmap_shift_left);
-
 void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
                                const unsigned long *bitmap2, int bits)
 {
diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
index 0430c1ce2a..4e1e690af1 100644
--- a/xen/include/xen/bitmap.h
+++ b/xen/include/xen/bitmap.h
@@ -38,8 +38,6 @@
  * bitmap_empty(src, nbits)                    Are all bits zero in *src?
  * bitmap_full(src, nbits)                     Are all bits set in *src?
  * bitmap_weight(src, nbits)                   Hamming Weight: number set bits
- * bitmap_shift_right(dst, src, n, nbits)      *dst = *src >> n
- * bitmap_shift_left(dst, src, n, nbits)       *dst = *src << n
  */
 
 /*
@@ -74,10 +72,6 @@ extern int __bitmap_equal(const unsigned long *bitmap1,
                        const unsigned long *bitmap2, int bits);
 extern void __bitmap_complement(unsigned long *dst, const unsigned long *src,
                        int bits);
-extern void __bitmap_shift_right(unsigned long *dst,
-                        const unsigned long *src, int shift, int bits);
-extern void __bitmap_shift_left(unsigned long *dst,
-                        const unsigned long *src, int shift, int bits);
 extern void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
                        const unsigned long *bitmap2, int bits);
 extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
@@ -233,22 +227,6 @@ static inline int bitmap_weight(const unsigned long *src, 
int nbits)
        return __bitmap_weight(src, nbits);
 }
 
-static inline void bitmap_shift_right(unsigned long *dst,
-                       const unsigned long *src, int n, int nbits)
-{
-       bitmap_switch(nbits,,
-               *dst = *src >> n,
-               __bitmap_shift_right(dst, src, n, nbits));
-}
-
-static inline void bitmap_shift_left(unsigned long *dst,
-                       const unsigned long *src, int n, int nbits)
-{
-       bitmap_switch(nbits,,
-               *dst = (*src << n) & BITMAP_LAST_WORD_MASK(nbits),
-               __bitmap_shift_left(dst, src, n, nbits));
-}
-
 #undef bitmap_switch
 #undef bitmap_bytes
 
diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h
index 1d73f9f3b6..6be9567e9e 100644
--- a/xen/include/xen/cpumask.h
+++ b/xen/include/xen/cpumask.h
@@ -31,9 +31,6 @@
  * int cpumask_full(mask)              Is mask full (all bits sets)?
  * int cpumask_weight(mask)            Hamming weigh - number of set bits
  *
- * void cpumask_shift_right(dst, src, n) Shift right
- * void cpumask_shift_left(dst, src, n)        Shift left
- *
  * int cpumask_first(mask)             Number lowest set bit, or NR_CPUS
  * int cpumask_next(cpu, mask)         Next cpu past 'cpu', or NR_CPUS
  * int cpumask_last(mask)              Number highest set bit, or NR_CPUS
@@ -213,18 +210,6 @@ static inline void cpumask_copy(cpumask_t *dstp, const 
cpumask_t *srcp)
        bitmap_copy(dstp->bits, srcp->bits, nr_cpumask_bits);
 }
 
-static inline void cpumask_shift_right(cpumask_t *dstp,
-                                      const cpumask_t *srcp, int n)
-{
-       bitmap_shift_right(dstp->bits, srcp->bits, n, nr_cpumask_bits);
-}
-
-static inline void cpumask_shift_left(cpumask_t *dstp,
-                                     const cpumask_t *srcp, int n)
-{
-       bitmap_shift_left(dstp->bits, srcp->bits, n, nr_cpumask_bits);
-}
-
 static inline int cpumask_first(const cpumask_t *srcp)
 {
        return min_t(int, nr_cpu_ids, find_first_bit(srcp->bits, nr_cpu_ids));
diff --git a/xen/include/xen/nodemask.h b/xen/include/xen/nodemask.h
index e287399352..5eebc2c5ee 100644
--- a/xen/include/xen/nodemask.h
+++ b/xen/include/xen/nodemask.h
@@ -30,9 +30,6 @@
  * int nodes_full(mask)                        Is mask full (all bits sets)?
  * int nodes_weight(mask)              Hamming weight - number of set bits
  *
- * void nodes_shift_right(dst, src, n) Shift right
- * void nodes_shift_left(dst, src, n)  Shift left
- *
  * int first_node(mask)                        Number lowest set bit, or 
MAX_NUMNODES
  * int next_node(node, mask)           Next node past 'node', or MAX_NUMNODES
  * int last_node(mask)                 Number highest set bit, or MAX_NUMNODES
@@ -189,22 +186,6 @@ static inline int __nodes_weight(const nodemask_t *srcp, 
int nbits)
        return bitmap_weight(srcp->bits, nbits);
 }
 
-#define nodes_shift_right(dst, src, n) \
-                       __nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES)
-static inline void __nodes_shift_right(nodemask_t *dstp,
-                                       const nodemask_t *srcp, int n, int 
nbits)
-{
-       bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
-}
-
-#define nodes_shift_left(dst, src, n) \
-                       __nodes_shift_left(&(dst), &(src), (n), MAX_NUMNODES)
-static inline void __nodes_shift_left(nodemask_t *dstp,
-                                       const nodemask_t *srcp, int n, int 
nbits)
-{
-       bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
-}
-
 /* FIXME: better would be to fix all architectures to never return
           > MAX_NUMNODES, then the silly min_ts could be dropped. */
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.