Skip to content

Commit 333470e

Browse files
htejuntorvalds
authored andcommitted
sched: use %*pb[l] to print bitmaps including cpumasks and nodemasks
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: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ad853b4 commit 333470e

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

kernel/sched/core.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5462,9 +5462,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
54625462
struct cpumask *groupmask)
54635463
{
54645464
struct sched_group *group = sd->groups;
5465-
char str[256];
54665465

5467-
cpulist_scnprintf(str, sizeof(str), sched_domain_span(sd));
54685466
cpumask_clear(groupmask);
54695467

54705468
printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
@@ -5477,7 +5475,8 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
54775475
return -1;
54785476
}
54795477

5480-
printk(KERN_CONT "span %s level %s\n", str, sd->name);
5478+
printk(KERN_CONT "span %*pbl level %s\n",
5479+
cpumask_pr_args(sched_domain_span(sd)), sd->name);
54815480

54825481
if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) {
54835482
printk(KERN_ERR "ERROR: domain->span does not contain "
@@ -5522,9 +5521,8 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
55225521

55235522
cpumask_or(groupmask, groupmask, sched_group_cpus(group));
55245523

5525-
cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group));
5526-
5527-
printk(KERN_CONT " %s", str);
5524+
printk(KERN_CONT " %*pbl",
5525+
cpumask_pr_args(sched_group_cpus(group)));
55285526
if (group->sgc->capacity != SCHED_CAPACITY_SCALE) {
55295527
printk(KERN_CONT " (cpu_capacity = %d)",
55305528
group->sgc->capacity);

kernel/sched/stats.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
static int show_schedstat(struct seq_file *seq, void *v)
1616
{
1717
int cpu;
18-
int mask_len = DIV_ROUND_UP(NR_CPUS, 32) * 9;
19-
char *mask_str = kmalloc(mask_len, GFP_KERNEL);
20-
21-
if (mask_str == NULL)
22-
return -ENOMEM;
2318

2419
if (v == (void *)1) {
2520
seq_printf(seq, "version %d\n", SCHEDSTAT_VERSION);
@@ -50,9 +45,8 @@ static int show_schedstat(struct seq_file *seq, void *v)
5045
for_each_domain(cpu, sd) {
5146
enum cpu_idle_type itype;
5247

53-
cpumask_scnprintf(mask_str, mask_len,
54-
sched_domain_span(sd));
55-
seq_printf(seq, "domain%d %s", dcount++, mask_str);
48+
seq_printf(seq, "domain%d %*pb", dcount++,
49+
cpumask_pr_args(sched_domain_span(sd)));
5650
for (itype = CPU_IDLE; itype < CPU_MAX_IDLE_TYPES;
5751
itype++) {
5852
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)
7670
rcu_read_unlock();
7771
#endif
7872
}
79-
kfree(mask_str);
8073
return 0;
8174
}
8275

0 commit comments

Comments
 (0)