History

workqueue: use percpu allocator for cwq on UP

I notice that the commit bbddff makes percpu allocator can work on UP, So we don't need the magic way for UP.

Lai Jiangshan committed 14 years ago

Commit e06ffa11 parent fde7d901 file · +3 −19Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+3−19
@@ -474,13 +474,8 @@ static struct cpu_workqueue_struct *get_cwq(unsigned int cpu, · 473 unmodified lines
474474 struct workqueue_struct *wq)
475475 {
476476 if (!(wq->flags & WQ_UNBOUND)) {
477− if (likely(cpu < nr_cpu_ids)) {
478−#ifdef CONFIG_SMP
477+ if (likely(cpu < nr_cpu_ids))
479478 return per_cpu_ptr(wq->cpu_wq.pcpu, cpu);
480−#else
481− return wq->cpu_wq.single;
482−#endif
483− }
484479 } else if (likely(cpu == WORK_CPU_UNBOUND))
485480 return wq->cpu_wq.single;
486481 return NULL;
@@ -2897,13 +2892,8 @@ static int alloc_cwqs(struct workqueue_struct *wq) · 2410 unmodified lines
28972892 const size_t size = sizeof(struct cpu_workqueue_struct);
28982893 const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS,
28992894 __alignof__(unsigned long long));
2900−#ifdef CONFIG_SMP
2901− bool percpu = !(wq->flags & WQ_UNBOUND);
2902−#else
2903− bool percpu = false;
2904−#endif
29052895
2906− if (percpu)
2896+ if (!(wq->flags & WQ_UNBOUND))
29072897 wq->cpu_wq.pcpu = __alloc_percpu(size, align);
29082898 else {
29092899 void *ptr;
@@ -2927,13 +2917,7 @@ static int alloc_cwqs(struct workqueue_struct *wq) · 17 unmodified lines
29272917
29282918 static void free_cwqs(struct workqueue_struct *wq)
29292919 {
2930−#ifdef CONFIG_SMP
2931− bool percpu = !(wq->flags & WQ_UNBOUND);
2932−#else
2933− bool percpu = false;
2934−#endif
2935−
2936− if (percpu)
2920+ if (!(wq->flags & WQ_UNBOUND))
29372921 free_percpu(wq->cpu_wq.pcpu);
29382922 else if (wq->cpu_wq.single) {
29392923 /* the pointer to free is stored right after the cwq */