From nobody Tue Sep 9 21:31:42 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 54E23309DC4 for ; Fri, 5 Sep 2025 09:08:03 +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=1757063285; cv=none; b=LonR1jnggvIzRjMp/MqZ1IjY10Arvety5RpS+YcyPhQMITpsNCKU8mO+i+SCBT7igzl0YzM/Uiea3YqxbrcAms0QbSz2coax2hGYdxSj6rctswDtesrPwkTKYkGLvc/B5E/LALSCWbgWqpx8CPr7tq4+llZVSn523sXODeV6EBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063285; c=relaxed/simple; bh=qkdztFXLaFLOpPxKYX76fm7otHffD5cZK4//HWe+OUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SPHs8Ns3/u7qUeyJRbpry5SsIw0M0O5BY9knpSZYaAuDlSJJPuOt72gCfyk51pVuyp6idPpxfBRohim+bBU7l76pfB2i/12ZI9FEXGQVM/Ug5hGafHbG65B2A5gKaL7XVwvmZDPQm+cCY0UdUM2VSgJhAu/dkgBXZgADo9d1By4= 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=G/NHhILq; 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="G/NHhILq" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3da9ad0c1f4so1283219f8f.3 for ; Fri, 05 Sep 2025 02:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757063281; x=1757668081; 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=bNu3JrNHi/qEOOengN/e8XVNw/5CBER76eU60Ek4MJs=; b=G/NHhILqrS2GiCUO6GlOwQ7yVfhLkWFfzwvdzHeAWySHWn3XQYhimdiBMn1qavmZSD Trk6ADFlwxR+edt1dkLH3vcmzrT3s9rjpFJmurXdEwEzTkw9mSiLOlVuXeXmcEUU1XM+ OvZAVKSssdbRCwWyTQt0B0sOfZUMwLyQsvhzYmCAM5M+v9fvooNa4U9T3HLidoHj7NgS R3ayPySRsfHMbGsMaEsZBmR+8F7ejtOr3aeNggBCeg6/800Em6cqvXRn7a2lZIpswGa/ GeiL9+1TqLjpf3M7vITO8Ojj5v/PParXWQ7ae9AAWlRPBipW4EK0d9ScWQUxsmE7jUYB FUYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757063281; x=1757668081; 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=bNu3JrNHi/qEOOengN/e8XVNw/5CBER76eU60Ek4MJs=; b=jJXrq0MXTTCoJxpBL4GCh8qh10LN4kfZXWqfbmdrQCL45uAbiDBd0Y1o34zJ3hmiab XjUNfjjF5nU2g0ePCmp7bU6ZQKjuYetWhHpMouB0Nx1YB8z+rdlk8Pldv9WfmSNMs6jI kdAEuSqLsB9Ih2vMP6VQ2l5krWhNpN34Hc+ZjdSBD9tGs5hScoN2INHLyDyNzwggXQ5a FXnP/rbRjDZtQXEutOndj19dBkdgPWMWd30VPJETAbbYGDACw/YngzygVTWU77v4jrGc q4zBEqzRkXUbBMY8mys8HO6/5u5Bulce7/lZfMtuc6AKrSf/zarubVcxvMTwSmZuErxM uQOA== X-Gm-Message-State: AOJu0Yyj9aiU4IKSc0/iS2pd8jXHhQIY1SySoU15KLEoiEzy7Rb0RDju xOjJ2RCc2aopK6irp5KFG0e/KIUg2UvLeEjA7tYysyBKqIo3XFuwd2/paT8GKAOoNmSHIgPk/bJ lOm+Q X-Gm-Gg: ASbGncs5QHBHN4uJNAFMkEkYJHYRc/Ap/wqDRHv1UrBsZDx6vrg/cMGaSb34tnoXMZ6 8Mq9UFwG8ByVS+4MAroewo5Ls84+2YuJAxIaqqE/ZMWt4vriYC9G07hW8P/rwTsh9rYTFhhfCKf 8QH68jNse+DwxGtMMbhblRymfG6Yjc1qW1cvOzY7geVN7fIN/ACuzSkZhuVG+CrNkIiD6OVURWE 8YPl2sxnRi1AnqXrYW1drpMyfZgfJfZDNariz+TAqMhCMoG0BPmhr7uySMYfy4XqrXm1HoSDxVp Fz9td0mZWAep69A5h0Diaum9wf4r7UxElYs2EElDwmonbfXNFJqtrxmmgzWKPRpz4d+2ykKtxo+ NjWb7Abue1VbcwBJgN8R7d2qMGkAbta1opEghY+nt5zcACkWV95CKaEmqqg== X-Google-Smtp-Source: AGHT+IF+/atwG9vdO3wlQO74aDlEiGObLmRVz5buolGSQk8dlHigSbSJZCAxM2nIrkHrG3Mpnrmhug== X-Received: by 2002:adf:a1c5:0:b0:3d4:f7ae:bebb with SMTP id ffacd0b85a97d-3d4f7be0a79mr11095234f8f.26.1757063281330; Fri, 05 Sep 2025 02:08:01 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e7fec07sm311505335e9.10.2025.09.05.02.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 02:08:01 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, rcu@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Jens Axboe , "Paul E . McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki Subject: [PATCH 1/2] rcu: replace use of system_wq with system_percpu_wq Date: Fri, 5 Sep 2025 11:07:46 +0200 Message-ID: <20250905090747.107232-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905090747.107232-1-marco.crivellari@suse.com> References: <20250905090747.107232-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/rcu/tasks.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index c0cc7ae41106..5fddd7168391 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -552,13 +552,13 @@ static void rcu_tasks_invoke_cbs(struct rcu_tasks *rt= p, struct rcu_tasks_percpu rtpcp_next =3D rtp->rtpcp_array[index]; if (rtpcp_next->cpu < smp_load_acquire(&rtp->percpu_dequeue_lim)) { cpuwq =3D rcu_cpu_beenfullyonline(rtpcp_next->cpu) ? rtpcp_next->cpu : = WORK_CPU_UNBOUND; - queue_work_on(cpuwq, system_wq, &rtpcp_next->rtp_work); + queue_work_on(cpuwq, system_percpu_wq, &rtpcp_next->rtp_work); index++; if (index < num_possible_cpus()) { rtpcp_next =3D rtp->rtpcp_array[index]; if (rtpcp_next->cpu < smp_load_acquire(&rtp->percpu_dequeue_lim)) { cpuwq =3D rcu_cpu_beenfullyonline(rtpcp_next->cpu) ? rtpcp_next->cpu = : WORK_CPU_UNBOUND; - queue_work_on(cpuwq, system_wq, &rtpcp_next->rtp_work); + queue_work_on(cpuwq, system_percpu_wq, &rtpcp_next->rtp_work); } } } --=20 2.51.0 From nobody Tue Sep 9 21:31:42 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 5E535309DD8 for ; Fri, 5 Sep 2025 09:08:04 +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=1757063289; cv=none; b=pPDL28KcLhDd9M+trJINsJcgcevhmISiCc8crMFC8QAC6dCxYAGk4Xl+j1IgjDbNUZ0olMYd2b3TJbq9aG58SOia8XshyDQwBhARqa0Y2PsXyKKtiT0agGnZ7lcJFH0VbFbbAUgXdKGV761vqDBfZnIgxmex/ySof11zwhiyS8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063289; c=relaxed/simple; bh=1zF4ped0JCfrpWQyfByH3Csxtam+ue4QKqQ7xKEVUIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WiRCC3QIOMfVmSF/cvyQt0wFfZVWZsCjzq9G1GbW9rhhRfwkuaMnWd5kbN5zpv3mC+x1UNN6H1tbvEvLNw2blmvs3wv+MPRy8rZ0iWoZzs8t3pnJYYJfpAxWRA0RaDPfAdZeSlS9N6bjvc7hyDrlFUvrlZnjYp0cMActxXoZeL0= 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=PrJjvlkG; 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="PrJjvlkG" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-45a1b065d59so11925405e9.1 for ; Fri, 05 Sep 2025 02:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757063282; x=1757668082; 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=xBJDT20pfEXOkjhhpY/VXucFpS1NHhYqFSc/i9LvNFY=; b=PrJjvlkGz/Ne4nIpJQbWN5BIO8AZTFUb7QWPeCeYcVn4cUd/kxf0UEjJFMDJSjQvsn t5Vpj6MwY4vDoxXp3hPpMbHhDxdyPlH9j+ZEzhMwkSwHnLyHsj3k2NdIMsKl9IBNBWfn /KUdsTmWFX+B/vqA6XjsAekaWkWjUegl8w9UotKCF0e0Z46sXsIxTgs3vOEYv9gbeCJa xC7Ja7G8A95Dhe/2lHTiqdx6Or0JaVrHvP9dMVh4PySmnHGIJjMXbrT4UuyJv7jPeFVM Fwngjudc5wKdXF/6RLu0j0VhdVNR9De6AuyyuoMAFJiiLMOpn2Wdw6mmY9yuJWriBHSh JtKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757063282; x=1757668082; 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=xBJDT20pfEXOkjhhpY/VXucFpS1NHhYqFSc/i9LvNFY=; b=TELMfr+3EeA9EUk+jRIq4Iiq4I15gIjZxMR+7kCE2mm/Z0M4LnUJmWSLdDt9DECKMn Qmt1eDGTUNM2HYchUAMfpf5EAqRtveKAMGiNkJs/bcKFTdOUlvpJ9T9vIcYkfcJtfoM3 CdGl8fB3SQ9QObz0PtUaUcZNv0euwcboe4kRZEPU1DLU7SkA0UxqLsmRPvmyHWlno0vY PZbUZ/V8QpETXfRPymgT8Wgy72W/KFzkqM+Do+9VGiitPzM6MPePiL/nNiFP4mxtj6XH jrGrff9I+2OIMc5yu1cXN5/xeKKoOPs7OmmJ1IQuMLXzNWFDCe0csLNvJ7s1QdQVSo5k OBgQ== X-Gm-Message-State: AOJu0YxrHMlahqv9EtsVskq9eKGhlgm8bHABa3P44LB68si5xhcUw2Pf dy5uwfsE+IQj/RcoLuBaauYrDQORJTSUTbXjPgtQ2hY7CenFPT73aPoVLCYd9oosGRiyDRCEhv/ lCuc8 X-Gm-Gg: ASbGncuovOw+UgZCOUe+To+/W2DQLp0OFCXfHZhQG2TK1eSZKa2ih7rvLZ4frlXXyAI hDCFh37cKI/cas17Az9SYUC/lMlmh/yPncC64qjbJ4rcukexzz/tAYIh5RGSHWyJradcyBxDl2Z 6DjZ7LzPEphu+fY8smWM1Rabyt1Ezk3ddTilv41RMFop0li6yVOELuubvSH5YgbO9lshEqOicCF S0ezBr2gmEeCnxWb2+okRHhK4sdNYEV7lrXr8W78pRuwJOtO5Lfe2pEILth52IbdzHV3DP3YuH/ z+EgRxvj0E2E9HHbFgr9i7N/IZrtFKYZzFX7yEs2abXhAcJ0+ks7jNwfPl8ye1lrlHTmqsYBYwv OPr6tB7J8KuUnOqYikoe8v9YqLJ9bf9aIYGzrTD8CWM6D2Gs= X-Google-Smtp-Source: AGHT+IF70anKgRw6wAGn1dfUgMIB1wbFZ76sqlJNdsBKrD65DfS49bp2Si8SqcEceEqcUooqlqTOMg== X-Received: by 2002:a05:6000:2283:b0:3d0:e221:8922 with SMTP id ffacd0b85a97d-3d1e04bddc0mr18173649f8f.46.1757063282299; Fri, 05 Sep 2025 02:08:02 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e7fec07sm311505335e9.10.2025.09.05.02.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 02:08:02 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, rcu@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Jens Axboe , "Paul E . McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki Subject: [PATCH 2/2] rcu: WQ_PERCPU added to alloc_workqueue users Date: Fri, 5 Sep 2025 11:07:47 +0200 Message-ID: <20250905090747.107232-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905090747.107232-1-marco.crivellari@suse.com> References: <20250905090747.107232-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/rcu/tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 659f83e71048..e763c3d1e851 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4829,10 +4829,10 @@ void __init rcu_init(void) rcutree_online_cpu(cpu); =20 /* Create workqueue for Tree SRCU and for expedited GPs. */ - rcu_gp_wq =3D alloc_workqueue("rcu_gp", WQ_MEM_RECLAIM, 0); + rcu_gp_wq =3D alloc_workqueue("rcu_gp", WQ_MEM_RECLAIM | WQ_PERCPU, 0); WARN_ON(!rcu_gp_wq); =20 - sync_wq =3D alloc_workqueue("sync_wq", WQ_MEM_RECLAIM, 0); + sync_wq =3D alloc_workqueue("sync_wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0); WARN_ON(!sync_wq); =20 /* Fill in default value for rcutree.qovld boot parameter. */ --=20 2.51.0