Skip to content

Commit fd0a68a

Browse files
committed
workqueue, irq_work: Build fix for !CONFIG_IRQ_WORK
2f34d73 ("workqueue: Fix queue_work_on() with BH workqueues") added irq_work usage to workqueue; however, it turns out irq_work is actually optional and the change breaks build on configuration which doesn't have CONFIG_IRQ_WORK enabled. Fix build by making workqueue use irq_work only when CONFIG_SMP and enabling CONFIG_IRQ_WORK when CONFIG_SMP is set. It's reasonable to argue that it may be better to just always enable it. However, this still saves a small bit of memory for tiny UP configs and also the least amount of change, so, for now, let's keep it conditional. Verified to do the right thing for x86_64 allnoconfig and defconfig, and aarch64 allnoconfig, allnoconfig + prink disable (SMP but nothing selects IRQ_WORK) and a modified aarch64 Kconfig where !SMP and nothing selects IRQ_WORK. v2: `depends on SMP` leads to Kconfig warnings when CONFIG_IRQ_WORK is selected by something else when !CONFIG_SMP. Use `def_bool y if SMP` instead. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org> Tested-by: Anders Roxell <anders.roxell@linaro.org> Fixes: 2f34d73 ("workqueue: Fix queue_work_on() with BH workqueues") Cc: Stephen Rothwell <sfr@canb.auug.org.au>
1 parent 2f34d73 commit fd0a68a

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

init/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ config CONSTRUCTORS
106106
bool
107107

108108
config IRQ_WORK
109-
bool
109+
def_bool y if SMP
110110

111111
config BUILDTIME_TABLE_SORT
112112
bool

kernel/workqueue.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,20 @@ static struct irq_work *bh_pool_irq_work(struct worker_pool *pool)
12091209
return &per_cpu(bh_pool_irq_works, pool->cpu)[high];
12101210
}
12111211

1212+
static void kick_bh_pool(struct worker_pool *pool)
1213+
{
1214+
#ifdef CONFIG_SMP
1215+
if (unlikely(pool->cpu != smp_processor_id())) {
1216+
irq_work_queue_on(bh_pool_irq_work(pool), pool->cpu);
1217+
return;
1218+
}
1219+
#endif
1220+
if (pool->attrs->nice == HIGHPRI_NICE_LEVEL)
1221+
raise_softirq_irqoff(HI_SOFTIRQ);
1222+
else
1223+
raise_softirq_irqoff(TASKLET_SOFTIRQ);
1224+
}
1225+
12121226
/**
12131227
* kick_pool - wake up an idle worker if necessary
12141228
* @pool: pool to kick
@@ -1227,15 +1241,7 @@ static bool kick_pool(struct worker_pool *pool)
12271241
return false;
12281242

12291243
if (pool->flags & POOL_BH) {
1230-
if (likely(pool->cpu == smp_processor_id())) {
1231-
if (pool->attrs->nice == HIGHPRI_NICE_LEVEL)
1232-
raise_softirq_irqoff(HI_SOFTIRQ);
1233-
else
1234-
raise_softirq_irqoff(TASKLET_SOFTIRQ);
1235-
} else {
1236-
irq_work_queue_on(bh_pool_irq_work(pool), pool->cpu);
1237-
}
1238-
1244+
kick_bh_pool(pool);
12391245
return true;
12401246
}
12411247

0 commit comments

Comments
 (0)