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
474 struct workqueue_struct *wq)474 struct workqueue_struct *wq)
475{475{
476 if (!(wq->flags & WQ_UNBOUND)) {476 if (!(wq->flags & WQ_UNBOUND)) {
477 if (likely(cpu < nr_cpu_ids)) {477 if (likely(cpu < nr_cpu_ids))
478#ifdef CONFIG_SMP
479 return per_cpu_ptr(wq->cpu_wq.pcpu, cpu);478 return per_cpu_ptr(wq->cpu_wq.pcpu, cpu);
480#else
481 return wq->cpu_wq.single;
482#endif
483 }
484 } else if (likely(cpu == WORK_CPU_UNBOUND))479 } else if (likely(cpu == WORK_CPU_UNBOUND))
485 return wq->cpu_wq.single;480 return wq->cpu_wq.single;
486 return NULL;481 return NULL;
@@ -2897,13 +2892,8 @@ static int alloc_cwqs(struct workqueue_struct *wq) · 2410 unmodified lines
2897 const size_t size = sizeof(struct cpu_workqueue_struct);2892 const size_t size = sizeof(struct cpu_workqueue_struct);
2898 const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS,2893 const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS,
2899 __alignof__(unsigned long long));2894 __alignof__(unsigned long long));
2900#ifdef CONFIG_SMP
2901 bool percpu = !(wq->flags & WQ_UNBOUND);
2902#else
2903 bool percpu = false;
2904#endif
2905 2895
2906 if (percpu)2896 if (!(wq->flags & WQ_UNBOUND))
2907 wq->cpu_wq.pcpu = __alloc_percpu(size, align);2897 wq->cpu_wq.pcpu = __alloc_percpu(size, align);
2908 else {2898 else {
2909 void *ptr;2899 void *ptr;
@@ -2927,13 +2917,7 @@ static int alloc_cwqs(struct workqueue_struct *wq) · 17 unmodified lines
2927 2917
2928static void free_cwqs(struct workqueue_struct *wq)2918static void free_cwqs(struct workqueue_struct *wq)
2929{2919{
2930#ifdef CONFIG_SMP2920 if (!(wq->flags & WQ_UNBOUND))
2931 bool percpu = !(wq->flags & WQ_UNBOUND);
2932#else
2933 bool percpu = false;
2934#endif
2935
2936 if (percpu)
2937 free_percpu(wq->cpu_wq.pcpu);2921 free_percpu(wq->cpu_wq.pcpu);
2938 else if (wq->cpu_wq.single) {2922 else if (wq->cpu_wq.single) {
2939 /* the pointer to free is stored right after the cwq */2923 /* the pointer to free is stored right after the cwq */