From nobody Tue Sep 9 21:31:40 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 0337B30AD06 for ; Fri, 5 Sep 2025 09:08:30 +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=1757063312; cv=none; b=BQOfh/LMXQIF0e4GnWy3T4irdZS+MkoDU3K0hSuqZNDAFKm00YY+RHefowx2YXVsE0ufbtXlS627lhqG57oNoHJ4MBJxmehwg3KW9bOe/fxVPG1xyH+IzmYK4B/AwmurbD7qZkZTKC3f8pq4s1HJ5jaB9oxVhZs7zXa4HWvabLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063312; c=relaxed/simple; bh=k+ixhQPGGF72LjHNNF5qNcmLsCiq464i8JXv41ZYhso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FKUNt5NysIWspc2eJGsQ8ez28GrSbQW9pICJnuFg21W3hfSkuby1BX1z/PCBfra9TR18OXwG06+JkpxLA29kH9T32o33qRYUwBFLm0QzJKGOllQVBQAg92LobMTHRlKqDbZHbHZTmGmuhfkfJHDps3IpYlvGx6OVxvyeenHQYH8= 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=Ah0tmg8e; 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="Ah0tmg8e" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-45b9853e630so17658865e9.0 for ; Fri, 05 Sep 2025 02:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757063309; x=1757668109; 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=nMpbE6VafRyeOOP29fdsM3EDpozD5yF3rEIxtn+59NM=; b=Ah0tmg8e1B9z2LnN3sOiJ2+WgecqgThPr+eTgN7oPxnYlp0W8NtQ6Z/U+AgGQUBJfL vwon7GE2oAhbZL8Hs2JtI9wy6xwpFkMWiGqDnGPTNLeBfyWZt0BIfIOW3F4BJ/NX/Kpx gzLSHlBgwnwAUwENMGRkqrxPmkeHseWJuIs+FPZ6R963TZzyos+oAwKa1EzS4drOOJsa DLrN2ecNC+HJRUDe4FjOudgQW5DKHecTYIUn+ZJwGNMtbCj2rA98tT0laH8UkkRoUOoL qx3PFSFdUMeUz8rC2l/RLPP/ayT5HrCm1tH/UVwvDHeLb3S1Cw7XlB6yqmRrQlgzk8s9 yabg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757063309; x=1757668109; 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=nMpbE6VafRyeOOP29fdsM3EDpozD5yF3rEIxtn+59NM=; b=s3F5vBt9ZCqfjKcp8BkntUCDj/gCA6gR7DWmfAvda52YczteCbsI/piUQNQZhPOTAK p858gtMnLrMql9u1jNrPHjctqdlSNVTgEqLU4UvLkTwkehzuAiE4n1d2qQYlf3a2nIL2 sTlyPwHkhAUMRYSRzaVZuJhN2cAtdmcLxjP1Th70FuSP3rCfF+L5vY4YSwxRZRUmQXIp pU2F6BOVsh5nVHFj43ibZbrzqxoRh627mYDJuaqrMhWQWrijbSsl0/g17rokXn8Ri8g4 S+kXAMkyGf8KCuVDj8aP+rwUbQBOV7w5AHE8uxydFOMRpZOvPEf0eAUjTjaN9X8RpK9X 8bAg== X-Gm-Message-State: AOJu0Yz1XtH2ycd42msvRrkNzlsFU2PiU6cS7rUc3h4uy9P3B7oyHzkU NKv3+A9zu3///vwa/tfkN+Zefomh1FB4A+hahMOc9lcdMM2wRUq2DWB1fkn+u7sIAFCdOU56fBq d/gYh X-Gm-Gg: ASbGncubCwgQ4rjQT+i/TUZhhfqpz7cRCF+rOMHXtRQ3Ba61kfXKK6z2UtTNAm2O1Qs mh4R4tx7EBcqKcevc8T/LEDXGyJwCEhNzcHggUZsEZkwZYE5J1RlANMoBHK9Az+gqV3U1XLQgPX HKHK8ZeCDh5V+YR+hQgJZS6F+IfwpdQU6THpUxkBZxm3wWXB+32sCQPL97t8GzjCarZVLiVnMyP wYdJp4KgFOtvr1EJUUsiNmI9oiPdBaut2ONzyvIornqtrKai2s0pVcq7Dsfi50DzNPXiLBA1QY8 zWxjN2HBYw28KL1i2kzrkqbtyCK/wyiz3/7oNT62YBCdWKlH8a4JVi585aGCFbd5PWBIt1KGPPm pDRDI7fvB8Yi2E5m5q0nmQI+MWDW9eT2V77lXUkr41/IAl+FMIfAesynHSw== X-Google-Smtp-Source: AGHT+IEQ7iICtAFI26qq7I6gkL+FcH2hfR1NxHLVFsStd3ArLDcFGJmIecq7OFAY9rQ+tTYgegYx2w== X-Received: by 2002:a05:600c:3556:b0:45b:8822:d6c4 with SMTP id 5b1f17b1804b1-45b88321ca0mr179252895e9.33.1757063309076; Fri, 05 Sep 2025 02:08:29 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45dd0350e80sm68900805e9.22.2025.09.05.02.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 02:08:28 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Miguel Ojeda , Alex Gaynor Subject: [PATCH 1/2] rust: replace use of system_unbound_wq with system_dfl_wq Date: Fri, 5 Sep 2025 11:08:18 +0200 Message-ID: <20250905090819.107694-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905090819.107694-1-marco.crivellari@suse.com> References: <20250905090819.107694-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 --- rust/kernel/workqueue.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs index f98bd02b838f..8ca813d68a1a 100644 --- a/rust/kernel/workqueue.rs +++ b/rust/kernel/workqueue.rs @@ -662,14 +662,14 @@ pub fn system_long() -> &'static Queue { unsafe { Queue::from_raw(bindings::system_long_wq) } } =20 -/// Returns the system unbound work queue (`system_unbound_wq`). +/// Returns the system unbound work queue (`system_dfl_wq`). /// /// Workers are not bound to any specific CPU, not concurrency managed, an= d all queued work items /// are executed immediately as long as `max_active` limit is not reached = and resources are /// available. pub fn system_unbound() -> &'static Queue { - // SAFETY: `system_unbound_wq` is a C global, always available. - unsafe { Queue::from_raw(bindings::system_unbound_wq) } + // SAFETY: `system_dfl_wq` is a C global, always available. + unsafe { Queue::from_raw(bindings::system_dfl_wq) } } =20 /// Returns the system freezable work queue (`system_freezable_wq`). --=20 2.51.0 From nobody Tue Sep 9 21:31:40 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 1CCF8284B4E for ; Fri, 5 Sep 2025 09:08:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063314; cv=none; b=iONU+Y7yj0deQui6L/JQ6Kyt20QsNEer7MP22mazpe6KREJq5ifHavvgTl3S+5V+/g8RODYPaNe6Xq2e5Aqf0mW1GoSHzCd480For8HwzoHKPgAaDGktcP66b/NOS0gkUsd0xnO74CNmapkId7E8laJ5yoxC3Hemr26JNfa49NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757063314; c=relaxed/simple; bh=26Tb1NtsqwZ1rv+sVNZuBfdl1j0yHZvMb0KD02KS9aA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cu3I8zUkijxV3E4WSeZ53UgUg1/baNQHkYDKR7Jw29UG81sts413L574sxVmnnRxGlMfQkArxD4PXJiJYfjiZsKzsa1CnoF+ks9rwvQO2dcDVkMTSgbNIFCGFdZc55/G4erEKuKnT+7hUOvCZYs21DGbt52TH6Gmyyadytd18h4= 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=M7CRSVSI; arc=none smtp.client-ip=209.85.128.51 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="M7CRSVSI" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-45b7c56a987so8047875e9.1 for ; Fri, 05 Sep 2025 02:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757063310; x=1757668110; 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=vsx4ro+fg1Da+fZ6k37g0k5i+Ei4r7saLuhpbXY1yMw=; b=M7CRSVSIPdrVjHEiX3ynHHUpvetOiCRTKsJgCPWe7bseB9Q98YLQLGSBwHbZeGkpQE /aPocbNzlBPzXITNXx4BztXxA7ChXEiSD/SNq86d/6JBR/P3nzh1KWfjigJLMvgkg7m8 J6O1ZbgnxFcrdNLJXuVy7D0i/REVhCWNQ1kC1desbMJ89+sJe39gBXmtq3jiB1KbN+J8 y+VNjEF1H9xAuMwgxgu8MX0pob/s/HsQp7qsz+3zHu4zwuJogTmTtHkwqgfWLtzq9Bqi w8dfZY2DWBe8+3w8vLnPEo3zUY2OxdwCktLcbWtz1mk/uZzlMipltfboP7sP1M+3UMea nQug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757063310; x=1757668110; 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=vsx4ro+fg1Da+fZ6k37g0k5i+Ei4r7saLuhpbXY1yMw=; b=khUKB4Dgm6Y9QJYmkAZrN8T2Ci4DWjm/iuDTR9VT0AxllIrvLv/XfwL8ndQw8X+LLE 9RfWk3SIrJ7RZZIKdl2kv0sSKxDDKe3pP8V/FhUALXs+79LGTn5nYV23BXOKN9v1M7Bx 80hl/+kfWWbz8pjc4e+9ekRupqR0jKmL7heJKqXgqqZv0GUmjO3BCTMO2xUvrGJNMwKx CzGJWnaGWW4diiL1T+GfWu5ASUT2N2tYvNi2lDW9OLW0uBTayUQ7gZDapGW42WICj0u9 zQJd2CD++7JFHeYaTdlOREYp3W5tDeVQDgP6yOkLXvqZqUywahKP7e//kRkyv+FBmERY ZGVw== X-Gm-Message-State: AOJu0YwcUDK9iLugdO4qWI1wS/vg2Wd5un2M3ouzwLvQZJuBJtrvVfDP 7PzIAqlIR8oSV3Ym2jUCOYp9iYn9LYANUu2lhxlnDh0rhwfBzLppXRCix28I956t5tO5MBps23O AUCrN X-Gm-Gg: ASbGncuUudgKLwr+/NNV5a0o4h2xpB/3nS2DVz2uV0qgnpcYrafbw63sfIFDYq+DmLF U5Vdsi9S7SLPOziteSPoyjIWZ/l6sDRJcA1DuO8Pj/VILYjQ0uTY8plIPCODvt01i12Gn/Oz3Gf rgnf+mWlKBNqw6haRbSX5n8MiImGotxXR50mnltg62fX4tgm27E789vfl4sh+ruc07q191zwYvw qZx402CdRGjjSNvtnMDKWTWVpb3JMaH0Ob8B6/7OP3cd3qQmLJuiv43jEWMQa75eEjhiR3VBP+k zrl5am3UFJn7wPNh5FLqRj0WtgYgVU0CYIL081VEM5xy2bHMBXxAZ/ThGoym0QFitPdwm6danVR qKR0XHTZoYxlKgVravabcEoEqwaZHY1sTEXtliaIuJWGjyJTHmgurprXatw== X-Google-Smtp-Source: AGHT+IHUYSE4/MqB/EOjKjkztpcu59mOOTXF5Ahf/lvz7h2oStW1eg9hrquGPbwauw4p3kcS8EXfwA== X-Received: by 2002:a05:600c:1c08:b0:45d:d353:a491 with SMTP id 5b1f17b1804b1-45dd54a5b31mr22217865e9.1.1757063310044; Fri, 05 Sep 2025 02:08:30 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45dd0350e80sm68900805e9.22.2025.09.05.02.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 02:08:29 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Miguel Ojeda , Alex Gaynor Subject: [PATCH 2/2] rust: replace use of system_wq with system_percpu_wq Date: Fri, 5 Sep 2025 11:08:19 +0200 Message-ID: <20250905090819.107694-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905090819.107694-1-marco.crivellari@suse.com> References: <20250905090819.107694-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 --- rust/kernel/workqueue.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs index 8ca813d68a1a..6f508c3e37e4 100644 --- a/rust/kernel/workqueue.rs +++ b/rust/kernel/workqueue.rs @@ -633,15 +633,15 @@ unsafe fn __enqueue(self, queue_work_on: F) -> Sel= f::EnqueueOutput } } =20 -/// Returns the system work queue (`system_wq`). +/// Returns the system work queue (`system_percpu_wq`). /// /// It is the one used by `schedule[_delayed]_work[_on]()`. Multi-CPU mult= i-threaded. There are /// users which expect relatively short queue flush time. /// /// Callers shouldn't queue work items which can run for too long. pub fn system() -> &'static Queue { - // SAFETY: `system_wq` is a C global, always available. - unsafe { Queue::from_raw(bindings::system_wq) } + // SAFETY: `system_percpu_wq` is a C global, always available. + unsafe { Queue::from_raw(bindings::system_percpu_wq) } } =20 /// Returns the system high-priority work queue (`system_highpri_wq`). --=20 2.51.0