diff options
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index aca94726e20a..79a11e40f311 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -2615,11 +2615,15 @@ static int alloc_cwqs(struct workqueue_struct *wq) | |||
2615 | const size_t size = sizeof(struct cpu_workqueue_struct); | 2615 | const size_t size = sizeof(struct cpu_workqueue_struct); |
2616 | const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS, | 2616 | const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS, |
2617 | __alignof__(unsigned long long)); | 2617 | __alignof__(unsigned long long)); |
2618 | #ifdef CONFIG_SMP | ||
2619 | bool percpu = !(wq->flags & WQ_UNBOUND); | ||
2620 | #else | ||
2621 | bool percpu = false; | ||
2622 | #endif | ||
2618 | 2623 | ||
2619 | if (CONFIG_SMP && !(wq->flags & WQ_UNBOUND)) { | 2624 | if (percpu) |
2620 | /* on SMP, percpu allocator can align itself */ | ||
2621 | wq->cpu_wq.pcpu = __alloc_percpu(size, align); | 2625 | wq->cpu_wq.pcpu = __alloc_percpu(size, align); |
2622 | } else { | 2626 | else { |
2623 | void *ptr; | 2627 | void *ptr; |
2624 | 2628 | ||
2625 | /* | 2629 | /* |
@@ -2641,7 +2645,13 @@ static int alloc_cwqs(struct workqueue_struct *wq) | |||
2641 | 2645 | ||
2642 | static void free_cwqs(struct workqueue_struct *wq) | 2646 | static void free_cwqs(struct workqueue_struct *wq) |
2643 | { | 2647 | { |
2644 | if (CONFIG_SMP && !(wq->flags & WQ_UNBOUND)) | 2648 | #ifdef CONFIG_SMP |
2649 | bool percpu = !(wq->flags & WQ_UNBOUND); | ||
2650 | #else | ||
2651 | bool percpu = false; | ||
2652 | #endif | ||
2653 | |||
2654 | if (percpu) | ||
2645 | free_percpu(wq->cpu_wq.pcpu); | 2655 | free_percpu(wq->cpu_wq.pcpu); |
2646 | else if (wq->cpu_wq.single) { | 2656 | else if (wq->cpu_wq.single) { |
2647 | /* the pointer to free is stored right after the cwq */ | 2657 | /* the pointer to free is stored right after the cwq */ |