I notice that the commit bbddff makes percpu allocator can work on UP, So we don't need the magic way for UP.
Showing the changes to kernel/workqueue.c (1 of 1 file). Show all
Unified · Split
| @@ -474,13 +474,8 @@ static struct cpu_workqueue_struct *get_cwq(unsigned int cpu, · 473 unmodified lines | ||
| 474 | 474 | struct workqueue_struct *wq) |
| 475 | 475 | { |
| 476 | 476 | if (!(wq->flags & WQ_UNBOUND)) { |
| 477 | − if (likely(cpu < nr_cpu_ids)) { | |
| 478 | −#ifdef CONFIG_SMP | |
| 477 | + if (likely(cpu < nr_cpu_ids)) | |
| 479 | 478 | return per_cpu_ptr(wq->cpu_wq.pcpu, cpu); |
| 480 | −#else | |
| 481 | − return wq->cpu_wq.single; | |
| 482 | −#endif | |
| 483 | − } | |
| 484 | 479 | } else if (likely(cpu == WORK_CPU_UNBOUND)) |
| 485 | 480 | return wq->cpu_wq.single; |
| 486 | 481 | return NULL; |
| @@ -2897,13 +2892,8 @@ static int alloc_cwqs(struct workqueue_struct *wq) · 2410 unmodified lines | ||
| 2897 | 2892 | const size_t size = sizeof(struct cpu_workqueue_struct); |
| 2898 | 2893 | const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS, |
| 2899 | 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 | 2897 | wq->cpu_wq.pcpu = __alloc_percpu(size, align); |
| 2908 | 2898 | else { |
| 2909 | 2899 | void *ptr; |
| @@ -2927,13 +2917,7 @@ static int alloc_cwqs(struct workqueue_struct *wq) · 17 unmodified lines | ||
| 2927 | 2917 | |
| 2928 | 2918 | static void free_cwqs(struct workqueue_struct *wq) |
| 2929 | 2919 | { |
| 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)) | |
| 2937 | 2921 | free_percpu(wq->cpu_wq.pcpu); |
| 2938 | 2922 | else if (wq->cpu_wq.single) { |
| 2939 | 2923 | /* the pointer to free is stored right after the cwq */ |