aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/workqueue.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-03-12 14:29:59 -0400
committerTejun Heo <tj@kernel.org>2013-03-12 14:29:59 -0400
commit420c0ddb1f205a3511b766d0dfee2cc87ed9dae0 (patch)
treeb40f69b265def3d67d2ea67b06584bc2e7437678 /kernel/workqueue.c
parentd84ff0512f1bfc0d8c864efadb4523fce68919cc (diff)
workqueue: remove workqueue_struct->pool_wq.single
workqueue->pool_wq union is used to point either to percpu pwqs (pool_workqueues) or single unbound pwq. As the first pwq can be accessed via workqueue->pwqs list, there's no reason for the single pointer anymore. Use list_first_entry(workqueue->pwqs) to access the unbound pwq and drop workqueue->pool_wq.single pointer and the pool_wq union. It simplifies the code and eases implementing multiple unbound pools w/ custom attributes. This patch doesn't introduce any visible behavior changes. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r--kernel/workqueue.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 73c5f68065b5..acee7b525d51 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -188,11 +188,7 @@ struct wq_flusher {
188 */ 188 */
189struct workqueue_struct { 189struct workqueue_struct {
190 unsigned int flags; /* W: WQ_* flags */ 190 unsigned int flags; /* W: WQ_* flags */
191 union { 191 struct pool_workqueue __percpu *cpu_pwqs; /* I: per-cpu pwq's */
192 struct pool_workqueue __percpu *pcpu;
193 struct pool_workqueue *single;
194 unsigned long v;
195 } pool_wq; /* I: pwq's */
196 struct list_head pwqs; /* I: all pwqs of this wq */ 192 struct list_head pwqs; /* I: all pwqs of this wq */
197 struct list_head list; /* W: list of all workqueues */ 193 struct list_head list; /* W: list of all workqueues */
198 194
@@ -471,9 +467,11 @@ static struct pool_workqueue *get_pwq(int cpu, struct workqueue_struct *wq)
471{ 467{
472 if (!(wq->flags & WQ_UNBOUND)) { 468 if (!(wq->flags & WQ_UNBOUND)) {
473 if (likely(cpu < nr_cpu_ids)) 469 if (likely(cpu < nr_cpu_ids))
474 return per_cpu_ptr(wq->pool_wq.pcpu, cpu); 470 return per_cpu_ptr(wq->cpu_pwqs, cpu);
475 } else if (likely(cpu == WORK_CPU_UNBOUND)) 471 } else if (likely(cpu == WORK_CPU_UNBOUND)) {
476 return wq->pool_wq.single; 472 return list_first_entry(&wq->pwqs, struct pool_workqueue,
473 pwqs_node);
474 }
477 return NULL; 475 return NULL;
478} 476}
479 477
@@ -3085,8 +3083,8 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
3085 int cpu; 3083 int cpu;
3086 3084
3087 if (!(wq->flags & WQ_UNBOUND)) { 3085 if (!(wq->flags & WQ_UNBOUND)) {
3088 wq->pool_wq.pcpu = alloc_percpu(struct pool_workqueue); 3086 wq->cpu_pwqs = alloc_percpu(struct pool_workqueue);
3089 if (!wq->pool_wq.pcpu) 3087 if (!wq->cpu_pwqs)
3090 return -ENOMEM; 3088 return -ENOMEM;
3091 3089
3092 for_each_possible_cpu(cpu) { 3090 for_each_possible_cpu(cpu) {
@@ -3102,7 +3100,6 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
3102 if (!pwq) 3100 if (!pwq)
3103 return -ENOMEM; 3101 return -ENOMEM;
3104 3102
3105 wq->pool_wq.single = pwq;
3106 pwq->pool = get_std_worker_pool(WORK_CPU_UNBOUND, highpri); 3103 pwq->pool = get_std_worker_pool(WORK_CPU_UNBOUND, highpri);
3107 list_add_tail(&pwq->pwqs_node, &wq->pwqs); 3104 list_add_tail(&pwq->pwqs_node, &wq->pwqs);
3108 } 3105 }
@@ -3113,9 +3110,10 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
3113static void free_pwqs(struct workqueue_struct *wq) 3110static void free_pwqs(struct workqueue_struct *wq)
3114{ 3111{
3115 if (!(wq->flags & WQ_UNBOUND)) 3112 if (!(wq->flags & WQ_UNBOUND))
3116 free_percpu(wq->pool_wq.pcpu); 3113 free_percpu(wq->cpu_pwqs);
3117 else 3114 else if (!list_empty(&wq->pwqs))
3118 kmem_cache_free(pwq_cache, wq->pool_wq.single); 3115 kmem_cache_free(pwq_cache, list_first_entry(&wq->pwqs,
3116 struct pool_workqueue, pwqs_node));
3119} 3117}
3120 3118
3121static int wq_clamp_max_active(int max_active, unsigned int flags, 3119static int wq_clamp_max_active(int max_active, unsigned int flags,