bitmap, cpumask, nodemask: implement %*pb[l] to format bitmaps directly from printf family of functions
Subsystems (31)
Tejun Heo
maintainerPATCH 1/1 bitmap, cpumask, nodemask: implement %*pb[l] to format bitmaps directly from printf family of functions
Hello,
bitmap implements two variants of scnprintf functions to format a bitmap into a string and cpumask and nodemask wrap them to provide equivalent interfaces. The scnprintf family of functions require a string buffer as an output target which complicates code paths which just want to print out the mask through printk for informational or debug purposes as they have to worry about how large the buffer should be and whether it's too large to allocate on stack.
Neither cpumask or nodemask provides a guildeline on how large the target buffer should be forcing users come up with their own solutions
- some allocate an arbitrarily sized buffer which is small enough to allocate on stack but may be too short in corner cases, other come up with a custom upper limit calculation considering the output format, some allocate the buffer dynamically while one resorted to using lock to synchronize access to a static buffer.
This is an artificial problem which is being solved repeatedly for no benefit. In a lot of cases, the output area already exists and can be targeted directly making the intermediate buffer unnecessary. This patchset teaches printf family of functions how to format bitmaps and replace the dedicated formatting functions with it.
Pointer formatting is extended to cover bitmap formatting. It uses the field width for the number of bits instead of precision. The format used is '%*pb[l]', with the optional trailing 'l' specifying list format instead of hex masks. For more details, please see 0002.
This patchset contains the following 32 patches.
0001-cpumask-always-use-nr_cpu_ids-in-formatting-and-pars.patch 0002-lib-vsprintf-implement-bitmap-printing-through-pb-l.patch 0003-cpumask-nodemask-implement-cpumask-nodemask_pr_args.patch 0004-bitmap-use-pb-l-to-print-bitmaps-including-cpumasks-.patch 0005-mips-use-pb-l-to-print-bitmaps-including-cpumasks-an.patch 0006-powerpc-use-pb-l-to-print-bitmaps-including-cpumasks.patch 0007-s390-use-pb-l-to-print-bitmaps-including-cpumasks-an.patch 0008-tile-use-pb-l-to-print-bitmaps-including-cpumasks-an.patch 0009-x86-use-pb-l-to-print-bitmaps-including-cpumasks-and.patch 0010-ia64-use-pb-l-to-print-bitmaps-including-cpumasks-an.patch 0011-xtensa-use-pb-l-to-print-bitmaps-including-cpumasks-.patch 0012-arm-use-pb-l-to-print-bitmaps-including-cpumasks-and.patch 0013-cpuset-use-pb-l-to-print-bitmaps-including-cpumasks-.patch 0014-rcu-use-pb-l-to-print-bitmaps-including-cpumasks-and.patch 0015-sched-use-pb-l-to-print-bitmaps-including-cpumasks-a.patch 0016-time-use-pb-l-to-print-bitmaps-including-cpumasks-an.patch 0017-percpu-use-pb-l-to-print-bitmaps-including-cpumasks-.patch 0018-workqueue-use-pb-l-to-format-bitmaps-including-cpuma.patch 0019-tracing-use-pb-l-to-print-bitmaps-including-cpumasks.patch 0020-net-use-pb-l-to-print-bitmaps-including-cpumasks-and.patch 0021-wireless-use-pb-l-to-print-bitmaps-including-cpumask.patch 0022-input-use-pb-l-to-print-bitmaps-including-cpumasks-a.patch 0023-scsi-use-pb-l-to-print-bitmaps-including-cpumasks-an.patch 0024-usb-use-pb-l-to-print-bitmaps-including-cpumasks-and.patch 0025-drivers-base-use-pb-l-to-print-bitmaps-including-cpu.patch 0026-slub-use-pb-l-to-print-bitmaps-including-cpumasks-an.patch 0027-mm-use-pb-l-to-print-bitmaps-including-cpumasks-and-.patch 0028-padata-use-pb-l-to-print-bitmaps-including-cpumasks-.patch 0029-proc-use-pb-l-to-print-bitmaps-including-cpumasks-an.patch 0030-irq-use-pb-l-to-print-bitmaps-including-cpumasks-and.patch 0031-profile-use-pb-l-to-print-bitmaps-including-cpumasks.patch 0032-bitmap-cpumask-nodemask-remove-dedicated-formatting-.patch
0001 removes inconsistency in cpumask formatting and parsing.
0002 implements '%*pb[l]' formatting.
0003 implements cpumask/nodemask_pr_args() macros.
0004-0031 convert existing users of the dedicated formatting functions to use '%*pb[l]'.
0032 removes the dedicated formatting functions.
If we can agree on this approach, it'd be best to route 0001-0003 through mainline ASAP and then route the rest through respective susbsystems.
The patchset is also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git review-bitmap-print
diffstat follows. Around -300 LOC.
arch/ia64/kernel/topology.c | 6 - arch/mips/netlogic/common/smp.c | 13 +-- arch/powerpc/kernel/cacheinfo.c | 15 +-- arch/powerpc/sysdev/xics/ics-opal.c | 6 - arch/powerpc/sysdev/xics/ics-rtas.c | 7 - arch/s390/kernel/cache.c | 9 +- arch/tile/kernel/hardwall.c | 5 - arch/tile/kernel/proc.c | 5 - arch/tile/kernel/setup.c | 13 +-- arch/tile/mm/homecache.c | 12 +- arch/tile/mm/init.c | 18 +--- arch/x86/kernel/cpu/intel_cacheinfo.c | 26 ++---- arch/x86/mm/numa.c | 6 - arch/x86/platform/uv/uv_nmi.c | 25 +----- arch/xtensa/kernel/setup.c | 7 - drivers/base/cpu.c | 2 drivers/base/node.c | 3 drivers/bus/arm-cci.c | 4 drivers/input/keyboard/atkbd.c | 4 drivers/input/keyboard/gpio_keys.c | 2 drivers/net/ethernet/tile/tilegx.c | 5 - drivers/net/ethernet/tile/tilepro.c | 5 - drivers/net/wireless/ath/ath9k/htc_drv_debug.c | 23 +---- drivers/net/wireless/ath/carl9170/debug.c | 24 +---- drivers/scsi/scsi_debug.c | 6 - drivers/usb/host/whci/debug.c | 7 - drivers/usb/wusbcore/reservation.c | 5 - drivers/usb/wusbcore/wa-rpipe.c | 5 - drivers/usb/wusbcore/wusbhc.c | 7 - drivers/uwb/drp.c | 2 drivers/uwb/uwb-debug.c | 16 +-- fs/proc/array.c | 10 -- fs/seq_file.c | 32 ------- include/linux/bitmap.h | 7 - include/linux/cpumask.h | 49 +++--------- include/linux/nodemask.h | 41 +++------- include/linux/seq_buf.h | 3 include/linux/seq_file.h | 25 ------ kernel/cpuset.c | 42 ++-------- kernel/irq/proc.c | 11 -- kernel/padata.c | 11 -- kernel/profile.c | 3 kernel/rcu/tree_plugin.h | 5 - kernel/sched/core.c | 10 -- kernel/sched/stats.c | 11 -- kernel/time/tick-sched.c | 11 -- kernel/trace/trace.c | 6 - kernel/trace/trace_seq.c | 2 kernel/workqueue.c | 5 - lib/bitmap.c | 102 ------------------------- lib/seq_buf.c | 36 -------- lib/vsprintf.c | 94 +++++++++++++++++++++++ mm/mempolicy.c | 7 - mm/percpu.c | 6 - mm/slub.c | 20 +--- net/core/net-sysfs.c | 28 +----- net/core/sysctl_net_core.c | 2 57 files changed, 288 insertions(+), 584 deletions(-)
--
tejun
Tejun Heo
maintainerPATCH 1/32 cpumask: always use nr_cpu_ids in formatting and parsing functions
Currently, the formatting and parsing functions in cpumask.h use nr_cpumask_bits like other cpumask functions; however, nr_cpumask_bits is either NR_CPUS or nr_cpu_ids depending on CONFIG_CPUMASK_OFFSTACK. This leads to inconsistent behaviors.
With CONFIG_NR_CPUS=512 and !CONFIG_CPUMASK_OFFSTACK
# cat /sys/devices/virtual/net/lo/queues/rx-0/rps_cpus 00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000 # cat /proc/self/status | grep Cpus_allowed: Cpus_allowed: f
With CONFIG_NR_CPUS=1024 and CONFIG_CPUMASK_OFFSTACK (fedora default)
# cat /sys/devices/virtual/net/lo/queues/rx-0/rps_cpus 0 # cat /proc/self/status | grep Cpus_allowed: Cpus_allowed: f
Note that /proc/self/status is always using nr_cpu_ids regardless of config. This is because seq cpumask formattings functions always use nr_cpu_ids.
Given that the same output fields may switch between the two forms, converging on nr_cpu_ids always isn't too likely to surprise userland. This patch updates the formatting and parsing functions in cpumask.h to always use nr_cpu_ids. There's no point in dealing with CPUs which aren't even possible on the machine.
---
Hello,
Linus, this is the first of the three pre-requisite patches to convert the users of the dedicated bitmap formatting functions over to '%*pb[l]' formatting.
If this approach is agreed upon, I think it'd be best to route these three patches through mainline soon so that subsystem conversion patches can pull these in and apply per-subsystem conversion patches.
Thanks.
include/linux/cpumask.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
include/linux/cpumask.h +7 -7
@@ -550,7 +550,7 @@ static inline void cpumask_copy(struct cpumask *dstp,static inline int cpumask_scnprintf (char *buf,int len,const struct cpumask *srcp) { -return bitmap_scnprintf (buf, len,cpumask_bits (srcp), nr_cpumask_bits); +return bitmap_scnprintf (buf, len,cpumask_bits (srcp), nr_cpu_ids); }/**
@@ -564,7 +564,7 @@ static inline int cpumask_scnprintf(char *buf, int len,static inline int cpumask_parse_user (const char __user *buf,int len,struct cpumask *dstp) { -return bitmap_parse_user (buf, len,cpumask_bits (dstp), nr_cpumask_bits); +return bitmap_parse_user (buf, len,cpumask_bits (dstp), nr_cpu_ids); }/**
@@ -579,7 +579,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len, struct cpumask *dstp) {return bitmap_parselist_user (buf, len,cpumask_bits (dstp), - nr_cpumask_bits); + nr_cpu_ids); }/**
@@ -595,7 +595,7 @@ static inline int cpulist_scnprintf(char *buf, int len, const struct cpumask *srcp) {return bitmap_scnlistprintf (buf, len,cpumask_bits (srcp), - nr_cpumask_bits); + nr_cpu_ids); }/**
@@ -610,7 +610,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)char *nl =strchr (buf,'\n' );unsigned int len = nl ? (unsigned int )(nl - buf) :strlen (buf); -return bitmap_parse (buf, len,cpumask_bits (dstp), nr_cpumask_bits); +return bitmap_parse (buf, len,cpumask_bits (dstp), nr_cpu_ids); }/**
@@ -622,7 +622,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)*/ static inline int cpulist_parse (const char *buf,struct cpumask *dstp) { -return bitmap_parselist (buf,cpumask_bits (dstp), nr_cpumask_bits); +return bitmap_parselist (buf,cpumask_bits (dstp), nr_cpu_ids); }/**
@@ -817,7 +817,7 @@ static inline ssize_t cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask) { return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask), - nr_cpumask_bits); + nr_cpu_ids); }/*
Signature · 1 line
2.1.0
Re: [PATCH 01/32] cpumask: always use nr_cpu_ids in formatting and parsing functions
Quoted 4 lines · Tejun Heo
Currently, the formatting and parsing functions in
cpumask.husenr_cpumask_bitslike other cpumask functions; however,nr_cpumask_bitsis eitherNR_CPUSornr_cpu_idsdepending onCONFIG_CPUMASK_OFFSTACK. This leads to inconsistent behaviors.
Thanks!
Rusty.
Quoted 114 lines
With
CONFIG_NR_CPUS=512and !CONFIG_CPUMASK_OFFSTACK# cat /sys/devices/virtual/net/lo/queues/rx-0/rps_cpus 00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000 # cat /proc/self/status | grep Cpus_allowed: Cpus_allowed: fWith
CONFIG_NR_CPUS=1024andCONFIG_CPUMASK_OFFSTACK(fedora default)# cat /sys/devices/virtual/net/lo/queues/rx-0/rps_cpus 0 # cat /proc/self/status | grep Cpus_allowed: Cpus_allowed: fNote that
/proc/self/statusis always usingnr_cpu_idsregardless of config. This is because seq cpumask formattings functions always usenr_cpu_ids.Given that the same output fields may switch between the two forms, converging on
nr_cpu_idsalways isn't too likely to surprise userland. This patch updates the formatting and parsing functions incpumask.hto always usenr_cpu_ids. There's no point in dealing with CPUs which aren't even possible on the machine.Signed-off-by Tejun Heo <[email protected]>Cc Andrew Morton <[email protected]>Cc Linus Torvalds <[email protected]>Cc Rusty Russell <[email protected]>---
Hello,Linus, this is the first of the three pre-requisite patches to convert the users of the dedicated bitmap formatting functions over to '%*pb[l]' formatting.
If this approach is agreed upon, I think it'd be best to route these three patches through mainline soon so that subsystem conversion patches can pull these in and apply per-subsystem conversion patches.
Thanks.
include/linux/cpumask.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)include/linux/cpumask.h +7
-7@@ -550,7 +550,7 @@ static inline void cpumask_copy(struct cpumask *dstp,static inline int cpumask_scnprintf (char *buf,int len,const struct cpumask *srcp) { -return bitmap_scnprintf (buf, len,cpumask_bits (srcp), nr_cpumask_bits); +return bitmap_scnprintf (buf, len,cpumask_bits (srcp), nr_cpu_ids); }/** @@ -564,7 +564,7 @@ static inline int cpumask_scnprintf(char *buf, int len,static inline int cpumask_parse_user (const char __user *buf,int len,struct cpumask *dstp) { -return bitmap_parse_user (buf, len,cpumask_bits (dstp), nr_cpumask_bits); +return bitmap_parse_user (buf, len,cpumask_bits (dstp), nr_cpu_ids); }/** @@ -579,7 +579,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len, struct cpumask *dstp) {return bitmap_parselist_user (buf, len,cpumask_bits (dstp), - nr_cpumask_bits); + nr_cpu_ids); }/** @@ -595,7 +595,7 @@ static inline int cpulist_scnprintf(char *buf, int len, const struct cpumask *srcp) {return bitmap_scnlistprintf (buf, len,cpumask_bits (srcp), - nr_cpumask_bits); + nr_cpu_ids); }/** @@ -610,7 +610,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)char *nl =strchr (buf,'\n' );unsigned int len = nl ? (unsigned int )(nl - buf) :strlen (buf); -return bitmap_parse (buf, len,cpumask_bits (dstp), nr_cpumask_bits); +return bitmap_parse (buf, len,cpumask_bits (dstp), nr_cpu_ids); }/** @@ -622,7 +622,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)*/ static inline int cpulist_parse (const char *buf,struct cpumask *dstp) { -return bitmap_parselist (buf,cpumask_bits (dstp), nr_cpumask_bits); +return bitmap_parselist (buf,cpumask_bits (dstp), nr_cpu_ids); }/** @@ -817,7 +817,7 @@ static inline ssize_t cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask) { return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask), - nr_cpumask_bits); + nr_cpu_ids); }/* Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 2/32 lib/vsprintf: implement bitmap printing through '%*pb[l]'
In reply to Tejun Heobitmap and its derivatives such as cpumask and nodemask currently only provide formatting functions which put the output string into the provided buffer; however, how long this buffer should be isn't defined anywhere and given that some of these bitmaps can be too large to be formatted into an on-stack buffer it users sometimes are unnecessarily forced to come up with creative solutions and compromises for the buffer just to printk these bitmaps.
There have been a couple different attempts at making this easier.
1. Way back, PeterZ tried printk '%pb' extension with the precision for bit width - '%.*pb'. This was intuitive and made sense but unfortunately triggered a compile warning about using precision for a pointer.
http://lkml.kernel.org/g/1336577562.2527.58.camel@twins
2. I implemented bitmap_pr_cont[_list]() and its wrappers for cpumask and nodemask. This works but PeterZ pointed out that pr_cont's tendency to produce broken lines when multiple CPUs are printing is bothering considering the usages.
http://lkml.kernel.org/g/[email protected]
So, this patch is another attempt at teaching printk and friends how to print bitmaps. It's almost identical to what PeterZ tried with precision but it uses the field width for the number of bits instead of precision. The format used is '%*pb[l]', with the optional trailing 'l' specifying list format instead of hex masks.
This is a valid format string and doesn't trigger compiler warnings; however, it does make it impossible to specify output field width when printing bitmaps. I think this is an acceptable trade-off given how much easier it makes printing bitmaps and that we don't have any in-kernel user which is using the field width specification. If any future user wants to use field width with a bitmap, it'd have to format the bitmap into a string buffer and then print that buffer with width spec, which isn't different from how it should be done now.
This patch implements bitmap[_list]_string() which are called from the vsprintf pointer() formatting function. The implementation is mostly identical to bitmap_scn[list]printf() except that the output is performed in the vsprintf way. These functions handle formatting into too small buffers and sprintf() family of functions report the correct overrun output length.
bitmap_scn[list]printf() are now thin wrappers around scnprintf().
---
Hello,
Linus, this is the second of the three pre-requisite patches to convert the users of the dedicated bitmap formatting functions over to '%*pb[l]' formatting and actually implements the formatting.
If this approach is agreed upon, I think it'd be best to route these three patches through mainline soon so that subsystem conversion patches can pull these in and apply per-subsystem conversion patches.
Thanks.
lib/bitmap.c | 61 ++----------------------------------- lib/vsprintf.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 59 deletions(-)
lib/bitmap.c +2 -59
@@ -390,28 +390,7 @@ EXPORT_SYMBOL(bitmap_find_next_zero_area_off);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 =ALIGN (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; +return scnprintf (buf, buflen,"%*pb" , nmaskbits, maskp); }EXPORT_SYMBOL (bitmap_scnprintf);
@@ -528,25 +507,6 @@ int bitmap_parse_user(const char __user *ubuf, }EXPORT_SYMBOL (bitmap_parse_user); -/* -* 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 was written to *buf, excluding the -* trailing \0. -*/ -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
@@ -566,24 +526,7 @@ static inline int bscnl_emit(char *buf, int buflen, int rbot, int rtop, int len)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; - -if (buflen ==0 ) -return 0 ; - buf[0 ] =0 ; - - 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; - } - } -return len; +return scnprintf (buf, buflen,"%*pbl" , nmaskbits, maskp); }EXPORT_SYMBOL (bitmap_scnlistprintf);
lib/vsprintf.c +94 -0
118 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [PATCH 02/32] lib/vsprintf: implement bitmap printing through '%*pb[l]'
Quoted 15 lines · Tejun Heo
There have been a couple different attempts at making this easier.
1. Way back, PeterZ tried printk '%pb' extension with the precision for bit width - '%.*pb'. This was intuitive and made sense but unfortunately triggered a compile warning about using precision for a pointer.
http://lkml.kernel.org/g/1336577562.2527.58.camel@twinsSo, this patch is another attempt at teaching printk and friends how to print bitmaps. It's almost identical to what PeterZ tried with precision but it uses the field width for the number of bits instead of precision. The format used is '%*pb[l]', with the optional trailing 'l' specifying list format instead of hex masks.
Quoted 7 lines
This is a valid format string and doesn't trigger compiler warnings; however, it does make it impossible to specify output field width when printing bitmaps.
I think this is an acceptable trade-off given how
much easier it makes printing bitmaps and that we don't have any in-kernel user which is using the field width specification.
Yeah, I suppose this is indeed the best we can do; and loosing the width thing (which is a rarely used feature for in kernel things) seems acceptable indeed. We did mention the option back then, but didn't pursue it.
I like the extra 'l' fmt option.
Quoted 1 line
Signed-off-by Tejun Heo <[email protected]>
Tejun Heo
maintainerPATCH 3/32 cpumask, nodemask: implement cpumask/nodemask_pr_args()
In reply to Tejun Heoprintf family of functions can now format bitmaps using '%*pb[l]' and all cpumask and nodemask formatting will be converted to use it. To ease printing these masks with '%*pb[l]' which require two params - the number of bits and the actual bitmap, this patch implement cpumask_pr_args() and nodemask_pr_args() which can be used to provide arguments for '%*pb[l]'
---
Hello,
Linus, this is the third of the three pre-requisite patches to convert the users of the dedicated bitmap formatting functions over to '%*pb[l]' formatting and actually implements the formatting.
If this approach is agreed upon, I think it'd be best to route these three patches through mainline soon so that subsystem conversion patches can pull these in and apply per-subsystem conversion patches.
Thanks.
include/linux/cpumask.h | 8 ++++++++ include/linux/nodemask.h | 8 ++++++++ 2 files changed, 16 insertions(+)
include/linux/cpumask.h +8 -0
@@ -22,6 +22,14 @@ typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;*/ #define cpumask_bits (maskp) ((maskp)->bits) +/** +* cpumask_pr_args - printf args to output a cpumask +* @maskp: cpumask to be printed +* +* Can be used to provide arguments for '%*pb[l]' when printing a cpumask. +*/ +#define cpumask_pr_args (maskp) nr_cpu_ids, cpumask_bits(maskp) +#if NR_CPUS ==1 #define nr_cpu_ids 1#else
include/linux/nodemask.h +8 -0
@@ -98,6 +98,14 @@ typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;extern nodemask_t _unused_nodemask_arg_; +/** +* nodemask_pr_args - printf args to output a nodemask +* @maskp: nodemask to be printed +* +* Can be used to provide arguments for '%*pb[l]' when printing a nodemask. +*/ +#define nodemask_pr_args (maskp) MAX_NUMNODES, (maskp)->bits +/* * The inline keyword gives the compiler room to decide to inline, or * not inline a function as it sees best. However, as these functions
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 4/32 bitmap: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- lib/bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bitmap.c +2 -2
@@ -548,8 +548,8 @@ int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,int n =0 ;if (len >1 ) { - n = list ?bitmap_scnlistprintf (buf, len, maskp, nmaskbits) : -bitmap_scnprintf (buf, len, maskp, nmaskbits); + n = list ?scnprintf (buf, len,"%*pbl" , nmaskbits, maskp) : +scnprintf (buf, len,"%*pb" , nmaskbits, maskp); buf[n++] ='\n' ; buf[n] ='\0' ; }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 5/32 mips: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- arch/mips/netlogic/common/smp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
arch/mips/netlogic/common/smp.c +5 -8
@@ -162,7 +162,6 @@ void __init nlm_smp_setup(void)unsigned int boot_cpu;int num_cpus, i, ncore, node;volatile u32 *cpu_ready =nlm_get_boot_data (BOOT_CPU_READY ); -char buf[64 ]; boot_cpu =hard_smp_processor_id ();cpumask_clear (&phys_cpu_present_mask);
@@ -189,10 +188,10 @@ void __init nlm_smp_setup(void) } } -cpumask_scnprintf (buf,ARRAY_SIZE (buf), &phys_cpu_present_mask); -pr_info ("Physical CPU mask: %s\n" , buf); -cpumask_scnprintf (buf,ARRAY_SIZE (buf), cpu_possible_mask); -pr_info ("Possible CPU mask: %s\n" , buf); +pr_info ("Physical CPU mask: %*pb\n" , +cpumask_pr_args (&phys_cpu_present_mask)); +pr_info ("Possible CPU mask: %*pb\n" , +cpumask_pr_args (cpu_possible_mask));/* check with the cores we have woken up */ for (ncore =0 , i =0 ; i <NLM_NR_NODES ; i++)
@@ -209,7 +208,6 @@ static int nlm_parse_cpumask(cpumask_t *wakeup_mask) {uint32_t core0_thr_mask, core_thr_mask;int threadmode, i, j; -char buf[64 ]; core0_thr_mask =0 ;for (i =0 ; i <NLM_THREADS_PER_CORE ; i++)
@@ -244,8 +242,7 @@ static int nlm_parse_cpumask(cpumask_t *wakeup_mask)return threadmode; unsupp: -cpumask_scnprintf (buf,ARRAY_SIZE (buf), wakeup_mask); -panic ("Unsupported CPU mask %s" , buf); +panic ("Unsupported CPU mask %*pb" ,cpumask_pr_args (wakeup_mask));return 0 ; }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 6/32 powerpc: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* Spurious if (len > 1) test dropped from shared_cpu_map_show().
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- arch/powerpc/kernel/cacheinfo.c | 15 ++++++--------- arch/powerpc/sysdev/xics/ics-opal.c | 6 ++---- arch/powerpc/sysdev/xics/ics-rtas.c | 7 ++----- 3 files changed, 10 insertions(+), 18 deletions(-)
arch/powerpc/kernel/cacheinfo.c +6 -9
@@ -607,19 +607,16 @@ static ssize_t shared_cpu_map_show(struct kobject *k, struct kobj_attribute *att {struct cache_index_dir *index;struct cache *cache; -int len; -int n =0 ; +int ret; index =kobj_to_cache_index_dir (k); cache = index->cache; - len =PAGE_SIZE -2 ; -if (len >1 ) { - n =cpumask_scnprintf (buf, len, &cache->shared_cpu_map); - buf[n++] ='\n' ; - buf[n] ='\0' ; - } -return n; + ret =scnprintf (buf,PAGE_SIZE -1 ,"%*pb\n" , +cpumask_pr_args (&cache->shared_cpu_map)); + buf[ret++] ='\n' ; + buf[ret] ='\0' ; +return ret; } static struct kobj_attribute cache_shared_cpu_map_attr =
arch/powerpc/sysdev/xics/ics-opal.c +2 -4
@@ -131,10 +131,8 @@ static int ics_opal_set_affinity(struct irq_data *d, wanted_server =xics_get_irq_server (d->irq, cpumask,1 );if (wanted_server <0 ) { -char cpulist[128 ]; -cpumask_scnprintf (cpulist,sizeof (cpulist), cpumask); -pr_warning ("%s: No online cpus in the mask %s for irq %d\n" , - __func__, cpulist, d->irq); +pr_warning ("%s: No online cpus in the mask %*pb for irq %d\n" , + __func__,cpumask_pr_args (cpumask), d->irq);return -1 ; } server =ics_opal_mangle_server (wanted_server);
arch/powerpc/sysdev/xics/ics-rtas.c +2 -5
@@ -140,11 +140,8 @@ static int ics_rtas_set_affinity(struct irq_data *d, irq_server =xics_get_irq_server (d->irq, cpumask,1 );if (irq_server ==-1 ) { -char cpulist[128 ]; -cpumask_scnprintf (cpulist,sizeof (cpulist), cpumask); -printk (KERN_WARNING -"%s: No online cpus in the mask %s for irq %d\n" , - __func__, cpulist, d->irq); +pr_warning ("%s: No online cpus in the mask %*pb for irq %d\n" , + __func__,cpumask_pr_args (cpumask), d->irq);return -1 ; }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 7/32 s390: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* Line termination only requires one extra space at the end of the buffer. Use PAGE_SIZE - 1 instead of PAGE_SIZE - 2 when formatting.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- arch/s390/kernel/cache.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/s390/kernel/cache.c +6 -3
@@ -243,9 +243,12 @@ static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char *buf)int len; index =kobj_to_cache_index_dir (kobj); - len = type ? -cpulist_scnprintf (buf,PAGE_SIZE -2 ,cpumask_of (index->cpu)) : -cpumask_scnprintf (buf,PAGE_SIZE -2 ,cpumask_of (index->cpu)); +if (type) + len =scnprintf (buf,PAGE_SIZE -1 ,"%*pbl" , +cpumask_pr_args (cpumask_of (index->cpu))); +else + len =scnprintf (buf,PAGE_SIZE -1 ,"%*pb" , +cpumask_pr_args (cpumask_of (index->cpu))); len +=sprintf (&buf[len],"\n" );return len; }
Signature · 1 line
2.1.0
Re: [PATCH 07/32] s390: use %*pb[l] to print bitmaps including cpumasks and nodemasks
Quoted 34 lines · Tejun Heo
printk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide
cpumask_pr_args()andnodemask_pr_args()respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.* Line termination only requires one extra space at the end of the buffer. Use
PAGE_SIZE- 1 instead ofPAGE_SIZE- 2 when formatting.This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
Signed-off-by Tejun Heo <[email protected]>Cc Andrew Morton <[email protected]>Cc Martin Schwidefsky <[email protected]>Cc Heiko Carstens <[email protected]>--- arch/s390/kernel/cache.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)arch/s390/kernel/cache.c +0
-2@@ -243,9 +243,12 @@ static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char *buf)int len; index =kobj_to_cache_index_dir (kobj); - len = type ? - cpulist_scnprintf(buf, PAGE_SIZE - 2, cpumask_of(index->cpu)) :
arch/s390/kernel/cache.c static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char *buf) · line 254
Quoted 10 lines
arch/s390/kernel/cache.c +6
-1-cpumask_scnprintf (buf,PAGE_SIZE -2 ,cpumask_of (index->cpu)); +if (type) + len =scnprintf (buf,PAGE_SIZE -1 ,"%*pbl" , +cpumask_pr_args (cpumask_of (index->cpu))); +else + len =scnprintf (buf,PAGE_SIZE -1 ,"%*pb" , +cpumask_pr_args (cpumask_of (index->cpu))); len +=sprintf (&buf[len],"\n" );return len; }
Hi Tejun,
this code will be removed during the next merge window, because we move s390 to the generic cacheinfo infrastructure in drivers/base/cacheinfo.c. (see linux-next)
So you can drop this patch.
Thanks,
Heiko
Tejun Heo
maintainerPATCH 8/32 tile: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- arch/tile/kernel/hardwall.c | 5 +---- arch/tile/kernel/proc.c | 5 ++--- arch/tile/kernel/setup.c | 13 +++++-------- arch/tile/mm/homecache.c | 12 +++++------- arch/tile/mm/init.c | 18 +++++++----------- drivers/net/ethernet/tile/tilegx.c | 5 ++--- drivers/net/ethernet/tile/tilepro.c | 5 ++--- 7 files changed, 24 insertions(+), 39 deletions(-)
arch/tile/kernel/hardwall.c +1 -4
@@ -909,11 +909,8 @@ static void hardwall_destroy(struct hardwall_info *info)static int hardwall_proc_show (struct seq_file *sf,void *v) {struct hardwall_info *info = sf->private; -char buf[256 ]; -int rc =cpulist_scnprintf (buf,sizeof (buf), &info->cpumask); - buf[rc++] ='\n' ; -seq_write (sf, buf, rc); +seq_printf (sf,"%*pbl\n" ,cpumask_pr_args (&info->cpumask));return 0 ; }
arch/tile/kernel/proc.c +2 -3
@@ -45,10 +45,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)int n =ptr_to_cpu (v);if (n ==0 ) { -char buf[NR_CPUS *5 ]; -cpulist_scnprintf (buf,sizeof (buf), cpu_online_mask);seq_printf (m,"cpu count\t: %d\n" ,num_online_cpus ()); -seq_printf (m,"cpu list\t: %s\n" , buf); +seq_printf (m,"cpu list\t: %*pbl\n" , +cpumask_pr_args (cpu_online_mask));seq_printf (m,"model name\t: %s\n" , chip_model);seq_printf (m,"flags\t\t:\n" );/* nothing for now */ seq_printf(m, "cpu MHz\t\t: %llu.%06llu\n",
arch/tile/kernel/setup.c +5 -8
@@ -215,12 +215,11 @@ early_param("mem", setup_mem); /* compatibility with x86 */static int __init setup_isolnodes (char *str) { -char buf[MAX_NUMNODES *5 ];if (str ==NULL ||nodelist_parse (str, isolnodes) !=0 )return -EINVAL ; -nodelist_scnprintf (buf,sizeof (buf), isolnodes); -pr_info ("Set isolnodes value to '%s'\n" , buf); +pr_info ("Set isolnodes value to '%*pbl'\n" , +nodemask_pr_args (&isolnodes));return 0 ; }early_param ("isolnodes" , setup_isolnodes);
@@ -1315,11 +1314,9 @@ early_param("disabled_cpus", disabled_cpus);void __init print_disabled_cpus (void ) { -if (!cpumask_empty (&disabled_map)) { -char buf[100 ]; -cpulist_scnprintf (buf,sizeof (buf), &disabled_map); -pr_info ("CPUs not available for Linux: %s\n" , buf); - } +if (!cpumask_empty (&disabled_map)) +pr_info ("CPUs not available for Linux: %*pbl\n" , +cpumask_pr_args (&disabled_map)); }static void __init setup_cpu_maps (void )
arch/tile/mm/homecache.c +5 -7
@@ -115,7 +115,6 @@ void flush_remote(unsigned long cache_pfn, unsigned long cache_control,struct cpumask cache_cpumask_copy, tlb_cpumask_copy;struct cpumask *cache_cpumask, *tlb_cpumask;HV_PhysAddr cache_pa; -char cache_buf[NR_CPUS *5 ], tlb_buf[NR_CPUS *5 ];mb ();/* provided just to simplify "magic hypervisor" mode */
@@ -149,13 +148,12 @@ void flush_remote(unsigned long cache_pfn, unsigned long cache_control, asids, asidcount);if (rc ==0 )return ; -cpumask_scnprintf (cache_buf,sizeof (cache_buf), &cache_cpumask_copy); -cpumask_scnprintf (tlb_buf,sizeof (tlb_buf), &tlb_cpumask_copy); -pr_err ("hv_flush_remote(%#llx, %#lx, %p [%s], %#lx, %#lx, %#lx, %p [%s], %p, %d) = %d\n" , - cache_pa, cache_control, cache_cpumask, cache_buf, - (unsigned long )tlb_va, tlb_length, tlb_pgsize, - tlb_cpumask, tlb_buf, asids, asidcount, rc); +pr_err ("hv_flush_remote(%#llx, %#lx, %p [%*pb], %#lx, %#lx, %#lx, %p [%*pb], %p, %d) = %d\n" , + cache_pa, cache_control, cache_cpumask, +cpumask_pr_args (&cache_cpumask_copy), + (unsigned long )tlb_va, tlb_length, tlb_pgsize, tlb_cpumask, +cpumask_pr_args (&tlb_cpumask_copy), asids, asidcount, rc);panic ("Unsafe to continue." ); }
arch/tile/mm/init.c +7 -11
@@ -353,15 +353,13 @@ static int __init setup_ktext(char *str)/* Neighborhood ktext pages on specified mask */ else if (cpulist_parse(str, &ktext_mask) == 0) { -char buf[NR_CPUS *5 ]; -cpulist_scnprintf (buf,sizeof (buf), &ktext_mask);if (cpumask_weight (&ktext_mask) >1 ) { ktext_small =1 ; -pr_info ("ktext: using caching neighborhood %s with small pages\n" , - buf); +pr_info ("ktext: using caching neighborhood %*pbl with small pages\n" , +cpumask_pr_args (&ktext_mask)); }else { -pr_info ("ktext: caching on cpu %s with one huge page\n" , - buf); +pr_info ("ktext: caching on cpu %*pbl with one huge page\n" , +cpumask_pr_args (&ktext_mask)); } }
@@ -492,11 +490,9 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base)struct cpumask bad;cpumask_andnot (&bad, &ktext_mask, cpu_possible_mask);cpumask_and (&ktext_mask, &ktext_mask, cpu_possible_mask); -if (!cpumask_empty (&bad)) { -char buf[NR_CPUS *5 ]; -cpulist_scnprintf (buf,sizeof (buf), &bad); -pr_info ("ktext: not using unavailable cpus %s\n" , buf); - } +if (!cpumask_empty (&bad)) +pr_info ("ktext: not using unavailable cpus %*pbl\n" , +cpumask_pr_args (&bad));if (cpumask_empty (&ktext_mask)) {pr_warn ("ktext: no valid cpus; caching on %d\n" ,smp_processor_id ());
drivers/net/ethernet/tile/tilegx.c +2 -3
@@ -292,7 +292,6 @@ static inline int mpipe_instance(struct net_device *dev)*/ static bool network_cpus_init (void ) { -char buf[1024 ];int rc;if (network_cpus_string ==NULL )
@@ -314,8 +313,8 @@ static bool network_cpus_init(void)return false; } -cpulist_scnprintf (buf,sizeof (buf), &network_cpus_map); -pr_info ("Linux network CPUs: %s\n" , buf); +pr_info ("Linux network CPUs: %*pbl\n" , +cpumask_pr_args (&network_cpus_map));return true; }
drivers/net/ethernet/tile/tilepro.c +2 -3
@@ -2410,9 +2410,8 @@ static int __init network_cpus_setup(char *str)if (cpumask_empty (&network_cpus_map)) {pr_warn ("Ignoring network_cpus='%s'\n" , str); }else { -char buf[1024 ]; -cpulist_scnprintf (buf,sizeof (buf), &network_cpus_map); -pr_info ("Linux network CPUs: %s\n" , buf); +pr_info ("Linux network CPUs: %*pbl\n" , +cpumask_pr_args (&network_cpus_map)); network_cpus_used = true; } }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 9/32 x86: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* Unnecessary buffer size calculation and condition on the lenght removed from intel_cacheinfo.c::show_shared_cpu_map_func().
* uv_nmi_nr_cpus_pr() got overly smart and implemented "..." abbreviation if the output stretched over the predefined 1024 byte buffer. Replaced with plain printk.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- arch/x86/kernel/cpu/intel_cacheinfo.c | 26 ++++++++++++-------------- arch/x86/mm/numa.c | 6 ++---- arch/x86/platform/uv/uv_nmi.c | 25 +++++++------------------ 3 files changed, 21 insertions(+), 36 deletions(-)
arch/x86/kernel/cpu/intel_cacheinfo.c +12 -14
@@ -952,20 +952,18 @@ static ssize_t show_size(struct _cpuid4_info *this_leaf, char *buf,static ssize_t show_shared_cpu_map_func (struct _cpuid4_info *this_leaf,int type,char *buf) { -ptrdiff_t len =PTR_ALIGN (buf +PAGE_SIZE -1 ,PAGE_SIZE ) - buf; -int n =0 ; - -if (len >1 ) { -const struct cpumask *mask; - - mask =to_cpumask (this_leaf->shared_cpu_map); - n = type ? -cpulist_scnprintf (buf, len-2 , mask) : -cpumask_scnprintf (buf, len-2 , mask); - buf[n++] ='\n' ; - buf[n] ='\0' ; - } -return n; +const struct cpumask *mask =to_cpumask (this_leaf->shared_cpu_map); +int ret; + +if (type) + ret =scnprintf (buf,PAGE_SIZE -1 ,"%*pbl" , +cpumask_pr_args (mask)); +else + ret =scnprintf (buf,PAGE_SIZE -1 ,"%*pb" , +cpumask_pr_args (mask)); + buf[ret++] ='\n' ; + buf[ret] ='\0' ; +return ret; } static inline ssize_t show_shared_cpu_map(struct _cpuid4_info *leaf, char *buf,
arch/x86/mm/numa.c +2 -4
@@ -794,7 +794,6 @@ int early_cpu_to_node(int cpu)void debug_cpumask_set_cpu (int cpu,int node,bool enable) {struct cpumask *mask; -char buf[64 ];if (node ==NUMA_NO_NODE ) {/* early_cpu_to_node() already emits a warning and trace */
@@ -812,10 +811,9 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable)else cpumask_clear_cpu (cpu, mask); -cpulist_scnprintf (buf,sizeof (buf), mask); -printk (KERN_DEBUG "%s cpu %d node %d: mask now %s\n" , +printk (KERN_DEBUG "%s cpu %d node %d: mask now %*pbl\n" , enable ?"numa_add_cpu" :"numa_remove_cpu" , - cpu, node, buf); + cpu, node,cpumask_pr_args (mask));return ; }
arch/x86/platform/uv/uv_nmi.c +7 -18
@@ -273,20 +273,6 @@ static inline void uv_clear_nmi(int cpu) } } -/* Print non-responding cpus */ -static void uv_nmi_nr_cpus_pr (char *fmt) -{ -static char cpu_list[1024 ]; -int len =sizeof (cpu_list); -int c =cpumask_weight (uv_nmi_cpu_mask); -int n =cpulist_scnprintf (cpu_list, len, uv_nmi_cpu_mask); - -if (n >= len-1 ) -strcpy (&cpu_list[len -6 ],"...\n" ); - -printk (fmt, c, cpu_list); -} -/* Ping non-responding cpus attemping to force them into the NMI handler */ static void uv_nmi_nr_cpus_ping (void ) {
@@ -371,16 +357,19 @@ static void uv_nmi_wait(int master)break ;/* if not all made it in, send IPI NMI to them */ -uv_nmi_nr_cpus_pr (KERN_ALERT -"UV: Sending NMI IPI to %d non-responding CPUs: %s\n" ); +pr_alert ("UV: Sending NMI IPI to %d non-responding CPUs: %*pbl\n" , +cpumask_weight (uv_nmi_cpu_mask), +cpumask_pr_args (uv_nmi_cpu_mask)); +uv_nmi_nr_cpus_ping ();/* if all cpus are in, then done */ if (!uv_nmi_wait_cpus (0 ))break ; -uv_nmi_nr_cpus_pr (KERN_ALERT -"UV: %d CPUs not in NMI loop: %s\n" ); +pr_alert ("UV: %d CPUs not in NMI loop: %*pbl\n" , +cpumask_weight (uv_nmi_cpu_mask), +cpumask_pr_args (uv_nmi_cpu_mask)); }while (0 ); pr_alert("UV: %d of %d CPUs in NMI\n",
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 10/32 ia64: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- arch/ia64/kernel/topology.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/ia64/kernel/topology.c +2 -4
@@ -217,14 +217,12 @@ static ssize_t show_number_of_sets(struct cache_info *this_leaf, char *buf)static ssize_t show_shared_cpu_map (struct cache_info *this_leaf,char *buf) { -ssize_t len;cpumask_t shared_cpu_map;cpumask_and (&shared_cpu_map, &this_leaf->shared_cpu_map, cpu_online_mask); - len =cpumask_scnprintf (buf,NR_CPUS +1 , &shared_cpu_map); - len +=sprintf (buf+len,"\n" ); -return len; +return scnprintf (buf,PAGE_SIZE ,"%*pb\n" , +cpumask_pr_args (&shared_cpu_map)); }static ssize_t show_type (struct cache_info *this_leaf,char *buf)
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 11/32 xtensa: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- arch/xtensa/kernel/setup.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
arch/xtensa/kernel/setup.c +2 -5
@@ -574,12 +574,9 @@ void machine_power_off(void)static int c_show (struct seq_file *f,void *slot) { -char buf[NR_CPUS *5 ]; - -cpulist_scnprintf (buf,sizeof (buf), cpu_online_mask);/* high-level stuff */ seq_printf (f,"CPU count\t: %u\n" -"CPU list\t: %s\n" +"CPU list\t: %*pbl\n" "vendor_id\t: Tensilica\n" "model\t\t: Xtensa " XCHAL_HW_VERSION_NAME "\n" "core ID\t\t: " XCHAL_CORE_ID "\n"
@@ -588,7 +585,7 @@ c_show(struct seq_file *f, void *slot)"cpu MHz\t\t: %lu.%02lu\n" "bogomips\t: %lu.%02lu\n" ,num_online_cpus (), - buf, +cpumask_pr_args (cpu_online_mask),XCHAL_BUILD_UNIQUE_ID ,XCHAL_HAVE_BE ?"big" :"little" , ccount_freq/1000000,
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 12/32 arm: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* Line termination only requires one extra space at the end of the buffer. Use PAGE_SIZE - 1 instead of PAGE_SIZE - 2 when formatting.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- drivers/bus/arm-cci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/arm-cci.c +2 -2
@@ -806,8 +806,8 @@ static int cci_pmu_event_init(struct perf_event *event)static ssize_t pmu_attr_cpumask_show (struct device *dev,struct device_attribute *attr,char *buf) { -int n =cpulist_scnprintf (buf,PAGE_SIZE -2 , &pmu->cpus); - +int n =scnprintf (buf,PAGE_SIZE -1 ,"%*pbl" , +cpumask_pr_args (&pmu->cpus)); buf[n++] ='\n' ; buf[n] ='\0' ;return n;
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 13/32 cpuset: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* kernel/cpuset.c::cpuset_print_task_mems_allowed() used a static buffer which is protected by a dedicated spinlock. Removed.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/cpuset.c | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-)
kernel/cpuset.c +9 -33
@@ -1707,40 +1707,27 @@ static int cpuset_common_seq_show(struct seq_file *sf, void *v) {struct cpuset *cs =css_cs (seq_css (sf));cpuset_filetype_t type =seq_cft (sf)->private; -ssize_t count; -char *buf, *s;int ret =0 ; - count =seq_get_buf (sf, &buf); - s = buf; -spin_lock_irq (&callback_lock);switch (type) {case FILE_CPULIST : - s +=cpulist_scnprintf (s, count, cs->cpus_allowed); +seq_printf (sf,"%*pbl\n" ,cpumask_pr_args (cs->cpus_allowed));break ;case FILE_MEMLIST : - s +=nodelist_scnprintf (s, count, cs->mems_allowed); +seq_printf (sf,"%*pbl\n" ,nodemask_pr_args (&cs->mems_allowed));break ;case FILE_EFFECTIVE_CPULIST : - s +=cpulist_scnprintf (s, count, cs->effective_cpus); +seq_printf (sf,"%*pbl\n" ,cpumask_pr_args (cs->effective_cpus));break ;case FILE_EFFECTIVE_MEMLIST : - s +=nodelist_scnprintf (s, count, cs->effective_mems); +seq_printf (sf,"%*pbl\n" ,nodemask_pr_args (&cs->effective_mems));break ;default : ret = -EINVAL ; - goto out_unlock; } -if (s < buf + count -1 ) { - *s++ ='\n' ; -seq_commit (sf, s - buf); - }else { -seq_commit (sf,-1 ); - } -out_unlock:spin_unlock_irq (&callback_lock);return ret; }
@@ -2610,8 +2597,6 @@ int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,return nodes_intersects (tsk1->mems_allowed, tsk2->mems_allowed); } -#define CPUSET_NODELIST_LEN (256) -/** * cpuset_print_task_mems_allowed - prints task's cpuset and mems_allowed * @tsk: pointer to task_struct of some task.
@@ -2621,23 +2606,16 @@ int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,*/ void cpuset_print_task_mems_allowed (struct task_struct *tsk) { -/* Statically allocated to prevent using excess stack. */ -static char cpuset_nodelist[CPUSET_NODELIST_LEN ]; -static DEFINE_SPINLOCK (cpuset_buffer_lock);struct cgroup *cgrp; -spin_lock (&cpuset_buffer_lock);rcu_read_lock (); cgrp =task_cs (tsk)->css.cgroup; -nodelist_scnprintf (cpuset_nodelist,CPUSET_NODELIST_LEN , - tsk->mems_allowed);pr_info ("%s cpuset=" , tsk->comm);pr_cont_cgroup_name (cgrp); -pr_cont (" mems_allowed=%s\n" , cpuset_nodelist); +pr_cont (" mems_allowed=%*pbl\n" ,nodemask_pr_args (&tsk->mems_allowed));rcu_read_unlock (); -spin_unlock (&cpuset_buffer_lock); }/*
@@ -2715,10 +2693,8 @@ out:/* Display task mems_allowed in /proc/<pid>/status file. */ void cpuset_task_status_allowed (struct seq_file *m,struct task_struct *task) { -seq_puts (m,"Mems_allowed:\t" ); -seq_nodemask (m, &task->mems_allowed); -seq_puts (m,"\n" ); -seq_puts (m,"Mems_allowed_list:\t" ); -seq_nodemask_list (m, &task->mems_allowed); -seq_puts (m,"\n" ); +seq_printf (m,"Mems_allowed:\t%*pb\n" , +nodemask_pr_args (&task->mems_allowed)); +seq_printf (m,"Mems_allowed_list:\t%*pbl\n" , +nodemask_pr_args (&task->mems_allowed)); }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 14/32 rcu: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/rcu/tree_plugin.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/rcu/tree_plugin.h +2 -3
@@ -53,7 +53,6 @@ DEFINE_PER_CPU(char, rcu_cpu_has_work);static cpumask_var_t rcu_nocb_mask;/* CPUs to have callbacks offloaded. */ static bool have_rcu_nocb_mask;/* Was rcu_nocb_mask allocated? */ static bool __read_mostly rcu_nocb_poll;/* Offload kthread are to poll. */ -static char __initdata nocb_buf[NR_CPUS *5 ];#endif /* #ifdef CONFIG_RCU_NOCB_CPU */ /*
@@ -2513,8 +2512,8 @@ void __init rcu_init_nohz(void)cpumask_and (rcu_nocb_mask, cpu_possible_mask, rcu_nocb_mask); } -cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); -pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); +pr_info ("\tOffload RCU callbacks from CPUs: %*pbl.\n" , +cpumask_pr_args (rcu_nocb_mask));if (rcu_nocb_poll)pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" );
Signature · 1 line
2.1.0
Re: [PATCH 14/32] rcu: use %*pb[l] to print bitmaps including cpumasks and nodemasks
Quoted 10 lines · Tejun Heo
printk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide
cpumask_pr_args()andnodemask_pr_args()respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Quoted 6 lines
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
Signed-off-by Tejun Heo <[email protected]>Cc Andrew Morton <[email protected]>Cc "Paul E. McKenney" <[email protected]>
Nice!!! I would be happy to take these, if you would like. If so, please let me know when the two patches above hit mainline.
Thanx, Paul
Quoted 30 lines
--- kernel/rcu/tree_plugin.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)kernel/rcu/tree_plugin.h +2
-3@@ -53,7 +53,6 @@ DEFINE_PER_CPU(char, rcu_cpu_has_work);static cpumask_var_t rcu_nocb_mask;/* CPUs to have callbacks offloaded. */ static bool have_rcu_nocb_mask;/* Was rcu_nocb_mask allocated? */ static bool __read_mostly rcu_nocb_poll;/* Offload kthread are to poll. */ -static char __initdata nocb_buf[NR_CPUS *5 ];#endif /* #ifdef CONFIG_RCU_NOCB_CPU */ /* @@ -2513,8 +2512,8 @@ void __init rcu_init_nohz(void)cpumask_and (rcu_nocb_mask, cpu_possible_mask, rcu_nocb_mask); } -cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); -pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); +pr_info ("\tOffload RCU callbacks from CPUs: %*pbl.\n" , +cpumask_pr_args (rcu_nocb_mask));if (rcu_nocb_poll)pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" );Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 15/32 sched: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/sched/core.c | 10 ++++------ kernel/sched/stats.c | 11 ++--------- 2 files changed, 6 insertions(+), 15 deletions(-)
kernel/sched/core.c +4 -6
@@ -5408,9 +5408,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, struct cpumask *groupmask) {struct sched_group *group = sd->groups; -char str[256 ]; -cpulist_scnprintf (str,sizeof (str),sched_domain_span (sd));cpumask_clear (groupmask);printk (KERN_DEBUG "%*s domain %d: " , level,"" , level);
@@ -5423,7 +5421,8 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,return -1 ; } -printk (KERN_CONT "span %s level %s\n" , str, sd->name); +printk (KERN_CONT "span %*pbl level %s\n" , +cpumask_pr_args (sched_domain_span (sd)), sd->name);if (!cpumask_test_cpu (cpu,sched_domain_span (sd))) { printk(KERN_ERR "ERROR: domain->span does not contain "
@@ -5468,9 +5467,8 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,cpumask_or (groupmask, groupmask,sched_group_cpus (group)); -cpulist_scnprintf (str,sizeof (str),sched_group_cpus (group)); - -printk (KERN_CONT " %s" , str); +printk (KERN_CONT " %*pbl" , +cpumask_pr_args (sched_group_cpus (group)));if (group->sgc->capacity !=SCHED_CAPACITY_SCALE ) {printk (KERN_CONT " (cpu_capacity = %d)" , group->sgc->capacity);
kernel/sched/stats.c +2 -9
@@ -15,11 +15,6 @@static int show_schedstat (struct seq_file *seq,void *v) {int cpu; -int mask_len =DIV_ROUND_UP (NR_CPUS ,32 ) *9 ; -char *mask_str =kmalloc (mask_len,GFP_KERNEL ); - -if (mask_str ==NULL ) -return -ENOMEM ;if (v == (void *)1 ) {seq_printf (seq,"version %d\n" ,SCHEDSTAT_VERSION );
@@ -50,9 +45,8 @@ static int show_schedstat(struct seq_file *seq, void *v)for_each_domain (cpu, sd) {enum cpu_idle_type itype; -cpumask_scnprintf (mask_str, mask_len, -sched_domain_span (sd)); -seq_printf (seq,"domain%d %s" , dcount++, mask_str); +seq_printf (seq,"domain%d %*pb" , dcount++, +cpumask_pr_args (sched_domain_span (sd)));for (itype =CPU_IDLE ; itype <CPU_MAX_IDLE_TYPES ; itype++) { seq_printf(seq, " %u %u %u %u %u %u %u %u",
@@ -76,7 +70,6 @@ static int show_schedstat(struct seq_file *seq, void *v)rcu_read_unlock ();#endif } -kfree (mask_str);return 0 ; }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 16/32 time: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/time/tick-sched.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
kernel/time/tick-sched.c +2 -9
@@ -326,13 +326,6 @@ static int tick_nohz_cpu_down_callback(struct notifier_block *nfb,return NOTIFY_OK ; } -/* -* Worst case string length in chunks of CPU range seems 2 steps -* separations: 0,2,4,6,... -* This is NR_CPUS + sizeof('\0') -*/ -static char __initdata nohz_full_buf[NR_CPUS +1 ]; -static int tick_nohz_init_all (void ) {int err =-1 ;
@@ -393,8 +386,8 @@ void __init tick_nohz_init(void)context_tracking_cpu_set (cpu);cpu_notifier (tick_nohz_cpu_down_callback,0 ); -cpulist_scnprintf (nohz_full_buf,sizeof (nohz_full_buf), tick_nohz_full_mask); - pr_info("NO_HZ: Full dynticks CPUs: %s.\n", nohz_full_buf); +pr_info ("NO_HZ: Full dynticks CPUs: %*pbl.\n" , + cpumask_pr_args(tick_nohz_full_mask)); }#endif
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 17/32 percpu: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- mm/percpu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
mm/percpu.c +2 -4
@@ -1528,7 +1528,6 @@ static void pcpu_dump_alloc_info(const char *lvl,int __init pcpu_setup_first_chunk (const struct pcpu_alloc_info *ai,void *base_addr) { -static char cpus_buf[4096 ]__initdata ;static int smap[PERCPU_DYNAMIC_EARLY_SLOTS ]__initdata ;static int dmap[PERCPU_DYNAMIC_EARLY_SLOTS ]__initdata ;size_t dyn_size = ai->dyn_size;
@@ -1541,12 +1540,11 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,int *unit_map;int group, unit, i; -cpumask_scnprintf (cpus_buf,sizeof (cpus_buf), cpu_possible_mask); -#define PCPU_SETUP_BUG_ON (cond) do { \ if (unlikely(cond)) { \ pr_emerg("PERCPU: failed to initialize, %s", #cond); \ - pr_emerg("PERCPU: cpu_possible_mask=%s\n", cpus_buf); \ + pr_emerg("PERCPU: cpu_possible_mask=%*pb\n", \ + cpumask_pr_args(cpu_possible_mask)); \ pcpu_dump_alloc_info(KERN_EMERG, ai); \ BUG(); \ } \
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 18/32 workqueue: use %*pb[l] to format bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/workqueue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/workqueue.c +2 -3
@@ -3083,10 +3083,9 @@ static ssize_t wq_cpumask_show(struct device *dev,int written;mutex_lock (&wq->mutex); - written =cpumask_scnprintf (buf,PAGE_SIZE , wq->unbound_attrs->cpumask); + written =scnprintf (buf,PAGE_SIZE ,"%*pb\n" , +cpumask_pr_args (wq->unbound_attrs->cpumask));mutex_unlock (&wq->mutex); - - written +=scnprintf (buf + written,PAGE_SIZE - written,"\n" );return written; }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 19/32 tracing: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/trace/trace.c | 6 +++--- kernel/trace/trace_seq.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/trace/trace.c +3 -3
@@ -3352,12 +3352,12 @@ tracing_cpumask_read(struct file *filp, char __user *ubuf,mutex_lock (&tracing_cpumask_update_lock); - len =cpumask_scnprintf (mask_str, count, tr->tracing_cpumask); -if (count - len <2 ) { + len =snprintf (mask_str, count,"%*pb\n" , +cpumask_pr_args (tr->tracing_cpumask)); +if (len >= count) { count = -EINVAL ; goto out_err; } - len +=sprintf (mask_str + len,"\n" ); count =simple_read_from_buffer (ubuf, count, ppos, mask_str,NR_CPUS +1 ); out_err:
kernel/trace/trace_seq.c +1 -1
@@ -120,7 +120,7 @@ void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,__trace_seq_init (s); -seq_buf_bitmask (&s->seq, maskp, nmaskbits); +seq_buf_printf (&s->seq,"%*pb" , nmaskbits, maskp);if (unlikely (seq_buf_has_overflowed (&s->seq))) { s->seq.len = save_len;
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 20/32 net: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- net/core/net-sysfs.c | 28 +++++++--------------------- net/core/sysctl_net_core.c | 2 +- 2 files changed, 8 insertions(+), 22 deletions(-)
net/core/net-sysfs.c +7 -21
@@ -614,8 +614,7 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue, {struct rps_map *map;cpumask_var_t mask; -size_t len =0 ; -int i; +int i, len;if (!zalloc_cpumask_var (&mask,GFP_KERNEL ))return -ENOMEM ;
@@ -626,17 +625,11 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue,for (i =0 ; i < map->len; i++)cpumask_set_cpu (map->cpus[i], mask); - len +=cpumask_scnprintf (buf + len,PAGE_SIZE , mask); -if (PAGE_SIZE - len <3 ) { -rcu_read_unlock (); -free_cpumask_var (mask); -return -EINVAL ; - } + len =snprintf (buf,PAGE_SIZE ,"%*pb\n" ,cpumask_pr_args (mask));rcu_read_unlock (); -free_cpumask_var (mask); - len +=sprintf (buf + len,"\n" ); -return len; + +return len <PAGE_SIZE ? len : -EINVAL ; } static ssize_t store_rps_map(struct netdev_rx_queue *queue,
@@ -1090,8 +1083,7 @@ static ssize_t show_xps_map(struct netdev_queue *queue,struct xps_dev_maps *dev_maps;cpumask_var_t mask;unsigned long index; -size_t len =0 ; -int i; +int i, len;if (!zalloc_cpumask_var (&mask,GFP_KERNEL ))return -ENOMEM ;
@@ -1117,15 +1109,9 @@ static ssize_t show_xps_map(struct netdev_queue *queue, }rcu_read_unlock (); - len +=cpumask_scnprintf (buf + len,PAGE_SIZE , mask); -if (PAGE_SIZE - len <3 ) { -free_cpumask_var (mask); -return -EINVAL ; - } - + len =snprintf (buf,PAGE_SIZE ,"%*pb\n" ,cpumask_pr_args (mask));free_cpumask_var (mask); - len +=sprintf (buf + len,"\n" ); -return len; +return len <PAGE_SIZE ? len : -EINVAL ; } static ssize_t store_xps_map(struct netdev_queue *queue,
net/core/sysctl_net_core.c +1 -1
@@ -155,7 +155,7 @@ write_unlock:rcu_read_unlock (); len =min (sizeof (kbuf) -1 , *lenp); - len =cpumask_scnprintf (kbuf, len, mask); + len =scnprintf (kbuf, len,"%*pb" ,cpumask_pr_args (mask));if (!len) { *lenp =0 ; goto done;
Signature · 1 line
2.1.0
Re: [PATCH 20/32] net: use %*pb[l] to print bitmaps including cpumasks and nodemasks
From: Tejun Heo <[email protected]>
Date: Sat, 24 Jan 2015 09:03:26 -0500
Quoted 7 lines
printk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide
cpumask_pr_args()andnodemask_pr_args()respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.This patch is dependent on the following two patches.
Quoted 7 lines
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
Signed-off-by Tejun Heo <[email protected]>
Please just apply this directly with those prerequisites, thanks:
Tejun Heo
maintainerPATCH 21/32 wireless: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- drivers/net/wireless/ath/ath9k/htc_drv_debug.c | 23 ++++++----------------- drivers/net/wireless/ath/carl9170/debug.c | 24 ++++++------------------ 2 files changed, 12 insertions(+), 35 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_debug.c +6 -17
@@ -291,26 +291,15 @@ static ssize_t read_file_slot(struct file *file, char __user *user_buf, {struct ath9k_htc_priv *priv = file->private_data;char buf[512 ]; -unsigned int len =0 ; +unsigned int len;spin_lock_bh (&priv->tx.tx_lock); - - len +=scnprintf (buf + len,sizeof (buf) - len,"TX slot bitmap : " ); - - len +=bitmap_scnprintf (buf + len,sizeof (buf) - len, - priv->tx.tx_slot,MAX_TX_BUF_NUM ); - - len +=scnprintf (buf + len,sizeof (buf) - len,"\n" ); - - len +=scnprintf (buf + len,sizeof (buf) - len, -"Used slots : %d\n" , -bitmap_weight (priv->tx.tx_slot,MAX_TX_BUF_NUM )); - + len =scnprintf (buf,sizeof (buf), +"TX slot bitmap : %*pb\n" +"Used slots : %d\n" , +MAX_TX_BUF_NUM , priv->tx.tx_slot, +bitmap_weight (priv->tx.tx_slot,MAX_TX_BUF_NUM ));spin_unlock_bh (&priv->tx.tx_lock); - -if (len >sizeof (buf)) - len =sizeof (buf); -return simple_read_from_buffer (user_buf, count, ppos, buf, len); }
drivers/net/wireless/ath/carl9170/debug.c +6 -18
@@ -214,14 +214,10 @@ DEBUGFS_DECLARE_RO_FILE(name, _read_bufsize)static char *carl9170_debugfs_mem_usage_read (struct ar9170 *ar,char *buf,size_t bufsize,ssize_t *len) { -ADD (buf, *len, bufsize,"jar: [" ); -spin_lock_bh (&ar->mem_lock); - *len +=bitmap_scnprintf (&buf[*len], bufsize - *len, - ar->mem_bitmap, ar->fw.mem_blocks); - -ADD (buf, *len, bufsize,"]\n" ); +ADD (buf, *len, bufsize,"jar: [%*pb]\n" , + ar->fw.mem_blocks, ar->mem_bitmap); ADD(buf, *len, bufsize, "cookies: used:%3d / total:%3d, allocs:%d\n", bitmap_weight(ar->mem_bitmap, ar->fw.mem_blocks),
@@ -316,17 +312,13 @@ static char *carl9170_debugfs_ampdu_state_read(struct ar9170 *ar, char *buf, cnt, iter->tid, iter->bsn, iter->snx, iter->hsn, iter->max, iter->state, iter->counter); -ADD (buf, *len, bufsize,"\tWindow: [" ); - - *len +=bitmap_scnprintf (&buf[*len], bufsize - *len, - iter->bitmap,CARL9170_BAW_BITS ); +ADD (buf, *len, bufsize,"\tWindow: [%*pb,W]\n" , +CARL9170_BAW_BITS , iter->bitmap);#define BM_STR_OFF (offset) \ ((CARL9170_BAW_BITS - (offset) - 1) / 4 + \ (CARL9170_BAW_BITS - (offset) - 1) / 32 + 1) -ADD (buf, *len, bufsize,",W]\n" ); - offset =BM_STR_OFF (0 );ADD (buf, *len, bufsize,"\tBase Seq: %*s\n" , offset,"T" );
@@ -448,12 +440,8 @@ static char *carl9170_debugfs_vif_dump_read(struct ar9170 *ar, char *buf,ADD (buf, *len, bufsize,"registered VIFs:%d \\ %d\n" , ar->vifs, ar->fw.vif_num); -ADD (buf, *len, bufsize,"VIF bitmap: [" ); - - *len +=bitmap_scnprintf (&buf[*len], bufsize - *len, - &ar->vif_bitmap, ar->fw.vif_num); - -ADD (buf, *len, bufsize,"]\n" ); +ADD (buf, *len, bufsize,"VIF bitmap: [%*pb]\n" , + ar->fw.vif_num, &ar->vif_bitmap);rcu_read_lock ();list_for_each_entry_rcu (iter, &ar->vif_list, list) {
Signature · 1 line
2.1.0
Re: [PATCH 21/32] wireless: use %*pb[l] to print bitmaps including cpumasks and nodemasks
Quoted 10 lines · Tejun Heo
printk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide
cpumask_pr_args()andnodemask_pr_args()respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Quoted 7 lines
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
Signed-off-by Tejun Heo <[email protected]>Cc Andrew Morton <[email protected]>Cc "John W. Linville" <[email protected]>
This was already applied so I'm dropping it from my queue.
Signature · 1 line
Kalle Valo
Tejun Heo
maintainerPATCH 22/32 input: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* Line termination only requires one extra space at the end of the buffer. Use PAGE_SIZE - 1 instead of PAGE_SIZE - 2 when formatting.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- drivers/input/keyboard/atkbd.c | 4 ++-- drivers/input/keyboard/gpio_keys.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/input/keyboard/atkbd.c +2 -2
@@ -1399,8 +1399,8 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t counstatic ssize_t atkbd_show_force_release (struct atkbd *atkbd,char *buf) { -size_t len =bitmap_scnlistprintf (buf,PAGE_SIZE -2 , - atkbd->force_release_mask,ATKBD_KEYMAP_SIZE ); +size_t len =scnprintf (buf,PAGE_SIZE -1 ,"%*pbl" , +ATKBD_KEYMAP_SIZE , atkbd->force_release_mask); buf[len++] ='\n' ; buf[len] ='\0' ;
drivers/input/keyboard/gpio_keys.c +1 -1
@@ -190,7 +190,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,__set_bit (bdata->button->code, bits); } - ret =bitmap_scnlistprintf (buf,PAGE_SIZE -2 , bits, n_events); + ret =scnprintf (buf,PAGE_SIZE -1 ,"%*pbl" , n_events, bits); buf[ret++] ='\n' ; buf[ret] ='\0' ;
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 23/32 scsi: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* map_show()'s return value is too high by one and the function could modify beyond the end of the buffer when the formatted text is long enough.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- drivers/scsi/scsi_debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/scsi_debug.c +3 -3
@@ -4536,10 +4536,10 @@ static ssize_t map_show(struct device_driver *ddp, char *buf)return scnprintf (buf,PAGE_SIZE ,"0-%u\n" , sdebug_store_sectors); - count =bitmap_scnlistprintf (buf,PAGE_SIZE , map_storep, map_size); - + count =scnprintf (buf,PAGE_SIZE -1 ,"%*pbl" , + (int )map_size, map_storep); buf[count++] ='\n' ; - buf[count++] =0 ; + buf[count] ='\0' ;return count; }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 24/32 usb: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* drivers/uwb/drp.c::uwb_drp_handle_alien_drp() was formatting mas.bm into a buffer but never used it. Removed.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- drivers/usb/host/whci/debug.c | 7 ++----- drivers/usb/wusbcore/reservation.c | 5 ++--- drivers/usb/wusbcore/wa-rpipe.c | 5 ++--- drivers/usb/wusbcore/wusbhc.c | 7 ++----- drivers/uwb/drp.c | 2 -- drivers/uwb/uwb-debug.c | 16 +++++----------- 6 files changed, 13 insertions(+), 29 deletions(-)
drivers/usb/host/whci/debug.c +2 -5
@@ -86,17 +86,14 @@ static void qset_print(struct seq_file *s, struct whc_qset *qset)static int di_print (struct seq_file *s,void *p) {struct whc *whc = s->private; -char buf[72 ];int d;for (d =0 ; d < whc->n_devices; d++) {struct di_buf_entry *di = &whc->di_buf[d]; -bitmap_scnprintf (buf,sizeof (buf), - (unsigned long *)di->availability_info,UWB_NUM_MAS ); -seq_printf (s,"DI[%d]\n" , d); -seq_printf (s," availability: %s\n" , buf); +seq_printf (s," availability: %*pb\n" , +UWB_NUM_MAS , (unsigned long *)di->availability_info); seq_printf(s, " %c%c key idx: %d dev addr: %d\n", (di->addr_sec_info & WHC_DI_SECURE) ? 'S' : ' ', (di->addr_sec_info & WHC_DI_DISABLE) ? 'D' : ' ',
drivers/usb/wusbcore/reservation.c +2 -3
@@ -49,14 +49,13 @@ static void wusbhc_rsv_complete_cb(struct uwb_rsv *rsv)struct wusbhc *wusbhc = rsv->pal_priv;struct device *dev = wusbhc->dev;struct uwb_mas_bm mas; -char buf[72 ];dev_dbg (dev,"%s: state = %d\n" , __func__, rsv->state);switch (rsv->state) {case UWB_RSV_STATE_O_ESTABLISHED :uwb_rsv_get_usable_mas (rsv, &mas); -bitmap_scnprintf (buf,sizeof (buf), mas.bm,UWB_NUM_MAS ); -dev_dbg (dev,"established reservation: %s\n" , buf); +dev_dbg (dev,"established reservation: %*pb\n" , +UWB_NUM_MAS , mas.bm);wusbhc_bwa_set (wusbhc, rsv->stream, &mas);break ;case UWB_RSV_STATE_NONE :
drivers/usb/wusbcore/wa-rpipe.c +2 -3
@@ -496,10 +496,9 @@ void wa_rpipes_destroy(struct wahc *wa)struct device *dev = &wa->usb_iface->dev;if (!bitmap_empty (wa->rpipe_bm, wa->rpipes)) { -char buf[256 ];WARN_ON (1 ); -bitmap_scnprintf (buf,sizeof (buf), wa->rpipe_bm, wa->rpipes); -dev_err (dev,"BUG: pipes not released on exit: %s\n" , buf); +dev_err (dev,"BUG: pipes not released on exit: %*pb\n" , + wa->rpipes, wa->rpipe_bm); }kfree (wa->rpipe_bm); }
drivers/usb/wusbcore/wusbhc.c +2 -5
@@ -496,11 +496,8 @@ static void __exit wusbcore_exit(void) {clear_bit (0 , wusb_cluster_id_table);if (!bitmap_empty (wusb_cluster_id_table,CLUSTER_IDS )) { -char buf[256 ]; -bitmap_scnprintf (buf,sizeof (buf), wusb_cluster_id_table, -CLUSTER_IDS ); -printk (KERN_ERR "BUG: WUSB Cluster IDs not released " -"on exit: %s\n" , buf); +printk (KERN_ERR "BUG: WUSB Cluster IDs not released on exit: %*pb\n" , +CLUSTER_IDS , wusb_cluster_id_table);WARN_ON (1 ); }usb_unregister_notify (&wusb_usb_notifier);
drivers/uwb/drp.c +0 -2
@@ -619,11 +619,9 @@ static void uwb_drp_handle_alien_drp(struct uwb_rc *rc, struct uwb_ie_drp *drp_istruct device *dev = &rc->uwb_dev.dev;struct uwb_mas_bm mas;struct uwb_cnflt_alien *cnflt; -char buf[72 ];unsigned long delay_us =UWB_MAS_LENGTH_US *UWB_MAS_PER_ZONE ;uwb_drp_ie_to_bm (&mas, drp_ie); -bitmap_scnprintf (buf,sizeof (buf), mas.bm,UWB_NUM_MAS );list_for_each_entry (cnflt, &rc->cnflt_alien_list, rc_node) {if (bitmap_equal (cnflt->mas.bm, mas.bm,UWB_NUM_MAS )) {
drivers/uwb/uwb-debug.c +5 -11
@@ -217,7 +217,6 @@ static int reservations_print(struct seq_file *s, void *p)struct uwb_dev_addr devaddr;char owner[UWB_ADDR_STRSIZE ], target[UWB_ADDR_STRSIZE ];bool is_owner; -char buf[72 ];uwb_dev_addr_print (owner,sizeof (owner), &rsv->owner->dev_addr);if (rsv->target.type ==UWB_RSV_TARGET_DEV ) {
@@ -234,8 +233,7 @@ static int reservations_print(struct seq_file *s, void *p) owner, target, uwb_rsv_state_str(rsv->state));seq_printf (s," stream: %d type: %s\n" , rsv->stream,uwb_rsv_type_str (rsv->type)); -bitmap_scnprintf (buf,sizeof (buf), rsv->mas.bm,UWB_NUM_MAS ); -seq_printf (s," %s\n" , buf); +seq_printf (s," %*pb\n" ,UWB_NUM_MAS , rsv->mas.bm); }mutex_unlock (&rc->rsvs_mutex);
@@ -259,14 +257,10 @@ static const struct file_operations reservations_fops = {static int drp_avail_print (struct seq_file *s,void *p) {struct uwb_rc *rc = s->private; -char buf[72 ]; - -bitmap_scnprintf (buf,sizeof (buf), rc->drp_avail.global,UWB_NUM_MAS ); -seq_printf (s,"global: %s\n" , buf); -bitmap_scnprintf (buf,sizeof (buf), rc->drp_avail.local,UWB_NUM_MAS ); -seq_printf (s,"local: %s\n" , buf); -bitmap_scnprintf (buf,sizeof (buf), rc->drp_avail.pending,UWB_NUM_MAS ); -seq_printf (s,"pending: %s\n" , buf); + +seq_printf (s,"global: %*pb\n" ,UWB_NUM_MAS , rc->drp_avail.global); +seq_printf (s,"local: %*pb\n" ,UWB_NUM_MAS , rc->drp_avail.local); +seq_printf (s,"pending: %*pb\n" ,UWB_NUM_MAS , rc->drp_avail.pending);return 0 ; }
Signature · 1 line
2.1.0
Re: [PATCH 24/32] usb: use %*pb[l] to print bitmaps including cpumasks and nodemasks
Quoted 13 lines · Tejun Heo
printk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide
cpumask_pr_args()andnodemask_pr_args()respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.* drivers/uwb/drp.c::uwb_drp_handle_alien_drp() was formatting mas.bm into a buffer but never used it. Removed.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Quoted 7 lines
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
Signed-off-by Tejun Heo <[email protected]>Cc Andrew Morton <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Tejun Heo
maintainerPATCH 25/32 drivers/base: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* Line termination only requires one extra space at the end of the buffer. Use PAGE_SIZE - 1 instead of PAGE_SIZE - 2 when formatting.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- drivers/base/cpu.c | 2 +- drivers/base/node.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/base/cpu.c +1 -1
@@ -245,7 +245,7 @@ static ssize_t print_cpus_offline(struct device *dev,if (!alloc_cpumask_var (&offline,GFP_KERNEL ))return -ENOMEM ;cpumask_andnot (offline, cpu_possible_mask, cpu_online_mask); - n =cpulist_scnprintf (buf, len, offline); + n =scnprintf (buf, len,"%*pbl" ,cpumask_pr_args (offline));free_cpumask_var (offline);/* display offline cpus >= nr_cpu_ids */
drivers/base/node.c +2 -1
@@ -605,7 +605,8 @@ static ssize_t print_nodes_state(enum node_states state, char *buf) {int n; - n =nodelist_scnprintf (buf,PAGE_SIZE -2 , node_states[state]); + n =scnprintf (buf,PAGE_SIZE -1 ,"%*pbl" , +nodemask_pr_args (&node_states[state])); buf[n++] ='\n' ; buf[n] ='\0' ;return n;
Signature · 1 line
2.1.0
Re: [PATCH 25/32] drivers/base: use %*pb[l] to print bitmaps including cpumasks and nodemasks
Quoted 13 lines · Tejun Heo
printk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide
cpumask_pr_args()andnodemask_pr_args()respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.* Line termination only requires one extra space at the end of the buffer. Use
PAGE_SIZE- 1 instead ofPAGE_SIZE- 2 when formatting.This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Quoted 6 lines
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
Signed-off-by Tejun Heo <[email protected]>Cc Andrew Morton <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Tejun Heo
maintainerPATCH 26/32 slub: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
* This is an equivalent conversion but the whole function should be converted to use scnprinf famiily of functions rather than performing custom output length predictions in multiple places.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- mm/slub.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
mm/slub.c +8 -12
@@ -4070,20 +4070,16 @@ static int list_locations(struct kmem_cache *s, char *buf,if (num_online_cpus () >1 && !cpumask_empty (to_cpumask (l->cpus)) && - len <PAGE_SIZE -60 ) { - len +=sprintf (buf + len," cpus=" ); - len +=cpulist_scnprintf (buf + len, -PAGE_SIZE - len -50 , -to_cpumask (l->cpus)); - } + len <PAGE_SIZE -60 ) + len +=scnprintf (buf + len,PAGE_SIZE - len -50 , +" cpus=%*pbl" , +cpumask_pr_args (to_cpumask (l->cpus)));if (nr_online_nodes >1 && !nodes_empty (l->nodes) && - len <PAGE_SIZE -60 ) { - len +=sprintf (buf + len," nodes=" ); - len +=nodelist_scnprintf (buf + len, -PAGE_SIZE - len -50 , - l->nodes); - } + len <PAGE_SIZE -60 ) + len +=scnprintf (buf + len,PAGE_SIZE - len -50 , +" nodes=%*pbl" , +nodemask_pr_args (&l->nodes)); len +=sprintf (buf + len,"\n" ); }
Signature · 1 line
2.1.0
Re: [PATCH 26/32] slub: use %*pb[l] to print bitmaps including cpumasks and nodemasks
Tejun Heo
maintainerPATCH 27/32 mm: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- mm/mempolicy.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
mm/mempolicy.c +3 -4
@@ -2838,8 +2838,7 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol) p +=snprintf (p, buffer + maxlen - p,"relative" ); } -if (!nodes_empty (nodes)) { - p +=snprintf (p, buffer + maxlen - p,":" ); - p +=nodelist_scnprintf (p, buffer + maxlen - p, nodes); - } +if (!nodes_empty (nodes)) + p +=scnprintf (p, buffer + maxlen - p,":%*pbl" , +nodemask_pr_args (&nodes)); }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 28/32 padata: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/padata.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
kernel/padata.c +3 -8
@@ -917,15 +917,10 @@ static ssize_t show_cpumask(struct padata_instance *pinst,else cpumask = pinst->cpumask.pcpu; - len =bitmap_scnprintf (buf,PAGE_SIZE ,cpumask_bits (cpumask), - nr_cpu_ids); -if (PAGE_SIZE - len <2 ) - len = -EINVAL ; -else - len +=sprintf (buf + len,"\n" ); - + len =snprintf (buf,PAGE_SIZE ,"%*pb\n" , + nr_cpu_ids,cpumask_bits (cpumask));mutex_unlock (&pinst->lock); -return len; +return len <PAGE_SIZE ? len : -EINVAL ; } static ssize_t store_cpumask(struct padata_instance *pinst,
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 29/32 proc: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- fs/proc/array.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/proc/array.c +4 -6
@@ -336,12 +336,10 @@ static inline void task_context_switch_counts(struct seq_file *m,static void task_cpus_allowed (struct seq_file *m,struct task_struct *task) { -seq_puts (m,"Cpus_allowed:\t" ); -seq_cpumask (m, &task->cpus_allowed); -seq_putc (m,'\n' ); -seq_puts (m,"Cpus_allowed_list:\t" ); -seq_cpumask_list (m, &task->cpus_allowed); -seq_putc (m,'\n' ); +seq_printf (m,"Cpus_allowed:\t%*pb\n" , +cpumask_pr_args (&task->cpus_allowed)); +seq_printf (m,"Cpus_allowed_list:\t%*pbl\n" , +cpumask_pr_args (&task->cpus_allowed)); } int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 30/32 irq: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/irq/proc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
kernel/irq/proc.c +4 -7
@@ -46,10 +46,9 @@ static int show_irq_affinity(int type, struct seq_file *m, void *v) mask = desc->pending_mask;#endif if (type) -seq_cpumask_list (m, mask); +seq_printf (m,"%*pbl\n" ,cpumask_pr_args (mask));else -seq_cpumask (m, mask); -seq_putc (m,'\n' ); +seq_printf (m,"%*pb\n" ,cpumask_pr_args (mask));return 0 ; }
@@ -67,8 +66,7 @@ static int irq_affinity_hint_proc_show(struct seq_file *m, void *v)cpumask_copy (mask, desc->affinity_hint);raw_spin_unlock_irqrestore (&desc->lock, flags); -seq_cpumask (m, mask); -seq_putc (m,'\n' ); +seq_printf (m,"%*pb\n" ,cpumask_pr_args (mask));free_cpumask_var (mask);return 0 ;
@@ -186,8 +184,7 @@ static const struct file_operations irq_affinity_list_proc_fops = {static int default_affinity_show (struct seq_file *m,void *v) { -seq_cpumask (m, irq_default_affinity); -seq_putc (m,'\n' ); +seq_printf (m,"%*pb\n" ,cpumask_pr_args (irq_default_affinity));return 0 ; }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 31/32 profile: use %*pb[l] to print bitmaps including cpumasks and nodemasks
In reply to Tejun Heoprintk and friends can now formap bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask.
This patch is dependent on the following two patches.
lib/vsprintf: implement bitmap printing through '%*pb[l]' cpumask, nodemask: implement cpumask/nodemask_pr_args()
Please wait till the forementioned patches are merged to mainline before applying to subsystem trees.
--- kernel/profile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/profile.c +1 -2
@@ -422,8 +422,7 @@ void profile_tick(int type)static int prof_cpu_mask_proc_show (struct seq_file *m,void *v) { -seq_cpumask (m, prof_cpu_mask); -seq_putc (m,'\n' ); +seq_printf (m,"%*pb\n" ,cpumask_pr_args (prof_cpu_mask));return 0 ; }
Signature · 1 line
2.1.0
Tejun Heo
maintainerPATCH 32/32 bitmap, cpumask, nodemask: remove dedicated formatting functions
In reply to Tejun HeoNow that all bitmap formatting usages have been converted to '%*pb[l]', the separate formatting functions are unnecessary. The following functions are removed.
* bitmap_scn[list]printf()
* cpumask_scnprintf(), cpulist_scnprintf()
* [__]nodemask_scnprintf(), [__]nodelist_scnprintf()
* seq_bitmap[_list](), seq_cpumask[_list](), seq_nodemask[_list]()
* seq_buf_bitmask()
--- fs/seq_file.c | 32 -------------------------------- include/linux/bitmap.h | 7 ------- include/linux/cpumask.h | 31 ------------------------------- include/linux/nodemask.h | 33 +++++++-------------------------- include/linux/seq_buf.h | 3 --- include/linux/seq_file.h | 25 ------------------------- lib/bitmap.c | 41 ----------------------------------------- lib/seq_buf.c | 36 ------------------------------------ 8 files changed, 7 insertions(+), 201 deletions(-)
fs/seq_file.c +0 -32
@@ -539,38 +539,6 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc)return res; } -int seq_bitmap (struct seq_file *m,const unsigned long *bits, -unsigned int nr_bits) -{ -if (m->count < m->size) { -int len =bitmap_scnprintf (m->buf + m->count, - m->size - m->count, bits, nr_bits); -if (m->count + len < m->size) { - m->count += len; -return 0 ; - } - } -seq_set_overflow (m); -return -1 ; -} -EXPORT_SYMBOL (seq_bitmap); - -int seq_bitmap_list (struct seq_file *m,const unsigned long *bits, -unsigned int nr_bits) -{ -if (m->count < m->size) { -int len =bitmap_scnlistprintf (m->buf + m->count, - m->size - m->count, bits, nr_bits); -if (m->count + len < m->size) { - m->count += len; -return 0 ; - } - } -seq_set_overflow (m); -return -1 ; -} -EXPORT_SYMBOL (seq_bitmap_list); -static void *single_start (struct seq_file *p,loff_t *pos) {return NULL + (*pos ==0 );
include/linux/bitmap.h +0 -7
@@ -52,16 +52,13 @@* bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz -* bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf -* bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region * bitmap_release_region(bitmap, pos, order) Free specified bit region * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region -* bitmap_print_to_pagebuf(list, buf, mask, nbits) Print bitmap src as list/hex */ /*
@@ -147,14 +144,10 @@ bitmap_find_next_zero_area(unsigned long *map, align_mask, 0); } -extern int bitmap_scnprintf (char *buf,unsigned int len, -const unsigned long *src,int nbits);extern int __bitmap_parse (const char *buf,unsigned int buflen,int is_user,unsigned long *dst,int nbits);extern int bitmap_parse_user (const char __user *ubuf,unsigned int ulen,unsigned long *dst,int nbits); -extern int bitmap_scnlistprintf (char *buf,unsigned int len, -const unsigned long *src,int nbits);extern int bitmap_parselist (const char *buf,unsigned long *maskp,int nmaskbits); extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,
include/linux/cpumask.h +0 -31
@@ -547,21 +547,6 @@ static inline void cpumask_copy(struct cpumask *dstp,#define cpumask_of (cpu) (get_cpu_mask(cpu))/** -* cpumask_scnprintf - print a cpumask into a string as comma-separated hex -* @buf: the buffer to sprintf into -* @len: the length of the buffer -* @srcp: the cpumask to print -* -* If len is zero, returns zero. Otherwise returns the length of the -* (nul-terminated) @buf string. -*/ -static inline int cpumask_scnprintf (char *buf,int len, -const struct cpumask *srcp) -{ -return bitmap_scnprintf (buf, len,cpumask_bits (srcp), nr_cpu_ids); -} - -/** * cpumask_parse_user - extract a cpumask from a user string * @buf: the buffer to extract from * @len: the length of the buffer
@@ -591,22 +576,6 @@ static inline int cpumask_parselist_user(const char __user *buf, int len, }/** -* cpulist_scnprintf - print a cpumask into a string as comma-separated list -* @buf: the buffer to sprintf into -* @len: the length of the buffer -* @srcp: the cpumask to print -* -* If len is zero, returns zero. Otherwise returns the length of the -* (nul-terminated) @buf string. -*/ -static inline int cpulist_scnprintf (char *buf,int len, -const struct cpumask *srcp) -{ -return bitmap_scnlistprintf (buf, len,cpumask_bits (srcp), - nr_cpu_ids); -} - -/** * cpumask_parse - extract a cpumask from from a string * @buf: the buffer to extract from * @dstp: the cpumask to set.
include/linux/nodemask.h +7 -26
@@ -8,14 +8,13 @@* See detailed comments in the file linux/bitmap.h describing the * data type on which these nodemasks are based. * -* For details of nodemask_scnprintf() and nodemask_parse_user(), -* see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c. -* For details of nodelist_scnprintf() and nodelist_parse(), see -* bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. -* For details of node_remap(), see bitmap_bitremap in lib/bitmap.c. -* For details of nodes_remap(), see bitmap_remap in lib/bitmap.c. -* For details of nodes_onto(), see bitmap_onto in lib/bitmap.c. -* For details of nodes_fold(), see bitmap_fold in lib/bitmap.c. +* For details of nodemask_parse_user(), see bitmap_parse_user() in +* lib/bitmap.c. For details of nodelist_parse(), see bitmap_parselist(), +* also in bitmap.c. For details of node_remap(), see bitmap_bitremap in +* lib/bitmap.c. For details of nodes_remap(), see bitmap_remap in +* lib/bitmap.c. For details of nodes_onto(), see bitmap_onto in +* lib/bitmap.c. For details of nodes_fold(), see bitmap_fold in +* lib/bitmap.c. * * The available nodemask operations are: *
@@ -52,9 +51,7 @@* 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 nodemask_parse_user(ubuf, ulen, mask) Parse ascii string as nodemask -* int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing * int nodelist_parse(buf, map) Parse ascii string as nodelist * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit) * void nodes_remap(dst, src, old, new) *dst = map(old, new)(src)
@@ -312,14 +309,6 @@ static inline int __first_unset_node(const nodemask_t *maskp)#define nodes_addr (src) ((src).bits) -#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_user (ubuf, ulen, dst) \ __nodemask_parse_user((ubuf), (ulen), &(dst), MAX_NUMNODES) static inline int __nodemask_parse_user(const char __user *buf, int len,
@@ -328,14 +317,6 @@ static inline int __nodemask_parse_user(const char __user *buf, int len,return bitmap_parse_user (buf, len, dstp->bits, nbits); } -#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); -} -#define nodelist_parse (buf, dst) __nodelist_parse((buf), &(dst), MAX_NUMNODES)static inline int __nodelist_parse (const char *buf,nodemask_t *dstp,int nbits) {
include/linux/seq_buf.h +0 -3
@@ -125,9 +125,6 @@ extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem, unsigned int len);extern int seq_buf_path (struct seq_buf *s,const struct path *path,const char *esc); -extern int seq_buf_bitmask (struct seq_buf *s,const unsigned long *maskp, -int nmaskbits); -#ifdef CONFIG_BINARY_PRINTF extern int seq_buf_bprintf (struct seq_buf *s,const char *fmt,const u32 *binary);
include/linux/seq_file.h +0 -25
@@ -126,31 +126,6 @@ int seq_path(struct seq_file *, const struct path *, const char *);int seq_dentry (struct seq_file *,struct dentry *,const char *);int seq_path_root (struct seq_file *m,const struct path *path,const struct path *root,const char *esc); -int seq_bitmap (struct seq_file *m,const unsigned long *bits, -unsigned int nr_bits); -static inline int seq_cpumask (struct seq_file *m,const struct cpumask *mask) -{ -return seq_bitmap (m,cpumask_bits (mask), nr_cpu_ids); -} - -static inline int seq_nodemask (struct seq_file *m,nodemask_t *mask) -{ -return seq_bitmap (m, mask->bits,MAX_NUMNODES ); -} - -int seq_bitmap_list (struct seq_file *m,const unsigned long *bits, -unsigned int nr_bits); - -static inline int seq_cpumask_list (struct seq_file *m, -const struct cpumask *mask) -{ -return seq_bitmap_list (m,cpumask_bits (mask), nr_cpu_ids); -} - -static inline int seq_nodemask_list (struct seq_file *m,nodemask_t *mask) -{ -return seq_bitmap_list (m, mask->bits,MAX_NUMNODES ); -}int single_open (struct file *,int (*)(struct seq_file *,void *),void *);int single_open_size (struct file *,int (*)(struct seq_file *,void *),void *,size_t );
lib/bitmap.c +0 -41
53 lines not on this page · raw message
lib/seq_buf.c +0 -36
@@ -91,42 +91,6 @@ int seq_buf_printf(struct seq_buf *s, const char *fmt, ...)return ret; } -/** -* seq_buf_bitmask - write a bitmask array in its ASCII representation -* @s: seq_buf descriptor -* @maskp: points to an array of unsigned longs that represent a bitmask -* @nmaskbits: The number of bits that are valid in @maskp -* -* Writes a ASCII representation of a bitmask string into @s. -* -* Returns zero on success, -1 on overflow. -*/ -int seq_buf_bitmask (struct seq_buf *s,const unsigned long *maskp, -int nmaskbits) -{ -unsigned int len =seq_buf_buffer_left (s); -int ret; - -WARN_ON (s->size ==0 ); - -/* -* Note, because bitmap_scnprintf() only returns the number of bytes -* written and not the number that would be written, we use the last -* byte of the buffer to let us know if we overflowed. There's a small -* chance that the bitmap could have fit exactly inside the buffer, but -* it's not that critical if that does happen. -*/ -if (len >1 ) { - ret =bitmap_scnprintf (s->buffer + s->len, len, maskp, nmaskbits); -if (ret < len) { - s->len += ret; -return 0 ; - } - } -seq_buf_set_overflow (s); -return -1 ; -} -#ifdef CONFIG_BINARY_PRINTF /** * seq_buf_bprintf - Write the printf string from binary arguments
Signature · 1 line
2.1.0