From: Lai Jiangshan <jiangshanlai@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <jiangshan.ljs@antgroup.com>,
Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Subject: [PATCH 1/7] workqueue: Add wq_online_cpumask
Date: Thu, 11 Jul 2024 16:35:41 +0800 [thread overview]
Message-ID: <20240711083547.3981-2-jiangshanlai@gmail.com> (raw)
In-Reply-To: <20240711083547.3981-1-jiangshanlai@gmail.com>
From: Lai Jiangshan <jiangshan.ljs@antgroup.com>
The new wq_online_mask mirrors the cpu_online_mask except during
hotplugging; specifically, it differs between the hotplugging stages
of workqueue_offline_cpu() and workqueue_online_cpu(), during which
the transitioning CPU is not represented in the mask.
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
kernel/workqueue.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 5d362290c2e8..985ab9230fe0 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -444,6 +444,9 @@ static struct rcuwait manager_wait = __RCUWAIT_INITIALIZER(manager_wait);
static LIST_HEAD(workqueues); /* PR: list of all workqueues */
static bool workqueue_freezing; /* PL: have wqs started freezing? */
+/* PL: mirror the cpu_online_mask excluding the CPU in the midst of hotplugging */
+static cpumask_var_t wq_online_cpumask;
+
/* PL&A: allowable cpus for unbound wqs and work items */
static cpumask_var_t wq_unbound_cpumask;
@@ -6583,6 +6586,8 @@ int workqueue_online_cpu(unsigned int cpu)
mutex_lock(&wq_pool_mutex);
+ cpumask_set_cpu(cpu, wq_online_cpumask);
+
for_each_pool(pool, pi) {
/* BH pools aren't affected by hotplug */
if (pool->flags & POOL_BH)
@@ -6629,6 +6634,9 @@ int workqueue_offline_cpu(unsigned int cpu)
/* update pod affinity of unbound workqueues */
mutex_lock(&wq_pool_mutex);
+
+ cpumask_clear_cpu(cpu, wq_online_cpumask);
+
list_for_each_entry(wq, &workqueues, list) {
struct workqueue_attrs *attrs = wq->unbound_attrs;
@@ -7650,10 +7658,12 @@ void __init workqueue_init_early(void)
BUILD_BUG_ON(__alignof__(struct pool_workqueue) < __alignof__(long long));
+ BUG_ON(!alloc_cpumask_var(&wq_online_cpumask, GFP_KERNEL));
BUG_ON(!alloc_cpumask_var(&wq_unbound_cpumask, GFP_KERNEL));
BUG_ON(!alloc_cpumask_var(&wq_requested_unbound_cpumask, GFP_KERNEL));
BUG_ON(!zalloc_cpumask_var(&wq_isolated_cpumask, GFP_KERNEL));
+ cpumask_copy(wq_online_cpumask, cpu_online_mask);
cpumask_copy(wq_unbound_cpumask, cpu_possible_mask);
restrict_unbound_cpumask("HK_TYPE_WQ", housekeeping_cpumask(HK_TYPE_WQ));
restrict_unbound_cpumask("HK_TYPE_DOMAIN", housekeeping_cpumask(HK_TYPE_DOMAIN));
--
2.19.1.6.gb485710b
next prev parent reply other threads:[~2024-07-11 8:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 8:35 [PATCH 0/7] Add wq_online_cpumask and remove cpus_read_lock() from apply_wqattrs_lock() Lai Jiangshan
2024-07-11 8:35 ` Lai Jiangshan [this message]
2024-07-11 8:35 ` [PATCH 2/7] workqueue: Simplify wq_calc_pod_cpumask() with wq_online_cpumask Lai Jiangshan
2024-07-11 8:35 ` [PATCH 3/7] workqueue: Remove cpus_read_lock() from apply_wqattrs_lock() Lai Jiangshan
2024-07-11 17:11 ` [PATCH UPDATED " Tejun Heo
2024-07-15 15:13 ` Daniel Jordan
2024-07-15 17:22 ` Tejun Heo
2024-07-16 2:01 ` [PATCH " Pengfei Xu
2024-07-11 8:35 ` [PATCH 4/7] workqueue: Remove the unneeded cpumask empty check in wq_calc_pod_cpumask() Lai Jiangshan
2024-07-11 8:35 ` [PATCH 5/7] workqueue: Remove the argument @cpu_going_down from wq_calc_pod_cpumask() Lai Jiangshan
2024-07-11 8:35 ` [PATCH 6/7] workqueue: Remove the arguments @hotplug_cpu and @online from wq_update_pod() Lai Jiangshan
2024-07-11 8:35 ` [PATCH 7/7] workqueue: Rename wq_update_pod() to unbound_wq_update_pwq() Lai Jiangshan
2024-07-11 17:12 ` [PATCH 0/7] Add wq_online_cpumask and remove cpus_read_lock() from apply_wqattrs_lock() Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240711083547.3981-2-jiangshanlai@gmail.com \
--to=jiangshanlai@gmail.com \
--cc=jiangshan.ljs@antgroup.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox