tracing: use %*pb[l] to print bitmaps including cpumasks and nodemasks
authorTejun Heo <tj@kernel.org>
Fri, 13 Feb 2015 22:37:39 +0000 (14:37 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Feb 2015 05:21:37 +0000 (21:21 -0800)
printk and friends can now format 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.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/trace/trace.c
kernel/trace/trace_seq.c

index 77b8dc528006cf2c937b242ded546f425a1a9caf..62c6506d663fa11e79128759bd03103d12ed7c0f 100644 (file)
@@ -3353,12 +3353,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:
index f8b45d8792f96cd4f5b3cc8428d435da0c84f96a..e694c9f9efa496e58d343778721658ea3f9dbad8 100644 (file)
@@ -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;