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

[Xen-devel] [PATCH v2 4/5] xen/bitmap: Drop all bitmap_scn{, list}printf() infrastructure



All callers have been convered to using %*pb[l].  In the unlikely case that
future code wants to retain this functionaly, it can be replicated in a more
convenient fashon with snprintf().

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Reviewed-by: Dario Faggioli <dfaggioli@xxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>
CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
 xen/common/bitmap.c        | 105 ---------------------------------------------
 xen/include/xen/bitmap.h   |   6 ---
 xen/include/xen/cpumask.h  |  18 --------
 xen/include/xen/nodemask.h |  34 ---------------
 4 files changed, 163 deletions(-)

diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c
index f498ee6..34de387 100644
--- a/xen/common/bitmap.c
+++ b/xen/common/bitmap.c
@@ -300,111 +300,6 @@ int __bitmap_weight(const unsigned long *bitmap, int bits)
 #endif
 EXPORT_SYMBOL(__bitmap_weight);
 
-/*
- * Bitmap printing & parsing functions: first version by Bill Irwin,
- * second version by Paul Jackson, third by Joe Korty.
- */
-
-#define CHUNKSZ                                32
-#define nbits_to_hold_value(val)       fls(val)
-#define roundup_power2(val,modulus)    (((val) + (modulus) - 1) & ~((modulus) 
- 1))
-#define unhex(c)                       (isdigit(c) ? (c - '0') : (toupper(c) - 
'A' + 10))
-#define BASEDEC 10             /* fancier cpuset lists input in decimal */
-
-/**
- * bitmap_scnprintf - convert bitmap to an ASCII hex string.
- * @buf: byte buffer into which string is placed
- * @buflen: reserved size of @buf, in bytes
- * @maskp: pointer to bitmap to convert
- * @nmaskbits: size of bitmap, in bits
- *
- * Exactly @nmaskbits bits are displayed.  Hex digits are grouped into
- * comma-separated sets of eight digits per set.
- */
-int bitmap_scnprintf(char *buf, unsigned int buflen,
-       const unsigned long *maskp, int nmaskbits)
-{
-       int i, word, bit, len = 0;
-       unsigned long val;
-       const char *sep = "";
-       int chunksz;
-       u32 chunkmask;
-
-       chunksz = nmaskbits & (CHUNKSZ - 1);
-       if (chunksz == 0)
-               chunksz = CHUNKSZ;
-
-       i = roundup_power2(nmaskbits, CHUNKSZ) - CHUNKSZ;
-       for (; i >= 0; i -= CHUNKSZ) {
-               chunkmask = ((1ULL << chunksz) - 1);
-               word = i / BITS_PER_LONG;
-               bit = i % BITS_PER_LONG;
-               val = (maskp[word] >> bit) & chunkmask;
-               len += scnprintf(buf+len, buflen-len, "%s%0*lx", sep,
-                       (chunksz+3)/4, val);
-               chunksz = CHUNKSZ;
-               sep = ",";
-       }
-       return len;
-}
-EXPORT_SYMBOL(bitmap_scnprintf);
-
-/*
- * bscnl_emit(buf, buflen, rbot, rtop, bp)
- *
- * Helper routine for bitmap_scnlistprintf().  Write decimal number
- * or range to buf, suppressing output past buf+buflen, with optional
- * comma-prefix.  Return len of what would be written to buf, if it
- * all fit.
- */
-static inline int bscnl_emit(char *buf, int buflen, int rbot, int rtop, int 
len)
-{
-       if (len > 0)
-               len += scnprintf(buf + len, buflen - len, ",");
-       if (rbot == rtop)
-               len += scnprintf(buf + len, buflen - len, "%d", rbot);
-       else
-               len += scnprintf(buf + len, buflen - len, "%d-%d", rbot, rtop);
-       return len;
-}
-
-/**
- * bitmap_scnlistprintf - convert bitmap to list format ASCII string
- * @buf: byte buffer into which string is placed
- * @buflen: reserved size of @buf, in bytes
- * @maskp: pointer to bitmap to convert
- * @nmaskbits: size of bitmap, in bits
- *
- * Output format is a comma-separated list of decimal numbers and
- * ranges.  Consecutively set bits are shown as two hyphen-separated
- * decimal numbers, the smallest and largest bit numbers set in
- * the range.  Output format is compatible with the format
- * accepted as input by bitmap_parselist().
- *
- * The return value is the number of characters which were output,
- * excluding the trailing '\0'.
- */
-int bitmap_scnlistprintf(char *buf, unsigned int buflen,
-       const unsigned long *maskp, int nmaskbits)
-{
-       int len = 0;
-       /* current bit is 'cur', most recently seen range is [rbot, rtop] */
-       int cur, rbot, rtop;
-
-       rbot = cur = find_first_bit(maskp, nmaskbits);
-       while (cur < nmaskbits) {
-               rtop = cur;
-               cur = find_next_bit(maskp, nmaskbits, cur+1);
-               if (cur >= nmaskbits || cur > rtop + 1) {
-                       len = bscnl_emit(buf, buflen, rbot, rtop, len);
-                       rbot = cur;
-               }
-       }
-       if (!len && buflen)
-               *buf = 0;
-       return len;
-}
-EXPORT_SYMBOL(bitmap_scnlistprintf);
 
 /**
  *     bitmap_find_free_region - find a contiguous aligned mem region
diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
index e2a3686..fe3c720 100644
--- a/xen/include/xen/bitmap.h
+++ b/xen/include/xen/bitmap.h
@@ -40,8 +40,6 @@
  * 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
- * bitmap_scnprintf(buf, len, src, nbits)      Print bitmap src to buf
- * bitmap_scnlistprintf(buf, len, src, nbits)  Print bitmap src as list to buf
  */
 
 /*
@@ -94,10 +92,6 @@ extern int __bitmap_subset(const unsigned long *bitmap1,
                        const unsigned long *bitmap2, int bits);
 extern int __bitmap_weight(const unsigned long *bitmap, int bits);
 
-extern int bitmap_scnprintf(char *buf, unsigned int len,
-                       const unsigned long *src, int nbits);
-extern int bitmap_scnlistprintf(char *buf, unsigned int len,
-                       const unsigned long *src, int nbits);
 extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order);
 extern void bitmap_release_region(unsigned long *bitmap, int pos, int order);
 extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h
index 4731a63..b4cc92a 100644
--- a/xen/include/xen/cpumask.h
+++ b/xen/include/xen/cpumask.h
@@ -8,9 +8,6 @@
  * See detailed comments in the file xen/bitmap.h describing the
  * data type on which these cpumasks are based.
  *
- * For details of cpumask_scnprintf() and cpulist_scnprintf(),
- * see bitmap_scnprintf() and bitmap_scnlistprintf() in lib/bitmap.c.
- *
  * The available cpumask operations are:
  *
  * void cpumask_set_cpu(cpu, mask)     turn on bit 'cpu' in mask
@@ -46,9 +43,6 @@
  * const cpumask_t *cpumask_of(cpu)    Return cpumask with bit 'cpu' set
  * unsigned long *cpumask_bits(mask)   Array of unsigned long's in mask
  *
- * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
- * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
- *
  * for_each_cpu(cpu, mask)             for-loop cpu over mask
  *
  * int num_online_cpus()               Number of online CPUs
@@ -312,18 +306,6 @@ static inline const cpumask_t *cpumask_of(unsigned int cpu)
 
 #define cpumask_bits(maskp) ((maskp)->bits)
 
-static inline int cpumask_scnprintf(char *buf, int len,
-                                   const cpumask_t *srcp)
-{
-       return bitmap_scnprintf(buf, len, srcp->bits, nr_cpu_ids);
-}
-
-static inline int cpulist_scnprintf(char *buf, int len,
-                                   const cpumask_t *srcp)
-{
-       return bitmap_scnlistprintf(buf, len, srcp->bits, nr_cpu_ids);
-}
-
 /*
  * cpumask_var_t: struct cpumask for stack usage.
  *
diff --git a/xen/include/xen/nodemask.h b/xen/include/xen/nodemask.h
index 2a90dc1..e287399 100644
--- a/xen/include/xen/nodemask.h
+++ b/xen/include/xen/nodemask.h
@@ -8,10 +8,6 @@
  * See detailed comments in the file linux/bitmap.h describing the
  * data type on which these nodemasks are based.
  *
- * For details of nodemask_scnprintf(), nodelist_scnpintf() and
- * nodemask_parse(), see bitmap_scnprintf() and bitmap_parse()
- * in lib/bitmap.c.
- *
  * The available nodemask operations are:
  *
  * void node_set(node, mask)           turn on bit 'node' in mask
@@ -50,10 +46,6 @@
  * NODE_MASK_NONE                      Initializer - no bits set
  * unsigned long *nodes_addr(mask)     Array of unsigned long's in mask
  *
- * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
- * int nodelist_scnprintf(buf, len, mask) Format nodemask as a list for 
printing
- * int nodemask_parse(ubuf, ulen, mask)        Parse ascii string as nodemask
- *
  * for_each_node_mask(node, mask)      for-loop node over mask
  *
  * int num_online_nodes()              Number of online Nodes
@@ -294,32 +286,6 @@ static inline int __cycle_node(int n, const nodemask_t 
*maskp, int nbits)
 
 #define nodes_addr(src) ((src).bits)
 
-#define nodelist_scnprintf(buf, len, src) \
-                       __nodelist_scnprintf((buf), (len), (src), MAX_NUMNODES)
-static inline int __nodelist_scnprintf(char *buf, int len,
-                                       const nodemask_t *srcp, int nbits)
-{
-       return bitmap_scnlistprintf(buf, len, srcp->bits, nbits);
-}
-
-#if 0
-#define nodemask_scnprintf(buf, len, src) \
-                       __nodemask_scnprintf((buf), (len), &(src), MAX_NUMNODES)
-static inline int __nodemask_scnprintf(char *buf, int len,
-                                       const nodemask_t *srcp, int nbits)
-{
-       return bitmap_scnprintf(buf, len, srcp->bits, nbits);
-}
-
-#define nodemask_parse(ubuf, ulen, dst) \
-                       __nodemask_parse((ubuf), (ulen), &(dst), MAX_NUMNODES)
-static inline int __nodemask_parse(const char __user *buf, int len,
-                                       nodemask_t *dstp, int nbits)
-{
-       return bitmap_parse(buf, len, dstp->bits, nbits);
-}
-#endif
-
 #if MAX_NUMNODES > 1
 #define for_each_node_mask(node, mask)                 \
        for ((node) = first_node(mask);                 \
-- 
2.1.4


_______________________________________________
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®.