Commit 931ac77ef65d2d90ee1def63d2041402ec7c53ab

Authored by Tejun Heo
1 parent 9f9c23644b

workqueue: fix build problem on !CONFIG_SMP

Commit f3421797 (workqueue: implement unbound workqueue) incorrectly
tested CONFIG_SMP as part of a C expression in alloc/free_cwqs().  As
CONFIG_SMP is not defined in UP, this breaks build.  Fix it by using

Found during linux-next build test.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>

Showing 1 changed file with 14 additions and 4 deletions Side-by-side Diff

... ... @@ -2615,11 +2615,15 @@
2615 2615 const size_t size = sizeof(struct cpu_workqueue_struct);
2616 2616 const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS,
2617 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)) {
2620   - /* on SMP, percpu allocator can align itself */
  2624 + if (percpu)
2621 2625 wq->cpu_wq.pcpu = __alloc_percpu(size, align);
2622   - } else {
  2626 + else {
2623 2627 void *ptr;
2624 2628  
2625 2629 /*
... ... @@ -2641,7 +2645,13 @@
2641 2645  
2642 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 2655 free_percpu(wq->cpu_wq.pcpu);
2646 2656 else if (wq->cpu_wq.single) {
2647 2657 /* the pointer to free is stored right after the cwq */