From nobody Tue Sep 9 21:32:27 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DD8128466D for ; Fri, 5 Sep 2025 09:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063018; cv=none; b=fLEQbddWFMOJbdQ6dyZVa+AkLguZZ3/E3bbqkhZccW+zMpYofgwpFFtX63m9wNDY6bna6tDtWvuX5KEqsnuF946DNomhr/X8Ai7AXlHbiDpzbKcMbfvJmWR5c4/qe26eTJSWjP9SxBvVAoREjOUrzF1pB+XUTUIr2fDcSlE0y6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063018; c=relaxed/simple; bh=n+KhciNpsuV7q2I8UDIMYtRrlSiTbAdZNFYjuYv2wOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lvkGHCY9UFo0f46+BmSyLn780Atxy9sROKpvelVUH1TmxRSz0Ut3fzasRhscwba7MSJQGIyJxsfG6y5c9BTQwhl+3Xe0BjjllVVBPyQltIUgSKN+lxuAlO2OAeRXEXSr88hmiJ4cWmNE1CeBsZbAo8NeejXMUE2HaopuUicX9vI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=E5yUjS8i; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="E5yUjS8i" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-45b79ec2fbeso13358075e9.3 for ; Fri, 05 Sep 2025 02:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757063013; x=1757667813; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OzCSgcP8J/wJxN3+pA5atn3uFy0f4CbQVghrsqERdgY=; b=E5yUjS8irUmNGnrWc76G3mAwsqVipd2ISmV0XC9fx4DoiAeRZtuDC8pGQpOQRIQKmY Nb5c0Bo5HwDTePARRd+Nu4czD1iTLHLzaGmDNKMPUq175PY8/q4CKtjpd+AC28iYzOjZ qQNIfJBqZM2Ni9cRx+Zyd0GnS2gAN0vTbUZCJbUdOdQLD7hz65apV7l0kqSHqmHOVSLB N7z7rtVKab/KTRcsRpL7Mtsriw6lfWkpO44N6hemvObbC1SgYp7biB8mTJbHVoZWe6gz i4TikLqq4B1UdZjXGwKSFOS5xcVbRLOPq7ugT+mLdxRIQRxe3h3bolgwflndlvjjkjJ2 lh/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757063013; x=1757667813; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OzCSgcP8J/wJxN3+pA5atn3uFy0f4CbQVghrsqERdgY=; b=hBfhQuUnyef2PdZP/VJkilFLLUwh8lUhmpY3Rm2Kp3sPvz9/65N2Og6nEH9zQQyXox wIF5R7VzKCM1pNZOJOJPpuT3NEFaGfpauY54ng6CGwkM1YgVjmq1m2fZ6GooPVsgF/NK osiBPG8UEPsTEwipg3u9RzbmTqm0e5CB5FywRp637u9alyvSfY1w7STYGrdvon39r1NH wS+HvM2I/R9FNzxAnDnQ5YEj2AOV7S6KP4XIZ6KPUzpFztYDFrfkbSxegDjzNld8CqRh sPViQfnhvg6z9TGJfk553OIMOgydu+YlTu9Mxlvd8sse8ZQIkh59HhvkjYuF1FDCIIOj JuQQ== X-Gm-Message-State: AOJu0YzAAy6XEsATyFJUmXNvXq44ZMaAES9XKGYih0M/cb4Tu8t7wy1o RqBLDrPXn3ZuYDMQ6arf5uxZt4VGb3beU2nAbDnEvHZW9yFRV/x4JEhNkcmW2GLLCuI3W2Fy5Jh nzU4v X-Gm-Gg: ASbGncu8qK2PuGjIv7KfI6oi7E9v7ksbhkCWleSB/c9dWlUQlCW/NflGar64e8oq3qN CBhCbZ9cz5aot6oJqmauZcoVi5s4xI/6pVPDno7PXI6DOTHqvPsd41guDP1MlUz3cjA28WYelai iM6rmLA0UmwLU3VH6ZJeg+3yycKeTGPOnMlXDn8jHQcNBhEdfRVhdY6zvV5oLKFw2T5xMWgMf54 N5gpoYbDS1Iclb9xop5fRvu8mPulo3NfRUO701GJT5zdYwlUYYYjaKamciGiwQs7lMjPUy7Aopv sLFjd7G2DTh8oximy3PAvOBPYlqTkuLJ1DdO7NZBadi02pRTGZdN63SyRZV0attK0dbKRteHM5M valrj8DSyYRuCH7LZLk22d5lCX3ud7DUdzbr0K/ToNNV0Gbs8Vvb+E71ixP/C+bSiN0Q8 X-Google-Smtp-Source: AGHT+IHTJr8AjxhM97DIyH1nX6frQj5Bab2I9iIRm2poKuO46hcNcueAX4sXHhcrkhFS4FnEzpATPA== X-Received: by 2002:a05:600c:a0a:b0:456:1824:4808 with SMTP id 5b1f17b1804b1-45b855aeb67mr166210085e9.32.1757063013132; Fri, 05 Sep 2025 02:03:33 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf3458a67fsm3614543f8f.62.2025.09.05.02.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 02:03:32 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Andrew Morton Subject: [PATCH 1/3] mm: replace use of system_unbound_wq with system_dfl_wq Date: Fri, 5 Sep 2025 11:03:21 +0200 Message-ID: <20250905090323.103401-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905090323.103401-1-marco.crivellari@suse.com> References: <20250905090323.103401-1-marco.crivellari@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. system_unbound_wq should be the default workqueue so as not to enforce locality constraints for random work whenever it's not required. Adding system_dfl_wq to encourage its use when unbound work should be used. queue_work() / queue_delayed_work() / mod_delayed_work() will now use the new unbound wq: whether the user still use the old wq a warn will be printed along with a wq redirect to the new one. The old system_unbound_wq will be kept for a few release cycles. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- mm/backing-dev.c | 2 +- mm/kfence/core.c | 6 +++--- mm/memcontrol.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 783904d8c5ef..e9f9fdcfe052 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -934,7 +934,7 @@ void wb_memcg_offline(struct mem_cgroup *memcg) memcg_cgwb_list->next =3D NULL; /* prevent new wb's */ spin_unlock_irq(&cgwb_lock); =20 - queue_work(system_unbound_wq, &cleanup_offline_cgwbs_work); + queue_work(system_dfl_wq, &cleanup_offline_cgwbs_work); } =20 /** diff --git a/mm/kfence/core.c b/mm/kfence/core.c index 102048821c22..f26d87d59296 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -854,7 +854,7 @@ static void toggle_allocation_gate(struct work_struct *= work) /* Disable static key and reset timer. */ static_branch_disable(&kfence_allocation_key); #endif - queue_delayed_work(system_unbound_wq, &kfence_timer, + queue_delayed_work(system_dfl_wq, &kfence_timer, msecs_to_jiffies(kfence_sample_interval)); } =20 @@ -900,7 +900,7 @@ static void kfence_init_enable(void) atomic_notifier_chain_register(&panic_notifier_list, &kfence_check_canar= y_notifier); =20 WRITE_ONCE(kfence_enabled, true); - queue_delayed_work(system_unbound_wq, &kfence_timer, 0); + queue_delayed_work(system_dfl_wq, &kfence_timer, 0); =20 pr_info("initialized - using %lu bytes for %d objects at 0x%p-0x%p\n", KF= ENCE_POOL_SIZE, CONFIG_KFENCE_NUM_OBJECTS, (void *)__kfence_pool, @@ -996,7 +996,7 @@ static int kfence_enable_late(void) return kfence_init_late(); =20 WRITE_ONCE(kfence_enabled, true); - queue_delayed_work(system_unbound_wq, &kfence_timer, 0); + queue_delayed_work(system_dfl_wq, &kfence_timer, 0); pr_info("re-enabled\n"); return 0; } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 421740f1bcdc..c2944bc83378 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -651,7 +651,7 @@ static void flush_memcg_stats_dwork(struct work_struct = *w) * in latency-sensitive paths is as cheap as possible. */ __mem_cgroup_flush_stats(root_mem_cgroup, true); - queue_delayed_work(system_unbound_wq, &stats_flush_dwork, FLUSH_TIME); + queue_delayed_work(system_dfl_wq, &stats_flush_dwork, FLUSH_TIME); } =20 unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) @@ -3732,7 +3732,7 @@ static int mem_cgroup_css_online(struct cgroup_subsys= _state *css) goto offline_kmem; =20 if (unlikely(mem_cgroup_is_root(memcg)) && !mem_cgroup_disabled()) - queue_delayed_work(system_unbound_wq, &stats_flush_dwork, + queue_delayed_work(system_dfl_wq, &stats_flush_dwork, FLUSH_TIME); lru_gen_online_memcg(memcg); =20 --=20 2.51.0 From nobody Tue Sep 9 21:32:27 2025 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F267321CFF7 for ; Fri, 5 Sep 2025 09:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063018; cv=none; b=AbcTGeSH839W/bIxCgKwKwFWKAvpPnJn6dbKSJzA+hHMoKkd7IgYTJQfHCO97maxudB5LhxibKX+e+nK4UHH3I9GGcAchY1Gdj+ADnz+r3G/X3vVxpWqBFFXveep3E+tM/34tjTZRzcRF/OL1pRukSvPLhHlnKekpFGqj/Mlvjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063018; c=relaxed/simple; bh=hubxZK1Re0hKriQTvqR0pgIo1HO8CGINxFx3+0HhB98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h1jnmxx9YOFwp63YEFqUPtNKDj7sj0jcGc7KQxF9yBm+0nA0NeB+j7F7XyULrn+wwr9GOuVUzs/maddyLOUg3CYDGi5iUESRkI+DirCMu2Kswxw/WAjmQK20YWVvHEYPomSoXx2mE0rrFR4xclt5uv/gyUTtzgludU8OCWLed7w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=QywHnIH2; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="QywHnIH2" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-45dd7b15a64so4124205e9.0 for ; Fri, 05 Sep 2025 02:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757063014; x=1757667814; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k9Rqa4pGBGQ+nqaKUkB0WbuJqc5AZJEg5FxwGqJqHQw=; b=QywHnIH2wcLNQai+NtE15R3q+KhKpFS7EadWZerrN9GCDjcstd7crBs9w8QItCEVGo Ae/FIEKmLL62kTJEWWun2QP/+qe5jY+7W09qMRJ8ykraCi+wse6oAVVjv82rLgl3DzBO ZldWMVG6XhUuaqM0aQXBk4pUv8D//rN86162cUALt+H9eGprBliJdeG85XXNDLAfMBSM OvMaQ7SBc9MOlBGwRUw10RH8+jl1ZvOuP8eTVB9yURADvstS08hw5igXc5qfTX+0SGzS GdyZjB5VCtOqyrbJOYZN+1KB0E63ItaI3xcFrvRO5eApE8HvIU+OrGPJXa7o2ZzK/2VP /uDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757063014; x=1757667814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k9Rqa4pGBGQ+nqaKUkB0WbuJqc5AZJEg5FxwGqJqHQw=; b=FLmcsVllHB9eGm/4QBBZOlLX5qAdmRlWKQnGi3uKmfm/wm62PyukiVtvhi5ZmetpWU 7vgbTwttYvMcsiCsOFuYnzX20hl+WA4fm52iJvsVDk3Omftlpdkic+wDytsUPE4ulGuI 5M+bxkgH0RLX0uHsfoOk1OpOclMu2J2ak3uxN765nWGa9KO9vhbM9c4Kjk6hxcubJJZh UbY8GH0H3elWVSeL2zwVmV2dlOKQJb4M3W0kXXH4eWEzsku8OPhxLtB9ncbonxZ7lUTM daOAWB/8yZXS2BO3OlUXMP8ojMsxE5JtiUhF3Ha6w8/Nfr5LkZk7XZp8qj/AIs9qxJ5T lAJg== X-Gm-Message-State: AOJu0YxEV51hS4c/VspDtLPBI38wjOJSY5XilIqAADICSmBe7ZfW3feq Yt6+DMdgprZWIuEBu90PD1xD54OWwCWJxAH6wkergZpZl/aHYQHp0tlhCDoHE0skj4k0WRvBNpP eUafj X-Gm-Gg: ASbGncuAMmwYQZnZB+65V0Jtm2zF8y9tHrWqlSs3AhUTUMZygxK9WWa9LntjsQrU9RI gSKqgQkR5FBmNnhJ1qaqZ2ilf6YO6nJUsXmW43scQCQV7ypLbcb8psVPVgg5PGBbYt2N4ozKYCp HoB7KQ4ZmVdwwS5A38OP3t3KtXQ4X2K0/2PR6/csXEKAFX33csnrH2kdo6vWfMCJBmGuuBYCrm5 X0m7KtRZb4hbxg/A58Wwj05ID9ms18soVekHlIkLH9HuDBitWylF7rI4Xbdr1cN3d8oReRGXKsC MhAc3XlgtNwbWnGjoQH8FjWAa40CaVaD4kE7PRp3VlQfQHFlBhEEyfmdMzMZ9tCeDMn4ry3uT/G jZmIwDQCCZqTMhu2RS5oUG2+XlD82bS3wK8sQRG9FXEV/9DY= X-Google-Smtp-Source: AGHT+IF5IWr97S5oTh0sTJHYmRd+RWZpF54xEoPhZVRBSB+xqmyXwnaCsRNO69Q1AcCVvKZ1nQuUdg== X-Received: by 2002:a7b:cb41:0:b0:45d:d295:fddc with SMTP id 5b1f17b1804b1-45dd5b2282amr15894545e9.4.1757063014017; Fri, 05 Sep 2025 02:03:34 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf3458a67fsm3614543f8f.62.2025.09.05.02.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 02:03:33 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Andrew Morton Subject: [PATCH 2/3] mm: replace use of system_wq with system_percpu_wq Date: Fri, 5 Sep 2025 11:03:22 +0200 Message-ID: <20250905090323.103401-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905090323.103401-1-marco.crivellari@suse.com> References: <20250905090323.103401-1-marco.crivellari@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. system_wq is a per-CPU worqueue, yet nothing in its name tells about that CPU affinity constraint, which is very often not required by users. Make it clear by adding a system_percpu_wq to all the mm subsystem. The old wq will be kept for a few release cylces. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- mm/backing-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index e9f9fdcfe052..7e672424f928 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -966,7 +966,7 @@ static int __init cgwb_init(void) { /* * There can be many concurrent release work items overwhelming - * system_wq. Put them in a separate wq and limit concurrency. + * system_percpu_wq. Put them in a separate wq and limit concurrency. * There's no point in executing many of these in parallel. */ cgwb_release_wq =3D alloc_workqueue("cgwb_release", 0, 1); --=20 2.51.0 From nobody Tue Sep 9 21:32:27 2025 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1378828851F for ; Fri, 5 Sep 2025 09:03:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063018; cv=none; b=TGpUd2lBK1Xdr0W/BB8WK5SxBxMLIwnhdaGO9RZfxslxpe5pJzJmld7Na0pAlT+1bMAsGQEpe7vqHvarzohhfSFloLj8ETxufQ3MjUEGtTi5wrJ7Os/61C8DOYfd+TEFLHhNs/BL0zWbRMfQOmWXdfeULkkk84lil5URdAOYofw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063018; c=relaxed/simple; bh=x0SccWkwwkQaMO1gCO3MC2G88/zGpVNyC8XvWOJlo5U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LGF6LPy+uc1hcEAPQoovhPJ39qDKtlqndiy8N95dnCH5uQ/LHEggaD9qLP8wsDafbHtJN9ozzD18S1FFFSTRu+UKZySj85rgeD4MiiRpKzQFM8Gc34u8Y9Vr/fKj5ruo79cdNHjJ14OdiBARdrcidhoxIvX0A0HI9tDMxXJVx0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Fe8cPrFM; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Fe8cPrFM" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3df2f4aedc7so1150991f8f.2 for ; Fri, 05 Sep 2025 02:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757063015; x=1757667815; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dYtBCkO9DqKzKcyS43porMi3LTjby1/YOgTfwITaJ5Q=; b=Fe8cPrFMp5q7sOnNUyeKVCHrwdmT2TGzHoxuyLwMqizb9l4Vel0PbQMX2B167myHeg TjR1+8iIxT9UtBoRbumfzLMdr0gk8HYhgEF5Ia92R+IRPCRhhQLmj0qe1QDK99YIGNdk zsHVi1c5mDf3j3iag7YgXHSLcAcZAUKB8IVaATT8ALxyFwxJWgTvVEix5ZBN+VddSOBP 710Zyi8eQnpEkkmHcDbJTCht9ZktketqHe/Wa0VcYkhhI/wo+hfwbAVEJzuBzXhzupRy TN+jGrvqSqgoJEwprqUyz3j17qCM13KaO8c6EBUyfY6thGJueddt7FpcVq4Q/oqHqd+8 nfCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757063015; x=1757667815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dYtBCkO9DqKzKcyS43porMi3LTjby1/YOgTfwITaJ5Q=; b=VYo8viGtnsZKRQFC1TJkA2ND7z9mjwE21OHdr5bLPigiDj9sPbH/P9iecWDMsV1txx Bzwb5cVg8j6EYNrPRXkCwskypd1UUOa9seaUsOq+SrjWVwnB4nIWdpLP/abKvcQpFaxM zoMdt/a51rQiazSDZJB/lzmvCdEV3ZLyhx9lP487gLBH5GpxgumljihsN2BfKYE8UtYa v8qrhrVh6rgq431L5aeaCo7YvLZBc8cIJADNb6lUcj3ajkdudu1kA23yVA3YBWig9E+3 dbqrz9Xk3r2Yn4Ix1YMcdMZ2B4lnZYy83oNWUFTMhGrERKQ9VSxCMM31v9Zh+9y0Q3MD P3Pw== X-Gm-Message-State: AOJu0YyRTVUbAS1o32Krvyt01QLv5GhGs+WxYNJ0ED9YRF8xOCEJlgLS F/+di0VZHNyW/7OB3TPlzjyOd/lGxxUTy0cW+2V5T8oighMfk6cvjZi4Z+196MSyWE7w2L68o4F 9vLDS X-Gm-Gg: ASbGnctBVj0rvJ3vgC0OQaRFXYSh8iJxm5JZSO9uKqzmdy09buf2a8bZrm4WpBhU6bG KkNysjku10qhWjje6ERTBJkH6E5FvjGxoYdubrdbepxQ0Ip1YqZebeK/Vhowl16JU6xZT5HMgXt f8hw87Xe+gguZcAFycMfC5FzHVNr9LsziNqxc4t3b5tTzz/hTx0ucdrRJJaJF1FTJyg0EN+tqY2 d6vh+/rKEl5lpgtby66HjcbC8ILGTr0sPJF+Q28OxpxTwSBp4J6I1m5WiQFPFPApARVHK27e2v1 Xvr86+gV96jV2hHGt0iytAP+kaZm+R33VcIV/8LLebd8kadtU0Q0sitjWhHyZYg+uChkSVpbwal CAZLGYqD2e0UNxcQWy/IH1HauUPLAWT9Cj/t5a4Ua3pU0Q25pIiIrqHvM5w== X-Google-Smtp-Source: AGHT+IEjaLZymkByczPO22uKZMFn/gyrcDISUwcAhC9QIjk27LsuQ5PsAm7XYe1kQO+OONf4843osQ== X-Received: by 2002:a05:6000:2586:b0:3cd:c10d:3b6b with SMTP id ffacd0b85a97d-3d1de4b9891mr17256852f8f.27.1757063015005; Fri, 05 Sep 2025 02:03:35 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf3458a67fsm3614543f8f.62.2025.09.05.02.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 02:03:34 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Andrew Morton Subject: [PATCH 3/3] mm: WQ_PERCPU added to alloc_workqueue users Date: Fri, 5 Sep 2025 11:03:23 +0200 Message-ID: <20250905090323.103401-4-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905090323.103401-1-marco.crivellari@suse.com> References: <20250905090323.103401-1-marco.crivellari@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. alloc_workqueue() treats all queues as per-CPU by default, while unbound workqueues must opt-in via WQ_UNBOUND. This default is suboptimal: most workloads benefit from unbound queues, allowing the scheduler to place worker threads where they=E2=80=99re needed= and reducing noise when CPUs are isolated. This default is suboptimal: most workloads benefit from unbound queues, allowing the scheduler to place worker threads where they=E2=80=99re needed= and reducing noise when CPUs are isolated. This patch adds a new WQ_PERCPU flag to all the mm subsystem users to explicitly request the use of the per-CPU behavior. Both flags coexist for one release cycle to allow callers to transition their calls. Once migration is complete, WQ_UNBOUND can be removed and unbound will become the implicit default. With the introduction of the WQ_PERCPU flag (equivalent to !WQ_UNBOUND), any alloc_workqueue() caller that doesn=E2=80=99t explicitly specify WQ_UNB= OUND must now use WQ_PERCPU. All existing users have been updated accordingly. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- mm/backing-dev.c | 2 +- mm/slub.c | 3 ++- mm/vmstat.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 7e672424f928..3b392de6367e 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -969,7 +969,7 @@ static int __init cgwb_init(void) * system_percpu_wq. Put them in a separate wq and limit concurrency. * There's no point in executing many of these in parallel. */ - cgwb_release_wq =3D alloc_workqueue("cgwb_release", 0, 1); + cgwb_release_wq =3D alloc_workqueue("cgwb_release", WQ_PERCPU, 1); if (!cgwb_release_wq) return -ENOMEM; =20 diff --git a/mm/slub.c b/mm/slub.c index b46f87662e71..cac9d5d7c924 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -6364,7 +6364,8 @@ void __init kmem_cache_init(void) void __init kmem_cache_init_late(void) { #ifndef CONFIG_SLUB_TINY - flushwq =3D alloc_workqueue("slub_flushwq", WQ_MEM_RECLAIM, 0); + flushwq =3D alloc_workqueue("slub_flushwq", WQ_MEM_RECLAIM | WQ_PERCPU, + 0); WARN_ON(!flushwq); #endif } diff --git a/mm/vmstat.c b/mm/vmstat.c index 4c268ce39ff2..57bf76b1d9d4 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2244,7 +2244,8 @@ void __init init_mm_internals(void) { int ret __maybe_unused; =20 - mm_percpu_wq =3D alloc_workqueue("mm_percpu_wq", WQ_MEM_RECLAIM, 0); + mm_percpu_wq =3D alloc_workqueue("mm_percpu_wq", + WQ_MEM_RECLAIM | WQ_PERCPU, 0); =20 #ifdef CONFIG_SMP ret =3D cpuhp_setup_state_nocalls(CPUHP_MM_VMSTAT_DEAD, "mm/vmstat:dead", --=20 2.51.0