workqueue: drop 'H' from kworker names of unbound worker pools
authorTejun Heo <tj@kernel.org>
Mon, 1 Apr 2013 18:23:32 +0000 (11:23 -0700)
committerTejun Heo <tj@kernel.org>
Mon, 1 Apr 2013 18:23:32 +0000 (11:23 -0700)
Currently, all workqueue workers which have negative nice value has
'H' postfixed to their names.  This is necessary for per-cpu workers
as they use the CPU number instead of pool->id to identify the pool
and the 'H' postfix is the only thing distinguishing normal and
highpri workers.

As workers for unbound pools use pool->id, the 'H' postfix is purely
informational.  TASK_COMM_LEN is 16 and after the static part and
delimiters, there are only five characters left for the pool and
worker IDs.  We're expecting to have more unbound pools with the
scheduled NUMA awareness support.  Let's drop the non-essential 'H'
postfix from unbound kworker name.

While at it, restructure kthread_create*() invocation to help future
NUMA related changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
kernel/workqueue.c

index 5ca46a2e2616f2b3419a751f4eb2ca2af582202d..248d18aa2a5d68ea31f600721ffa920af595c240 100644 (file)
@@ -1644,9 +1644,10 @@ static struct worker *alloc_worker(void)
  */
 static struct worker *create_worker(struct worker_pool *pool)
 {
-       const char *pri = pool->attrs->nice < 0  ? "H" : "";
        struct worker *worker = NULL;
+       int node = pool->cpu >= 0 ? cpu_to_node(pool->cpu) : NUMA_NO_NODE;
        int id = -1;
+       char id_buf[16];
 
        lockdep_assert_held(&pool->manager_mutex);
 
@@ -1672,13 +1673,13 @@ static struct worker *create_worker(struct worker_pool *pool)
        worker->id = id;
 
        if (pool->cpu >= 0)
-               worker->task = kthread_create_on_node(worker_thread,
-                                       worker, cpu_to_node(pool->cpu),
-                                       "kworker/%d:%d%s", pool->cpu, id, pri);
+               snprintf(id_buf, sizeof(id_buf), "%d:%d%s", pool->cpu, id,
+                        pool->attrs->nice < 0  ? "H" : "");
        else
-               worker->task = kthread_create(worker_thread, worker,
-                                             "kworker/u%d:%d%s",
-                                             pool->id, id, pri);
+               snprintf(id_buf, sizeof(id_buf), "u%d:%d", pool->id, id);
+
+       worker->task = kthread_create_on_node(worker_thread, worker, node,
+                                             "kworker/%s", id_buf);
        if (IS_ERR(worker->task))
                goto fail;