]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen/bitmap: Drop {bitmap,cpumask,nodes}_shift_{left,right}()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 25 Jun 2019 09:48:22 +0000 (10:48 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 31 Jul 2019 13:18:37 +0000 (14:18 +0100)
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 smallest 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@suse.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/common/bitmap.c
xen/include/xen/bitmap.h
xen/include/xen/cpumask.h
xen/include/xen/nodemask.h

index 34de387880f2ab790e0286b901ed0a7f623be1fd..fd070bee97af3c8aec5669f787f0d3673b7ea950 100644 (file)
@@ -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)
 {
index 0430c1ce2af4c0e1a6542ead75e399fc0b9c6abb..4e1e690af1e8345c530966147bea69ba850c7189 100644 (file)
@@ -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
 
index 1d73f9f3b6dd8872d0a2991bd7e73be3b85a0a3e..6be9567e9e05a35e67c33c653dadf6022e13daab 100644 (file)
@@ -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));
index e287399352f6c79109f51e1ff90b7de9c3018518..5eebc2c5eed151cb9b9f64615b2095afac2178ef 100644 (file)
@@ -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. */