diff options
| author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2012-03-09 05:03:20 -0500 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2012-03-12 12:21:17 -0400 |
| commit | e06ffa1ede4146cbc261d90f5dff3d63fe2e9d7a (patch) | |
| tree | 3d8a7bccc95926aeb08c1b03e1ea8cffe722d38c | |
| parent | fde7d9049e55ab85a390be7f415d74c9f62dd0f9 (diff) | |
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.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
| -rw-r--r-- | kernel/workqueue.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index bec7b5b53e03..5bbba094bfac 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -474,13 +474,8 @@ static struct cpu_workqueue_struct *get_cwq(unsigned int cpu, | |||
| 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) | |||
| 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) | |||
| 2927 | 2917 | ||
| 2928 | static void free_cwqs(struct workqueue_struct *wq) | 2918 | static void free_cwqs(struct workqueue_struct *wq) |
| 2929 | { | 2919 | { |
| 2930 | #ifdef CONFIG_SMP | 2920 | 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 */ |
