From nobody Tue Sep 9 21:32:22 2025 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 9A6BE28000F for ; Fri, 5 Sep 2025 08:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062523; cv=none; b=T8iz7wJqZeKh36LBeSPozcG1IEhDLICLx57Tq/qMhgHJCqEHhYTOnE6TArdc8bfnWmQGTtpQ8fpJB0MuQbIr0EUuXbIBZB250CY62c3s6sQRt4scv2OsmaW4Ws5VU4ESrc6Er1BM9rJ51l6PLYi7yFKncR8o2ScKf+WkMv/DlP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062523; c=relaxed/simple; bh=rPqk/i8FHiso17+h8HR95Fljzg9ubNSYBKvqESikwFM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i6S3Qm3ereVWf1RsbWdcZtIXQylp1rbr95GvTW0JtyQUzMoSYUfGkg5ANKFz00roArdKYsMGddwTAIlHYnjimJr8EAcAuxg4JrRGUc8/y/vswe5MOLNyrQnEqMXgXjei63xKPkOCc9Ox9sYJBcXJtdvAhTmmMxjmS+faUtoqzTU= 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=M/0j53tF; arc=none smtp.client-ip=209.85.128.42 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="M/0j53tF" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-45dda7d87faso1799495e9.2 for ; Fri, 05 Sep 2025 01:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757062518; x=1757667318; 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=QAGsQ/32s/KKYkZau8Rby6xoFYH4N+/s1hCU9vRuvK8=; b=M/0j53tF/wAPQ7/tLbaOR8uKHqPRRnpGXcmgg8wiOT3BrO++pDCR0ZW5Yujlt3JFMb E0StLcNHgxYol00GNOAQIjBKEyFah2rMs4usckGCya87qHhR4DnKYID0KpPo1sTN6lkB bSRF1CjjW+qBeelfXySXMGjybezase9/H+w4j+JtIElR93L7nqZVoXLKpURsu9vlxu8j wXKZ8FjN8/6kNjTDzB9isn6P0SEfXnrtQMDtO1kw8nhVxKQKEW9x9JsIxNKfOAOSdo3r VFlEccQ5zqWkwk0HlPyuQpS7qNGIT3II4oHU3nJ4PTQ2Ofs5WN2KBjlvRjmcq2KFltD7 0JvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757062518; x=1757667318; 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=QAGsQ/32s/KKYkZau8Rby6xoFYH4N+/s1hCU9vRuvK8=; b=PxnDyeVkUUS8DQFK1yEMkRb98Cjwh4VGRuMLHkz7ff0SpiP+tT/2JacLVedCWCyctF 5+QVikpR36+Zd32ogNyD5ZSozMZy8JL57pIAxmOuF9wJRbbUSqdhSZmLl0+Y5avzHCrK fUaa8Vjo+VHREURKgVHeLhMvCeRzFiXl1Si8TWTzw149GS/rgBYcUA+/U1o/ptNYMaoe jGSMWfDnejlt1RlJ44crY6Av4lkjD/Vw2mOlp7Ead5k0JTHKPIwCtd1QUYsNTOKadFBN Ancbpe/lGgecOVaUNyTfSB4hdboI+iCzIqE8bb5S9v+zWpVpe+LPEfDw1dq0Ni3mGwJ1 D6NA== X-Gm-Message-State: AOJu0Yz8NhsBHaFjZFPpcgRqVYCogTlRwFNRsowM5s7to8F6/SvCmpld qTaPJqvPpza/I3KKrRjU3v8DuE6sLZWMkNuKKP1nFX0gouD2WZpjVGpRs0B4gqL+P3dAoww/aoS Rb2Vz X-Gm-Gg: ASbGncv37yYg8ZRF2wxhX19ZQ5QzcNwHGN6E1r/J/vQTYBASGagedrC2Gx4FrymKR2x Eem8JtjjcwSCMRJEEbvNflA/sCocL9ualOS4GoLKtH/hzN8AXY8vqGJHFApsmGOVZsqv8T9Ltyj gNf2iOaGLqyphJxQ+ukggALgPHteMvffvRBCKsQuSDJWzJHQGSCGoXPSTR58fwRbdTSP7g1eh/k ybtvzzrlkEunyDrFCU2ax/ZKE60llKPZeAZ2ifA5s0XClmyR9Uh4J/QjEgKBIvFPw7b5oQ49got ZzZGEhkKqroy464ym57G+TM7O4zKXR2hGG9g48EC9VlxwTYtnuwLuZXYvdkYzA5dWkcu6Y39hVj w8FhIbAQuCSZEAyJks/6IsKEfOSjM3tSV9PGo8AIZQB+V1N3eKiqwubtIOg== X-Google-Smtp-Source: AGHT+IEIeeWlv5Y1zYgVrT7F52IJeE+DGSxWfwj/+Ab75L8oWqb439G29fc+gz412+/+BrWVo8S3uQ== X-Received: by 2002:a05:6000:3111:b0:3dd:6101:4efb with SMTP id ffacd0b85a97d-3dd61015026mr8283880f8f.11.1757062518456; Fri, 05 Sep 2025 01:55:18 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d21a32dbc5sm28178346f8f.11.2025.09.05.01.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 01:55:18 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Johannes Weiner , Michal Koutny Subject: [PATCH 1/2] cgroup: replace use of system_wq with system_percpu_wq Date: Fri, 5 Sep 2025 10:54:35 +0200 Message-ID: <20250905085436.95863-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905085436.95863-1-marco.crivellari@suse.com> References: <20250905085436.95863-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. queue_work() / queue_delayed_work() mod_delayed_work() will now use the new per-cpu wq: whether the user still stick on the old name a warn will be printed along a wq redirect to the new one. This patch add the new system_percpu_wq except for mm, fs and net subsystem, whom are handled in separated patches. The old wq will be kept for a few release cylces. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- kernel/cgroup/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 3caf2cd86e65..1e39355194fd 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -121,7 +121,7 @@ DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem); /* * cgroup destruction makes heavy use of work items and there can be a lot * of concurrent destructions. Use a separate workqueue so that cgroup - * destruction work items don't end up filling up max_active of system_wq + * destruction work items don't end up filling up max_active of system_per= cpu_wq * which may lead to deadlock. */ static struct workqueue_struct *cgroup_destroy_wq; --=20 2.51.0 From nobody Tue Sep 9 21:32:22 2025 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 692F62820BA for ; Fri, 5 Sep 2025 08:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062524; cv=none; b=OTuyhK7lwjq/IHLjIcoVyzN3FqgW8rlrIpVWgfbVkA77Hk18s0/Qwmasbkep4RjO5fhFdijUYBenVZPtikfYO5vKSfRU6NPrhq+PCHBgMU6Z7nn7d9FvubPz6v9UUFHc1XLIwIH+twDL/yXHyRpA2+TRSy+7MhU9mJoE22vqnO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062524; c=relaxed/simple; bh=W33kCBQrq1sazmSN8/SXjWeRCYxWjdmqGuSQHrjaZxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SL2LgehAMBOU/nyS+ccVNHGl6nB6QOPn+z1lmYLQziCwa/0ZwTqVqReuyB7jIn5oWTG6O5U79Ie62oS28WhgiJfAgL9QmZQsyL0wy7Vk2dfSny3hfzpbHLVKqzj4ohOb4PdjRwNQYRg8PhtHHb5lqoY3M8mb9127V8Dh1ztppJ8= 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=MfKvMmhr; arc=none smtp.client-ip=209.85.221.46 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="MfKvMmhr" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3dae49b117bso1588133f8f.1 for ; Fri, 05 Sep 2025 01:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757062519; x=1757667319; 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=7/ipke7Yn7BBLcOWQazhCZw2ILXfe7LPFnHyae+lwYk=; b=MfKvMmhrocqOFWzxyGPDZLFun/HKVeRgNOyc/5vtb3/jMFytRT9Myi7Eoh+ny8Syu2 XT7rPeIvZJQapBpmQ3cxWmN+5p+mJhiSQetm56Q7vmgl2w3QJDTtUqaOINjvAeJKXzbW 05GfCnGazWpU9BMhhEPjQ42/dTPuZCeDc5NkcXaRhltNJvHCcsmBpmXF+duZfXumjLiq K1NMz3Nxw1RNRSUsknd279cKZk8wpj0vZjni+zXvSf0PnIbELArGEOqrohPMGJJRkpfV 7tznVPKi4NlmFT0KIWo+HodasA5a9+zMIEq/pQr/8VmPu7y+8HV0YEknoStQOn+s5SDh ph2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757062519; x=1757667319; 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=7/ipke7Yn7BBLcOWQazhCZw2ILXfe7LPFnHyae+lwYk=; b=ShK3yui/yZ8ZeqdQzXoukD8fZ+pctceZwxKIGj2UglGsuFtKwppmkhXtyIX2ftlBD1 ubq9bBYCcsarSxXgopfZbgHlNv4VVlHXeOT7b0t9Ifq8dxEgcM0bd+kB+F2BS4tHhhUU y47yepZbm3tj+czDYI8M/j7pCPGfKaw/G1Jaj8Hd549wM3ruz8uF+GDJvOkWX7SMyMz0 3WLfqZyQqmz05tH2eY3V6pxlYZLpAjMpIIbZx9nBG+eSIB2xKkw1CSyNIliM3LmNrPjm fXkWRf0GVQrdIGVh6IlvcJ2vDmmFSkqbnmxXN5DrnsMUcfAqUXeGzBqOfkg9Jzl0+FB1 p78Q== X-Gm-Message-State: AOJu0Yx/8xtmZVNS9kKQoDuNMrp7uww0LMoNGMO33Jrcr+woRGhnAdyn 1EUt/fi1I+zHvFw/Hwe5BK8xpZUpttz6eOZyOwoUB1lqRtQTci3EDQKnOVsSuk0WElliItbfRQu 1NRW1 X-Gm-Gg: ASbGnctZbr94utfcWyYwdhPe21WjQxf2qGhTal4FrY59M4EOUOCtpDuoqCpEIPbZXjF +GYHaBzDr9JUjISxMmLZb1nQnqVGEcxHHWrPsH7XG77sh/SLtZvppgXpgOQkXvSBYMGOOHhalkV 7/9TwfYdXrXI8kWO76S9d0FNO5xxLt9/6/0UpLviDEc52upLtMPB3bJz4rPAU0ZDxcQYxC3yMdy whXhRbCF6tx4wFedwIZS9Xx9DELfqvyRCXc4glIdMFHQE4OvyZNQzRcSRWvw9vzHQM6BLRLwSOs hj2Qt6kyKXA+3DOCjNZrt/PwDniqGAbTVcU0lE9z5SD0AEYGuDNviwxtjgCtXaYE7gpk/grLXO0 uppzD5HsAwA6B3X9zz8Rr60oDrIEviqucc4SjVN1QEber75HI1NsAhwm4oA== X-Google-Smtp-Source: AGHT+IH1vxXmkmQJCTds9ZYf/rs6uQBCjDIYTyd1wRbv+xHr6msO7l7HeEiqGF0FFDuaxiocSRxd/Q== X-Received: by 2002:a05:6000:2883:b0:3e4:bec8:dcd3 with SMTP id ffacd0b85a97d-3e4bec8dd01mr369961f8f.42.1757062519375; Fri, 05 Sep 2025 01:55:19 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d21a32dbc5sm28178346f8f.11.2025.09.05.01.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 01:55:19 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Johannes Weiner , Michal Koutny Subject: [PATCH 2/2] cgroup: WQ_PERCPU added to alloc_workqueue users Date: Fri, 5 Sep 2025 10:54:36 +0200 Message-ID: <20250905085436.95863-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905085436.95863-1-marco.crivellari@suse.com> References: <20250905085436.95863-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 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 --- kernel/cgroup/cgroup-v1.c | 2 +- kernel/cgroup/cgroup.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index fa24c032ed6f..779d586e191c 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -1321,7 +1321,7 @@ static int __init cgroup1_wq_init(void) * Cap @max_active to 1 too. */ cgroup_pidlist_destroy_wq =3D alloc_workqueue("cgroup_pidlist_destroy", - 0, 1); + WQ_PERCPU, 1); BUG_ON(!cgroup_pidlist_destroy_wq); return 0; } diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 1e39355194fd..54a66cf0cef9 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -6281,7 +6281,7 @@ static int __init cgroup_wq_init(void) * We would prefer to do this in cgroup_init() above, but that * is called before init_workqueues(): so leave this until after. */ - cgroup_destroy_wq =3D alloc_workqueue("cgroup_destroy", 0, 1); + cgroup_destroy_wq =3D alloc_workqueue("cgroup_destroy", WQ_PERCPU, 1); BUG_ON(!cgroup_destroy_wq); return 0; } --=20 2.51.0