From nobody Sun Feb 8 05:20:03 2026 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 68F103B8D4B for ; Tue, 3 Feb 2026 15:28:33 +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=1770132514; cv=none; b=s0dgE8GXqcxd5saBh/b/bV9oY8g6jk+pfNUUw4YsFoARde1qGeoqumiao5kdVN4YeLHFt5BWcN+aIPfUOl2T0/wH9oN253VcmQCCwk9MgZI13CXbJ0KX41FIO4NANROeoXnG1qfxkwPWWIQ1jLP9tyH+CaBA+5Pv7mscMZqB+8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770132514; c=relaxed/simple; bh=VjzLcMYnMGzKi+vu/uescVXSKcvPTOypNKURUrKD0zg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dIDRWv+bJ+eIbygTvWn/2pHRfWFgjrxtu7nQSPkhpiv1sQH0QhuGaaZ9/SHqTBHK0NqPMPvqr7uF7zbB2xfzfGcLSMzI7qZW6ZRxX5I+HWJ9oAAqZnBzWEg1YxXHxUxjb3dvZTmo4StOkBztEdROKKMtp+KGjYDGC0BnsOKj3vs= 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=GQq/6thX; 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="GQq/6thX" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4807068eacbso48118595e9.2 for ; Tue, 03 Feb 2026 07:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1770132511; x=1770737311; 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=jptYRhOowxSmX36W8by/N3vMS3FFkCDr4M7jwT5m6nk=; b=GQq/6thXahLRrplzKuyBshQHOLW+RobAKmuZvK2fq3g4wkjHm7zNq+Wdc+RI1G5+y4 d0zSrEC95E32QadKehXxUdTkDRDSRuigqyyD+ylyAkgToyZqMGLxaL2qkAW7EouNF+HA peP6hv5QMHaUN64K+LZ8yvlXByRBgJY3PFu3PDS1aDxjrTrXaiCbL8I+/3dZ1PcL24G7 XSZsiDk2ROGy8tKGN7d3ut1mvsGZ+t5HwydS6mE2+me9lkEAU59DVk7l4FcjQsiO/6op PNXHidwK8qvsDFy0HwxSQ/N4pMiz+fKBGmfq/bhc9ez5Ozoq/XLxxX2s2to7dRqOiEUS 0zNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770132511; x=1770737311; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jptYRhOowxSmX36W8by/N3vMS3FFkCDr4M7jwT5m6nk=; b=O34tF4RBxY81xF6k+dGFIuxqxC0WIxYc9HruVdh3MJyKpXFrRtaxSWCereKgwvMgCg OTiWyFP1ytA1bE1Gy4RVc0q+jgQSn84RvI9mqQ3EYvgFrnZMkn99D86kQyMwhknrLJLU rfrs17A+MQu8BB2F3LHlQfyqsOnh7N4JcOZOuOW1zfj37xvvOpcccG+8jUR9XxPT3J8Q BcqdTKuxuVA5hp7eQzgEcljo4D6MqNzafS4ISwQuIc2CyteRvtw51fdp5ErZGA94xfy3 0aJvHXg7Pxwd906UvBM7s4CrAzLBnO2IoV22aSLoPPz7+YZHNRQC8baOd6yvqB+SbAtU F9iA== X-Gm-Message-State: AOJu0YwkHQ/AQEYjvR2OKE8+Z0s1kbU0oKYhvnoiDZwUnwF242hXO3IJ LLD2+IicHLa8m9bHwR0451tffyVX5BO3Qmvs9Ky4dl5Ngjl3IXxUOEtbJD6lSkllI2iTzIsRwrJ wVSan X-Gm-Gg: AZuq6aKhudH73ctxa+DDX1mSJcaP1CcWUUEqquSBL6n71xwv10/qsiyGXW8DbM9VP4a SakVZIiriT/DlpddiP8IKawu1DXCPTfQZvGw/H4d0zzt7+chWJSiGj6vfBe+L7J8ctTwEuZGXb2 b15w4uhh3Hz9fD6alfTW8J3Fg2jB3dHzyu4XXNS8Hn0OaA59QLCxEB4YNkApur0+ZghVpWsEuiA kQVTWtUBzNmwv2jfXq1baJKPSpcctnHjUZ3SKMWJ7TwOf0R5CXn/A1NliS0dyzo6Kb62OlJ0r5l KMHKTA/a+W5o5UjYPUlmq3FGh/RNpscjdENJFdXuA7kXenjtkKS1MUDWwDlUi5/JwsQ671ZVjxo tbecMmbjXrhDcy5h31NupQynT/aP/0cbzeK79YOAR9WMDY7fEUd7garL8kKezBfHweGXym3acaY 8Vl2v9syA223ExYjnszRgJxZIilX5TRr+dKR5A X-Received: by 2002:a05:600c:5491:b0:480:46c6:bf4b with SMTP id 5b1f17b1804b1-4830e92a73bmr467905e9.5.1770132511405; Tue, 03 Feb 2026 07:28:31 -0800 (PST) Received: from linux.fritz.box ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483050dd79fsm71316005e9.0.2026.02.03.07.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 07:28:31 -0800 (PST) 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 , Alice Ryhl Subject: [PATCH v4 1/2] rust: add system_dfl() around the new system_dfl_wq Date: Tue, 3 Feb 2026 16:28:16 +0100 Message-ID: <20260203152818.317806-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260203152818.317806-1-marco.crivellari@suse.com> References: <20260203152818.317806-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" The C code defines 2 new workqueues: system_percpu_wq and system_dfl_wq, respectively the futures replacement for system_wq and system_unbound_wq. This change introduce system_dfl(), that use the new system_dfl_wq. system_unbound_wq will be replaced in a future release cycle and should not be used. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari Reviewed-by: Alice Ryhl Reviewed-by: Gary Guo --- rust/kernel/workqueue.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs index 706e833e9702..300cc2bfe012 100644 --- a/rust/kernel/workqueue.rs +++ b/rust/kernel/workqueue.rs @@ -968,11 +968,25 @@ pub fn system_long() -> &'static Queue { /// 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. +/// +/// Note: `system_unbound_wq` will be removed in a future release cycle. U= se [`system_dfl_wq`] instead. pub fn system_unbound() -> &'static Queue { // SAFETY: `system_unbound_wq` is a C global, always available. unsafe { Queue::from_raw(bindings::system_unbound_wq) } } =20 +/// 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. +/// +/// Note: `system_dfl_wq` will replace in a future release cycle [`system_= unbound_wq`]. +pub fn system_dfl() -> &'static Queue { + // SAFETY: `system_dfl_wq` is a C global, always available. + unsafe { Queue::from_raw(bindings::system_dfl_wq) } +} + /// Returns the system freezable work queue (`system_freezable_wq`). /// /// It is equivalent to the one returned by [`system`] except that it's fr= eezable. --=20 2.52.0 From nobody Sun Feb 8 05:20:03 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.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 48D123B8D55 for ; Tue, 3 Feb 2026 15:28:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770132516; cv=none; b=SMpNOzcnadjQH3Od4Bborc7XhH63xTThSSmh/3lerzBddK4ddUl3GcbOYnXJrRF7m9RGhFnv5THQopuVcfOGVI0B4irgiQldz2ut5hjNiRyL+AH/2Y6GaSf+K2Ia5dal828DEaeqN8LuAd35j5G7QNVVkJ5HSMi8+AV3wgDXOdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770132516; c=relaxed/simple; bh=5P1OoHaY7/L+xB5tVS0KbkGK2mda/BzFZpi996e8uBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WczsDHDvgAjLT8HzFXnCHTHrqC/UbxmvfIzvZj7g6eI3BXCNWs2E5rFkcjZqJJkNIDyBJSYh2qPJ66EJdIoxo4m7dQPDCxuPPiF9oOJn2y274mBe+ZnfcdPrE8Uh5wk+PPaRMHfeXFuw+NvHL8rsO2uHeihpdp6bS8masQRZFV4= 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=QGqUT2Jj; arc=none smtp.client-ip=209.85.128.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="QGqUT2Jj" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-47f5c2283b6so47124925e9.1 for ; Tue, 03 Feb 2026 07:28:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1770132512; x=1770737312; 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=evrCydrxXcTH9gOn4p6qQgFP3yUlzzT31yKuNCq7gFI=; b=QGqUT2JjSRP2MnPdieFrHUlek9tf0zS1nu9yej/oxpVIp3WjoFbnlzy4MkxJc5IMFo p6dJ5GoQ9oST3zu0qMz1JwDQF3kNuqmdkod3UGEVxASbiWCM0H1bU4RMuesQDRd4ADSD VYJqAzrC4mKLCXZXMEXHQ/DXudw2zxyjU9MDQNpnli55Ls68lLlwarRD9xYwgI6q++FX WkdNdAxLMGVCO3Qqao/OD5H4NyK6TUK9Kn4KVzoM960RhSH575VWpJh3i7fYNeUVYuk4 jI2jCGY/2zGwy92LoV9LLUCHmiswjz9Z1mH9Ejly4xco/94XVnM7yhqYAHUZ9dNfFh/L vMjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770132512; x=1770737312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=evrCydrxXcTH9gOn4p6qQgFP3yUlzzT31yKuNCq7gFI=; b=kwGwtPgyuXjWdnk2Fgvkd12RP+GOn4dbOvvd8ujoBbiB96iBNFb5fgOWSSSslHbpVu LNCjv77+ktDCIcHeHKwGbPWi2ygUDtRJjCs8BDBQFQsp5ME9aXUehe6k+5m7C6roVMyf l059MJgou7xzvghJLDPnUhUhBcYw1zsMBAy+dgEselfZ4HXE3V9ugQFiaUAoAOxnPuhj nZaYMK9H9GsrQRcJv3y1b+I4sTQ0gVljkw/U74UBRFk0EMt3FOWutsBSFBMqwZwl3S7W x9FRkz/gLoZh8awyCrWYkW4uPV6QbwUAvHZXKQMQ7tILvVqkQoioTwFP4Iv21B7ibJLN hnOg== X-Gm-Message-State: AOJu0Yy0BQifKgpjRu1uiYlLZBpkTwvQFtfeo2AqfgCgCcphiOAd8GwL g8gOUbfU/VhJog44iQLUTG4P6sjUBEXArrTU2WSw5iNYe6Y4EFcTf4nlBU63T1zD1oSLHEX5vFz 4EjVC X-Gm-Gg: AZuq6aItU7iOisNRkbjsI+EsdjCB0mUWq0h55Z78z3UlCxOd7iXMtuKq74zWEXgMkWZ WuFVkypw5R8RiraTK1LLfVp1GMX6ZYXvvfpywnXWRnwdS9pFnogYCv7txZXJnzvo/YDb28RcRXo ClYDYKnQaA+ov74/+pAd0JQx2kTuzhContxQP8HZ+R0V1nR/jwsxknWtaa/FsyZE+q7n5FQpxrm E1JbqB8vDiqECuJOaoh3Y0BsM81WrxdjvBRsuNk+a9rZL15Va1/aOPRUWdJEKh5rvTs06NM5B7u yJfmgPjwfZSpbYQlZCktYvrn0CAeO6yPbVfz2rX6FKGkNqS7afmXCUaz3PJk9gYEIwoimt1uqj2 +VuEC7NQHF6CK7OfbhNs2MsMfcuNYGCkmdArfd4rzWQKxDvtYhqou1nh5WFuZ1Vu2/WYTy8gNBE l/tvd30skoR5/gLVIzrKn0hSKsdQ== X-Received: by 2002:a05:600c:1e1d:b0:47d:73a4:45a7 with SMTP id 5b1f17b1804b1-4830e966bb1mr163915e9.24.1770132512356; Tue, 03 Feb 2026 07:28:32 -0800 (PST) Received: from linux.fritz.box ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483050dd79fsm71316005e9.0.2026.02.03.07.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 07:28:32 -0800 (PST) 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 , Alice Ryhl Subject: [PATCH v4 2/2] rust: add system_percpu() and per-cpu enqueue functions Date: Tue, 3 Feb 2026 16:28:17 +0100 Message-ID: <20260203152818.317806-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260203152818.317806-1-marco.crivellari@suse.com> References: <20260203152818.317806-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" The C code defines 2 new workqueues: system_percpu_wq and system_dfl_wq, respectively the futures replacement for system_wq and system_unbound_wq. This change introduce system_percpu(), that use the new system_percpu_wq. In order to enqueue on a specific CPU, two new functions have been added to the Queue implementation: enqueue_cpu() - that receive a u32 CPU id as 2nd argument enqueue_delayed_cpu() - that receive a u32 CPU id as 3rd argument system_wq (and so workqueue::system()) will be removed in a future release cycle and should not be used. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari Reviewed-by: Alice Ryhl --- rust/kernel/sync/completion.rs | 2 +- rust/kernel/workqueue.rs | 96 +++++++++++++++++++++++++++++++--- 2 files changed, 91 insertions(+), 7 deletions(-) diff --git a/rust/kernel/sync/completion.rs b/rust/kernel/sync/completion.rs index c50012a940a3..ee6aa8f18507 100644 --- a/rust/kernel/sync/completion.rs +++ b/rust/kernel/sync/completion.rs @@ -38,7 +38,7 @@ /// done <- Completion::new(), /// }), GFP_KERNEL)?; /// -/// let _ =3D workqueue::system().enqueue(this.clone()); +/// let _ =3D workqueue::system_percpu().enqueue(this.clone()); /// /// Ok(this) /// } diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs index 300cc2bfe012..81a68d5062b7 100644 --- a/rust/kernel/workqueue.rs +++ b/rust/kernel/workqueue.rs @@ -67,7 +67,7 @@ //! /// This method will enqueue the struct for execution on the system wo= rkqueue, where its value //! /// will be printed. //! fn print_later(val: Arc) { -//! let _ =3D workqueue::system().enqueue(val); +//! let _ =3D workqueue::system_percpu().enqueue(val); //! } //! # print_later(MyStruct::new(42).unwrap()); //! ``` @@ -121,11 +121,11 @@ //! } //! //! fn print_1_later(val: Arc) { -//! let _ =3D workqueue::system().enqueue::, 1>(val); +//! let _ =3D workqueue::system_percpu().enqueue::, 1>(v= al); //! } //! //! fn print_2_later(val: Arc) { -//! let _ =3D workqueue::system().enqueue::, 2>(val); +//! let _ =3D workqueue::system_percpu().enqueue::, 2>(v= al); //! } //! # print_1_later(MyStruct::new(24, 25).unwrap()); //! # print_2_later(MyStruct::new(41, 42).unwrap()); @@ -171,13 +171,13 @@ //! /// This method will enqueue the struct for execution on the system wo= rkqueue, where its value //! /// will be printed 12 jiffies later. //! fn print_later(val: Arc) { -//! let _ =3D workqueue::system().enqueue_delayed(val, 12); +//! let _ =3D workqueue::system_percpu().enqueue_delayed(val, 12); //! } //! //! /// It is also possible to use the ordinary `enqueue` method together = with `DelayedWork`. This //! /// is equivalent to calling `enqueue_delayed` with a delay of zero. //! fn print_now(val: Arc) { -//! let _ =3D workqueue::system().enqueue(val); +//! let _ =3D workqueue::system_percpu().enqueue(val); //! } //! # print_later(MyStruct::new(42).unwrap()); //! # print_now(MyStruct::new(42).unwrap()); @@ -292,6 +292,39 @@ pub fn enqueue(&self, w: W) -> W::En= queueOutput } } =20 + /// Enqueues a work item on a specific CPU. + /// + /// This may fail if the work item is already enqueued in a workqueue. + /// + /// The work item will be submitted on cpu_id. + pub fn enqueue_cpu(&self, w: W, cpu_id: u32) -> W::E= nqueueOutput + where + W: RawWorkItem + Send + 'static, + { + let queue_ptr =3D self.0.get(); + + // SAFETY: We only return `false` if the `work_struct` is already = in a workqueue. The other + // `__enqueue` requirements are not relevant since `W` is `Send` a= nd static. + // + // The call to `bindings::queue_work_on` will dereference the prov= ided raw pointer, which + // is ok because `__enqueue` guarantees that the pointer is valid = for the duration of this + // closure. + // + // Furthermore, if the C workqueue code accesses the pointer after= this call to + // `__enqueue`, then the work item was successfully enqueued, and = `bindings::queue_work_on` + // will have returned true. In this case, `__enqueue` promises tha= t the raw pointer will + // stay valid until we call the function pointer in the `work_stru= ct`, so the access is ok. + unsafe { + w.__enqueue(move |work_ptr| { + bindings::queue_work_on( + cpu_id as ffi::c_int, + queue_ptr, + work_ptr, + ) + }) + } + } + /// Enqueues a delayed work item. /// /// This may fail if the work item is already enqueued in a workqueue. @@ -328,6 +361,42 @@ pub fn enqueue_delayed(&self, w: W, = delay: Jiffies) -> W::Enqu } } =20 + /// Enqueues a delayed work item on a specific CPU. + /// + /// This may fail if the work item is already enqueued in a workqueue. + /// + /// The work item will be submitted on cpu_id. + pub fn enqueue_delayed_cpu(&self, w: W, delay: Jiffi= es, cpu_id: u32) -> W::EnqueueOutput + where + W: RawDelayedWorkItem + Send + 'static, + { + let queue_ptr =3D self.0.get(); + + // SAFETY: We only return `false` if the `work_struct` is already = in a workqueue. The other + // `__enqueue` requirements are not relevant since `W` is `Send` a= nd static. + // + // The call to `bindings::queue_delayed_work_on` will dereference = the provided raw pointer, + // which is ok because `__enqueue` guarantees that the pointer is = valid for the duration of + // this closure, and the safety requirements of `RawDelayedWorkIte= m` expands this + // requirement to apply to the entire `delayed_work`. + // + // Furthermore, if the C workqueue code accesses the pointer after= this call to + // `__enqueue`, then the work item was successfully enqueued, and + // `bindings::queue_delayed_work_on` will have returned true. In t= his case, `__enqueue` + // promises that the raw pointer will stay valid until we call the= function pointer in the + // `work_struct`, so the access is ok. + unsafe { + w.__enqueue(move |work_ptr| { + bindings::queue_delayed_work_on( + cpu_id as ffi::c_int, + queue_ptr, + container_of!(work_ptr, bindings::delayed_work, work), + delay, + ) + }) + } + } + /// Tries to spawn the given function or closure as a work item. /// /// This method can fail because it allocates memory to store the work= item. @@ -934,17 +1003,32 @@ unsafe impl RawDelayedWorkItem= for Pin> { } =20 -/// Returns the system work queue (`system_wq`). +/// Returns the per-cpu system work queue (`system_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. +/// +/// Note: `system_wq` will be removed in a future release cycle. Use [`sys= tem_percpu_wq`] instead. pub fn system() -> &'static Queue { // SAFETY: `system_wq` is a C global, always available. unsafe { Queue::from_raw(bindings::system_wq) } } =20 +/// Returns the per-cpu 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. +/// +/// Note: `system_percpu_wq` will replace `system_wq` in a future release = cycle. +pub fn system_percpu() -> &'static Queue { + // SAFETY: `system_percpu_wq` is a C global, always available. + unsafe { Queue::from_raw(bindings::system_percpu_wq) } +} + /// Returns the system high-priority work queue (`system_highpri_wq`). /// /// It is similar to the one returned by [`system`] but for work items whi= ch require higher --=20 2.52.0