From nobody Sun Feb 8 02:26:47 2026 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) (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 4F042421883 for ; Wed, 4 Feb 2026 15:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770220258; cv=none; b=KVBfIGqfGfYxobh9OfIcgFThBfzO7PHw1lvrxa+Z9SULLmuIHCLmibgiYUvd79AvbMh57Z1O0f1Fh2oueZBrKvaPOkaqc1NsAu6Hn9rl+MW4ZLxL0ZQgtxEq96rPyLxJhUHaBwzvi+SdbPcJTXXMFATUTjOh7Ogc/mEhTwHNSH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770220258; c=relaxed/simple; bh=so9g/9Fhc/PnB/Oc41ncP75JhzHK9HwO8kVevup0eEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KbJU/HeushsoLnF5udZECor3ojoSxvufltOS01HQ/6Il+SoN0IOOjFSVCGOLf/GtXtoAn2iFN0lJWDCWiIvrSciTigUYcq3MJM3Oq8E/weo5w+/yobWKm9/z33Q5JkZD3tEok6zI4d0pTsZ0MJBigMNbrjjbMy6/rZ3/M9roUak= 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=IjXODi/M; arc=none smtp.client-ip=209.85.128.67 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="IjXODi/M" Received: by mail-wm1-f67.google.com with SMTP id 5b1f17b1804b1-47ee76e8656so94693455e9.0 for ; Wed, 04 Feb 2026 07:50:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1770220256; x=1770825056; 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=uT/xyZK4EJ/ek5utcqcmzn3TDnBpie0X0xrxkYJsyXI=; b=IjXODi/MB/Gm02Zeex7kWOOiYJqL3hfs51bPVGVLE+9eVxEKwyoQxvrPcbY54EPwar /wQSjJLcd5KH6f4bi93uSUnICvLAoZvwA5ZJCSRI6UJeWqVfdmdlgkmikPg5dyRh0ckb BjSZz13T/5tndXFhM91XDryN1un5MusRgcIlabzunMPJQ1nRd/QjRTdBfdc7M/lenbwO 2wEG9Y9XfhlY+jE9J4wpUbXCop2HJGU68SKxSGZY5vDYWXpsE05YVszSnPu4oBB6XpP+ wZmRjDkRJptP6Ee2JD5MKHTdEOwOrlr8hPKkxiWIDqV4W+xFD9an1QAAuwdfI3IxXQQu WV8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770220256; x=1770825056; 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=uT/xyZK4EJ/ek5utcqcmzn3TDnBpie0X0xrxkYJsyXI=; b=fzyfKmV8ryzjrE0tWACy8aOvHVw85uJrDC46W6kieKY6oiBbGNcrji6FoeT8/tdag/ VYQPLzWr+9+XWf60GZeMAo8to33JGBFDMSjW66hCvwdgRmsbNZ23FZ6hDBP1MWlCXa+g Us1BnHnZFXI/lAfJrx+3OGF7RSuijkDWwFq3xkAAPwb2ruqWDsB6fbwfOnQVtOodUNv0 5NvtjfAdPGwDHcQjYdV/LKr3Fqf1PLp10F1yBaf+RJ94NFrukLSqUQQXC3lp5tGZCG5H wvsqlNmPTiedQ8hB5YXWIAPKOhbAz4GxlkvseP16CJUep6ag2Ho6+f6hhToJn8dLfQ2p mp5g== X-Gm-Message-State: AOJu0Ywbyc/bJiD+q9MnN+a16+qkNLor6FRaxrfVh00k7CJF7Ghena36 uMVsDYUOY/4h5RldyXt0N9tWD3u0rD0Vw0omrJUxOUaV69KZlPhiZEB1hixFHjOrStMMrWlfkWi 96lTl X-Gm-Gg: AZuq6aLVLz1+HxoRejT2s9B9n6tSeWN5s388VZDmq1qLLpEYOU4oq2J/5tl38N5XlYz TtZlzQ4W+oV9AM2h+PxMooszNtclP8jS3SmXLFCZN6NJand6jYTcPF/g/7/jqjNM7GnzWAGOuBA MAF3rNkaqUWhBrIrEx8YToWZE+umQrfaP4DR2/Ur4+2yUWAtgZgPfDjeaHjNhFUW110JySX4SjM P8GF8dfTNjeF9sFPXlFyeiTf79euyof7riNHkUQ2qbyxo9LIrIhMWM68OZXBzj2mOXgxQ15Ei8/ LmnIe2zNmN87GUAD0v2Lem1wuEnCgaNGMVu1WL5/dALXBGjIZLMfj5tU2NGbSivxsGGoqRmB1xd sHaX1EzP77u53C3klPRnsIXTiH6mfOpyLkcHJW5GFMS78WLGx9eKzeyYTJpDdv4EOpkuScWmBo0 unqnovwIfGfLSc X-Received: by 2002:a05:600c:810b:b0:480:4a90:1af2 with SMTP id 5b1f17b1804b1-4830e979f7bmr45721295e9.35.1770220256456; Wed, 04 Feb 2026 07:50:56 -0800 (PST) Received: from linux ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483107e62d6sm51879535e9.0.2026.02.04.07.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Feb 2026 07:50:56 -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 v5 1/2] rust: add system_default() around the new system_dfl_wq Date: Wed, 4 Feb 2026 16:50:36 +0100 Message-ID: <20260204155037.325482-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260204155037.325482-1-marco.crivellari@suse.com> References: <20260204155037.325482-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_default(), 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 --- rust/kernel/workqueue.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs index 706e833e9702..adbecdb2b3a9 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_u= nbound_wq`. +pub fn system_default() -> &'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 02:26:47 2026 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) (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 B3C174218B2 for ; Wed, 4 Feb 2026 15:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770220260; cv=none; b=eMULwG6mIl0ABUn0ZTDg2+HgfI7zzTa/Dtzv6JWR6yEEUGuzqMHXXLOOuW1dkk6Oo22FCBubJVFQ6womEVQpVEi0tVaw8NOP5WQ6f/+CxhJo6yD+XY6w/WDLDiwWyVXQ2Q1J4av2tJXOmTyozyyQsOBvIOPFV9MIC1uk9jTzwck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770220260; c=relaxed/simple; bh=loMiS3d+EznbDCgp38avNhwcRx8n7oZGHw2JqevnF5c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sXM4cXSJxqdpUB5Fbha0mHKFcg7IlpAfOnKNU5vIt0LfdO0I+rCfrJFe/vwwEF0bDtHKPuvz0AvPUaqpp3ZHaaFf/ejKmjeNu28YYEbSLq298K/kg8rbBZ4AGfTflK2JAXytojCWDmR2LqnK6Vpc0GMtM4W6FYX/5t3+Eo5Zye8= 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=ebYlBKql; arc=none smtp.client-ip=209.85.128.66 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="ebYlBKql" Received: by mail-wm1-f66.google.com with SMTP id 5b1f17b1804b1-4806dffc64cso8080695e9.1 for ; Wed, 04 Feb 2026 07:50:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1770220258; x=1770825058; 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=tbqi2lUxamrBUmUgflwxoYXGoL4Y0kJLYTqAWHLN0gI=; b=ebYlBKql7uQNGIzObcyKaH73bMv4eCMFuWpeSO1EUkEaFvgOZqUy4Hd3D7vqZE5I9x QGQ5WxCv3e/g1fXbnTIl2VHLQeLsgR18Yu0h/2zWuTKbVvw0rVK3Q5VUNQPqUvAJgf9D 7R9dyavvynGiPaC1wg6KLdJDFIUzdCO6ErYYR2jam27/fXhFCjOM+E7gayzyekAwhqLY 2xJd7Yq6lQxuL2WEGL86CPvz2Wm/pdeLlhctOtEwypRiek5AWE7Z5ramEfH6/oLQjRmj scatfSiiyM0BL/WELYgk2uK3YdISIpxUThNseRWxl8lInjxDS0MuZYYKvQyFxCoJ6AWo yssA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770220258; x=1770825058; 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=tbqi2lUxamrBUmUgflwxoYXGoL4Y0kJLYTqAWHLN0gI=; b=rLOIjm6jS9ysIWUOQlmaSYX9QXxRt4yRVrth+CCkhp8KPF5+uWUmOloGq8cQ4BZgnv mvcee4WKGADuMsod40bApJiU//VkSTk1OIO8fM/4qyNqgyuZwG2mR6ngUuIE6HzKurSs E4cTl32/RMkvonAsVKn6iTvWKvQV5mmugZSs4GG1qXXTxylRo/VKLTMJDR7ZlyYASyyv r4Mh7ltfn0CZc54DSQ5qqhUVnQvKfSReosxRga6vQHvRLk3sONgZpxH+tJuZpc8rO/84 42hegSPhkm/KRVlo/3H+EY0MFLW4xPLrESQTbDWLbM7mtLuf4UQC3l6FBRHTUpXgeTPV tOLQ== X-Gm-Message-State: AOJu0Yws7D7ATnvIFAUReLy+xLwtWfnctI0YOTQaS6UxDTL33jrfGQU9 oxYy+vNLMSONGQzXOXFczjAc50JEssYMDUdKsvNdd/90UDehINZqc+OV4alPZPFirxTKGVBJWY3 gXVpt X-Gm-Gg: AZuq6aKTFz3ClEgiUthjQX6DvqmlLMJBNffFu4wHmCQORjAm+5CYLX2cbDi7PsCcaTS 1wmIzl6MaG5sszWRnNUYTOo1r4g7XGwvIe2lSxY2i9wqAGVVyTINV6fYTAc8MSPqPJldVje3qmw T6ldJoZhTCLsGXXrNiyXoSKhEVcMsluD3s/h4K9j27N4DnV6oVNQf8DOtNc0OldPxu2gJsn9Z3h vqiunsBFlIZdIAG6XzAVoSi0hCB6a63f752m4xToLQX5E3BrvVjmcBRo7ITwU6leZ6frwFz+WyD XlMVkJJLOwTPZvc62GaBKlBugGq6QjbcaJB4FHv/rLjGn6sCG18gZ71CDyCYvQ54qjRSy4f9Bqw dHMVa+GlROmoaV/7IEoQo39hnbc5xwxgJPww/pcN9/nyjiJD9rGEbWF7W6/LHOBJovj0CEeJvoW 1colK6ONT78wch X-Received: by 2002:a05:600c:6994:b0:480:4d39:84b3 with SMTP id 5b1f17b1804b1-4830e9262c8mr50063645e9.6.1770220257746; Wed, 04 Feb 2026 07:50:57 -0800 (PST) Received: from linux ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483107e62d6sm51879535e9.0.2026.02.04.07.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Feb 2026 07:50:57 -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 v5 2/2] rust: add system_percpu() and per-cpu enqueue functions Date: Wed, 4 Feb 2026 16:50:37 +0100 Message-ID: <20260204155037.325482-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260204155037.325482-1-marco.crivellari@suse.com> References: <20260204155037.325482-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 --- 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 adbecdb2b3a9..fd28fc74d5b7 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 `syst= em_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