[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zc65DUZKIx5IIgrX@slm.duckdns.org>
Date: Thu, 15 Feb 2024 15:23:25 -1000
From: Tejun Heo <tj@...nel.org>
To: Lai Jiangshan <jiangshanlai@...il.com>
Cc: linux-kernel@...r.kernel.org, torvalds@...ux-foundation.org,
Naresh Kamboju <naresh.kamboju@...aro.org>,
Anders Roxell <anders.roxell@...aro.org>,
Peter Zijlstra <peterz@...radead.org>,
Valentin Schneider <vschneid@...hat.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: [PATCH wq/for-6.9] workqueue, irq_work: Build fix for
!CONFIG_IRQ_WORK
>From 9d6efa8d0dd012db22958a225246812441b25405 Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@...nel.org>
Date: Thu, 15 Feb 2024 15:02:30 -1000
2f34d7337d98 ("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.
Signed-off-by: Tejun Heo <tj@...nel.org>
Fixes: 2f34d7337d98 ("workqueue: Fix queue_work_on() with BH workqueues")
Reported-by: Naresh Kamboju <naresh.kamboju@...aro.org>
Tested-by: Anders Roxell <anders.roxell@...aro.org>
---
Hello,
As this is breaking build for some configs, I'll apply this to wq/for-6.9.
If there's any objection, please let me know. I'll back out and work on a
different approach.
Thanks.
init/Kconfig | 2 ++
kernel/workqueue.c | 24 +++++++++++++++---------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/init/Kconfig b/init/Kconfig
index 8df18f3a9748..41be05a8ba5e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -107,6 +107,8 @@ config CONSTRUCTORS
config IRQ_WORK
bool
+ depends on SMP
+ default y
config BUILDTIME_TABLE_SORT
bool
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 04e35dbe6799..6ae441e13804 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1209,6 +1209,20 @@ static struct irq_work *bh_pool_irq_work(struct worker_pool *pool)
return &per_cpu(bh_pool_irq_works, pool->cpu)[high];
}
+static void kick_bh_pool(struct worker_pool *pool)
+{
+#ifdef CONFIG_SMP
+ if (unlikely(pool->cpu != smp_processor_id())) {
+ irq_work_queue_on(bh_pool_irq_work(pool), pool->cpu);
+ return;
+ }
+#endif
+ if (pool->attrs->nice == HIGHPRI_NICE_LEVEL)
+ raise_softirq_irqoff(HI_SOFTIRQ);
+ else
+ raise_softirq_irqoff(TASKLET_SOFTIRQ);
+}
+
/**
* kick_pool - wake up an idle worker if necessary
* @pool: pool to kick
@@ -1227,15 +1241,7 @@ static bool kick_pool(struct worker_pool *pool)
return false;
if (pool->flags & POOL_BH) {
- if (likely(pool->cpu == smp_processor_id())) {
- if (pool->attrs->nice == HIGHPRI_NICE_LEVEL)
- raise_softirq_irqoff(HI_SOFTIRQ);
- else
- raise_softirq_irqoff(TASKLET_SOFTIRQ);
- } else {
- irq_work_queue_on(bh_pool_irq_work(pool), pool->cpu);
- }
-
+ kick_bh_pool(pool);
return true;
}
--
2.43.2
Powered by blists - more mailing lists