diff options
author | Tejun Heo <tj@kernel.org> | 2015-02-13 17:37:23 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-14 00:21:37 -0500 |
commit | e8e6d97c9bf734c42322dbed0f882ef11bfe7b58 (patch) | |
tree | 66989fbc5d75855d90e38a390224d496dfdee913 /kernel | |
parent | 660e5ec02d5391305604887f33a844adeaa6220c (diff) |
cpuset: 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.
* kernel/cpuset.c::cpuset_print_task_mems_allowed() used a static
buffer which is protected by a dedicated spinlock. Removed.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cpuset.c | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index c54a1dae6c11..1d1fe9361d29 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -1707,40 +1707,27 @@ static int cpuset_common_seq_show(struct seq_file *sf, void *v) | |||
1707 | { | 1707 | { |
1708 | struct cpuset *cs = css_cs(seq_css(sf)); | 1708 | struct cpuset *cs = css_cs(seq_css(sf)); |
1709 | cpuset_filetype_t type = seq_cft(sf)->private; | 1709 | cpuset_filetype_t type = seq_cft(sf)->private; |
1710 | ssize_t count; | ||
1711 | char *buf, *s; | ||
1712 | int ret = 0; | 1710 | int ret = 0; |
1713 | 1711 | ||
1714 | count = seq_get_buf(sf, &buf); | ||
1715 | s = buf; | ||
1716 | |||
1717 | spin_lock_irq(&callback_lock); | 1712 | spin_lock_irq(&callback_lock); |
1718 | 1713 | ||
1719 | switch (type) { | 1714 | switch (type) { |
1720 | case FILE_CPULIST: | 1715 | case FILE_CPULIST: |
1721 | s += cpulist_scnprintf(s, count, cs->cpus_allowed); | 1716 | seq_printf(sf, "%*pbl\n", cpumask_pr_args(cs->cpus_allowed)); |
1722 | break; | 1717 | break; |
1723 | case FILE_MEMLIST: | 1718 | case FILE_MEMLIST: |
1724 | s += nodelist_scnprintf(s, count, cs->mems_allowed); | 1719 | seq_printf(sf, "%*pbl\n", nodemask_pr_args(&cs->mems_allowed)); |
1725 | break; | 1720 | break; |
1726 | case FILE_EFFECTIVE_CPULIST: | 1721 | case FILE_EFFECTIVE_CPULIST: |
1727 | s += cpulist_scnprintf(s, count, cs->effective_cpus); | 1722 | seq_printf(sf, "%*pbl\n", cpumask_pr_args(cs->effective_cpus)); |
1728 | break; | 1723 | break; |
1729 | case FILE_EFFECTIVE_MEMLIST: | 1724 | case FILE_EFFECTIVE_MEMLIST: |
1730 | s += nodelist_scnprintf(s, count, cs->effective_mems); | 1725 | seq_printf(sf, "%*pbl\n", nodemask_pr_args(&cs->effective_mems)); |
1731 | break; | 1726 | break; |
1732 | default: | 1727 | default: |
1733 | ret = -EINVAL; | 1728 | ret = -EINVAL; |
1734 | goto out_unlock; | ||
1735 | } | 1729 | } |
1736 | 1730 | ||
1737 | if (s < buf + count - 1) { | ||
1738 | *s++ = '\n'; | ||
1739 | seq_commit(sf, s - buf); | ||
1740 | } else { | ||
1741 | seq_commit(sf, -1); | ||
1742 | } | ||
1743 | out_unlock: | ||
1744 | spin_unlock_irq(&callback_lock); | 1731 | spin_unlock_irq(&callback_lock); |
1745 | return ret; | 1732 | return ret; |
1746 | } | 1733 | } |
@@ -2610,8 +2597,6 @@ int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, | |||
2610 | return nodes_intersects(tsk1->mems_allowed, tsk2->mems_allowed); | 2597 | return nodes_intersects(tsk1->mems_allowed, tsk2->mems_allowed); |
2611 | } | 2598 | } |
2612 | 2599 | ||
2613 | #define CPUSET_NODELIST_LEN (256) | ||
2614 | |||
2615 | /** | 2600 | /** |
2616 | * cpuset_print_task_mems_allowed - prints task's cpuset and mems_allowed | 2601 | * cpuset_print_task_mems_allowed - prints task's cpuset and mems_allowed |
2617 | * @tsk: pointer to task_struct of some task. | 2602 | * @tsk: pointer to task_struct of some task. |
@@ -2621,23 +2606,16 @@ int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, | |||
2621 | */ | 2606 | */ |
2622 | void cpuset_print_task_mems_allowed(struct task_struct *tsk) | 2607 | void cpuset_print_task_mems_allowed(struct task_struct *tsk) |
2623 | { | 2608 | { |
2624 | /* Statically allocated to prevent using excess stack. */ | ||
2625 | static char cpuset_nodelist[CPUSET_NODELIST_LEN]; | ||
2626 | static DEFINE_SPINLOCK(cpuset_buffer_lock); | ||
2627 | struct cgroup *cgrp; | 2609 | struct cgroup *cgrp; |
2628 | 2610 | ||
2629 | spin_lock(&cpuset_buffer_lock); | ||
2630 | rcu_read_lock(); | 2611 | rcu_read_lock(); |
2631 | 2612 | ||
2632 | cgrp = task_cs(tsk)->css.cgroup; | 2613 | cgrp = task_cs(tsk)->css.cgroup; |
2633 | nodelist_scnprintf(cpuset_nodelist, CPUSET_NODELIST_LEN, | ||
2634 | tsk->mems_allowed); | ||
2635 | pr_info("%s cpuset=", tsk->comm); | 2614 | pr_info("%s cpuset=", tsk->comm); |
2636 | pr_cont_cgroup_name(cgrp); | 2615 | pr_cont_cgroup_name(cgrp); |
2637 | pr_cont(" mems_allowed=%s\n", cpuset_nodelist); | 2616 | pr_cont(" mems_allowed=%*pbl\n", nodemask_pr_args(&tsk->mems_allowed)); |
2638 | 2617 | ||
2639 | rcu_read_unlock(); | 2618 | rcu_read_unlock(); |
2640 | spin_unlock(&cpuset_buffer_lock); | ||
2641 | } | 2619 | } |
2642 | 2620 | ||
2643 | /* | 2621 | /* |
@@ -2715,10 +2693,8 @@ out: | |||
2715 | /* Display task mems_allowed in /proc/<pid>/status file. */ | 2693 | /* Display task mems_allowed in /proc/<pid>/status file. */ |
2716 | void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task) | 2694 | void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task) |
2717 | { | 2695 | { |
2718 | seq_puts(m, "Mems_allowed:\t"); | 2696 | seq_printf(m, "Mems_allowed:\t%*pb\n", |
2719 | seq_nodemask(m, &task->mems_allowed); | 2697 | nodemask_pr_args(&task->mems_allowed)); |
2720 | seq_puts(m, "\n"); | 2698 | seq_printf(m, "Mems_allowed_list:\t%*pbl\n", |
2721 | seq_puts(m, "Mems_allowed_list:\t"); | 2699 | nodemask_pr_args(&task->mems_allowed)); |
2722 | seq_nodemask_list(m, &task->mems_allowed); | ||
2723 | seq_puts(m, "\n"); | ||
2724 | } | 2700 | } |