Commit f0906827 authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds

net: 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: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1a40243b
...@@ -614,8 +614,7 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue, ...@@ -614,8 +614,7 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue,
{ {
struct rps_map *map; struct rps_map *map;
cpumask_var_t mask; cpumask_var_t mask;
size_t len = 0; int i, len;
int i;
if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
return -ENOMEM; return -ENOMEM;
...@@ -626,17 +625,11 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue, ...@@ -626,17 +625,11 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue,
for (i = 0; i < map->len; i++) for (i = 0; i < map->len; i++)
cpumask_set_cpu(map->cpus[i], mask); cpumask_set_cpu(map->cpus[i], mask);
len += cpumask_scnprintf(buf + len, PAGE_SIZE, mask); len = snprintf(buf, PAGE_SIZE, "%*pb\n", cpumask_pr_args(mask));
if (PAGE_SIZE - len < 3) {
rcu_read_unlock(); rcu_read_unlock();
free_cpumask_var(mask); free_cpumask_var(mask);
return -EINVAL;
}
rcu_read_unlock();
free_cpumask_var(mask); return len < PAGE_SIZE ? len : -EINVAL;
len += sprintf(buf + len, "\n");
return len;
} }
static ssize_t store_rps_map(struct netdev_rx_queue *queue, 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, ...@@ -1090,8 +1083,7 @@ static ssize_t show_xps_map(struct netdev_queue *queue,
struct xps_dev_maps *dev_maps; struct xps_dev_maps *dev_maps;
cpumask_var_t mask; cpumask_var_t mask;
unsigned long index; unsigned long index;
size_t len = 0; int i, len;
int i;
if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
return -ENOMEM; return -ENOMEM;
...@@ -1117,15 +1109,9 @@ static ssize_t show_xps_map(struct netdev_queue *queue, ...@@ -1117,15 +1109,9 @@ static ssize_t show_xps_map(struct netdev_queue *queue,
} }
rcu_read_unlock(); rcu_read_unlock();
len += cpumask_scnprintf(buf + len, PAGE_SIZE, mask); len = snprintf(buf, PAGE_SIZE, "%*pb\n", cpumask_pr_args(mask));
if (PAGE_SIZE - len < 3) {
free_cpumask_var(mask);
return -EINVAL;
}
free_cpumask_var(mask); free_cpumask_var(mask);
len += sprintf(buf + len, "\n"); return len < PAGE_SIZE ? len : -EINVAL;
return len;
} }
static ssize_t store_xps_map(struct netdev_queue *queue, static ssize_t store_xps_map(struct netdev_queue *queue,
......
...@@ -155,7 +155,7 @@ static int flow_limit_cpu_sysctl(struct ctl_table *table, int write, ...@@ -155,7 +155,7 @@ static int flow_limit_cpu_sysctl(struct ctl_table *table, int write,
rcu_read_unlock(); rcu_read_unlock();
len = min(sizeof(kbuf) - 1, *lenp); len = min(sizeof(kbuf) - 1, *lenp);
len = cpumask_scnprintf(kbuf, len, mask); len = scnprintf(kbuf, len, "%*pb", cpumask_pr_args(mask));
if (!len) { if (!len) {
*lenp = 0; *lenp = 0;
goto done; goto done;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment