lkml.org 
[lkml]   [2014]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 08/12] cpuset: use {cpu|node}mask pr_cont and seq output functions
    Date
    Convert the existing user of cpu{mask|list}_scnprintf() and
    node{mask|list}_scnprintf() which use them just to printk or
    seq_printf() the resulting buffer to use the following functions
    instead respectively.

    * For printk: cpu{mask|list}_pr_cont() and node{mask|list}_pr_cont().

    * For seq_file: seq_cpumask[_list]() and seq_nodemask[_list]().

    Because these conversions usually break up a single output function
    call into multiple, the reduction is LOC isn't too big but it removes
    unnecessary complexity and/or arbitrary limit on the length printed.

    * kernel/cpuset.c::cpuset_print_task_mems_allowed() used a static
    buffer which is protected by a dedicated spinlock. Replaced with
    plain pr_conts.

    This patch is dependent on the previous patch ("bitmap, cpumask,
    nodemask: implement pr_cont variants of formatting functions") which
    is planned to go through -mm. It'd be the easiest to route this
    together. If this should go through the subsystem tree, please wait
    till the forementioned patch is merged to mainline.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Li Zefan <lizefan@huawei.com>
    ---
    kernel/cpuset.c | 13 +++----------
    1 file changed, 3 insertions(+), 10 deletions(-)

    diff --git a/kernel/cpuset.c b/kernel/cpuset.c
    index fdf1759..6a7f466 100644
    --- a/kernel/cpuset.c
    +++ b/kernel/cpuset.c
    @@ -2614,8 +2614,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.
    @@ -2625,23 +2623,18 @@ 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=");
    + nodelist_pr_cont(tsk->mems_allowed);
    + pr_cont("\n");

    rcu_read_unlock();
    - spin_unlock(&cpuset_buffer_lock);
    }

    /*
    --
    2.1.0


    \
     
     \ /
      Last update: 2014-12-10 17:21    [W:4.083 / U:0.316 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site