[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260206-feature-dynamic_isolcpus_dhei-v1-7-00a711eb0c74@gmail.com>
Date: Fri, 06 Feb 2026 02:04:28 -0500
From: Qiliang Yuan <realwujing@...il.com>
To: Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>,
Mel Gorman <mgorman@...e.de>, Valentin Schneider <vschneid@...hat.com>,
Thomas Gleixner <tglx@...nel.org>, "Paul E. McKenney" <paulmck@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Neeraj Upadhyay <neeraj.upadhyay@...nel.org>,
Joel Fernandes <joelagnelf@...dia.com>,
Josh Triplett <josh@...htriplett.org>, Boqun Feng <boqun.feng@...il.com>,
Uladzislau Rezki <urezki@...il.com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>, Zqiang <qiang.zhang@...ux.dev>,
Tejun Heo <tj@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>, Suren Baghdasaryan <surenb@...gle.com>,
Michal Hocko <mhocko@...e.com>, Brendan Jackman <jackmanb@...gle.com>,
Johannes Weiner <hannes@...xchg.org>, Zi Yan <ziy@...dia.com>,
Anna-Maria Behnsen <anna-maria@...utronix.de>,
Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org, rcu@...r.kernel.org, linux-mm@...ck.org,
Qiliang Yuan <realwujing@...il.com>, Qiliang Yuan <yuanql9@...natelecom.cn>
Subject: [PATCH RFC 07/12] workqueue: Dynamic housekeeping mask update
support
Workqueues use housekeeping masks (HK_TYPE_WQ and HK_TYPE_DOMAIN) to
determine the default affinity for unbound workqueues. Currently,
these masks are only applied during early boot.
Register a housekeeping notifier to dynamically update the workqueue
unbound cpumask when these housekeeping masks are changed at runtime.
This ensures that unbound workqueues are re-affined to the new
housekeeping CPUs. Also update wq_isolated_cpumask to reflect the
changes in HK_TYPE_DOMAIN.
Signed-off-by: Qiliang Yuan <realwujing@...il.com>
Signed-off-by: Qiliang Yuan <yuanql9@...natelecom.cn>
---
kernel/workqueue.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 253311af47c6..b8913935d5e8 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -7913,6 +7913,44 @@ static void __init wq_cpu_intensive_thresh_init(void)
* executing the work items yet. Populate the worker pools with the initial
* workers and enable future kworker creations.
*/
+static int wq_housekeeping_reconfigure(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ if (action == HK_UPDATE_MASK) {
+ unsigned int type = (unsigned long)data;
+
+ if (type == HK_TYPE_WQ || type == HK_TYPE_DOMAIN) {
+ cpumask_var_t cpumask;
+
+ if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
+ return NOTIFY_BAD;
+
+ cpumask_copy(cpumask, cpu_possible_mask);
+ if (!cpumask_empty(housekeeping_cpumask(HK_TYPE_WQ)))
+ cpumask_and(cpumask, cpumask, housekeeping_cpumask(HK_TYPE_WQ));
+ if (!cpumask_empty(housekeeping_cpumask(HK_TYPE_DOMAIN)))
+ cpumask_and(cpumask, cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
+
+ workqueue_set_unbound_cpumask(cpumask);
+
+ if (type == HK_TYPE_DOMAIN) {
+ apply_wqattrs_lock();
+ cpumask_andnot(wq_isolated_cpumask, cpu_possible_mask,
+ housekeeping_cpumask(HK_TYPE_DOMAIN));
+ apply_wqattrs_unlock();
+ }
+
+ free_cpumask_var(cpumask);
+ }
+ }
+
+ return NOTIFY_OK;
+}
+
+static struct notifier_block wq_housekeeping_nb = {
+ .notifier_call = wq_housekeeping_reconfigure,
+};
+
void __init workqueue_init(void)
{
struct workqueue_struct *wq;
@@ -7964,6 +8002,7 @@ void __init workqueue_init(void)
wq_online = true;
wq_watchdog_init();
+ housekeeping_register_notifier(&wq_housekeeping_nb);
}
/*
--
2.51.0
Powered by blists - more mailing lists