[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250221223533.158959-1-hamzamahfooz@linux.microsoft.com>
Date: Fri, 21 Feb 2025 17:35:31 -0500
From: Hamza Mahfooz <hamzamahfooz@...ux.microsoft.com>
To: rust-for-linux@...r.kernel.org
Cc: Hamza Mahfooz <hamzamahfooz@...ux.microsoft.com>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Wedson Almeida Filho <walmeida@...rosoft.com>,
Nell Shamrell-Harrington <nells@...ux.microsoft.com>,
Dirk Behme <dirk.behme@...il.com>,
Konstantin Andrikopoulos <kernel@...dragore.io>,
Danilo Krummrich <dakr@...nel.org>,
Roland Xu <mu001999@...look.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] rust: workqueue: define built-in bh queues
We provide these methods because it lets us access these queues from
Rust without using unsafe code.
Signed-off-by: Hamza Mahfooz <hamzamahfooz@...ux.microsoft.com>
---
rust/kernel/workqueue.rs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
index 0cd100d2aefb..68ce70d94f2d 100644
--- a/rust/kernel/workqueue.rs
+++ b/rust/kernel/workqueue.rs
@@ -703,3 +703,21 @@ pub fn system_freezable_power_efficient() -> &'static Queue {
// SAFETY: `system_freezable_power_efficient_wq` is a C global, always available.
unsafe { Queue::from_raw(bindings::system_freezable_power_efficient_wq) }
}
+
+/// Returns the system bottom halves work queue (`system_bh_wq`).
+///
+/// It is similar to the one returned by [`system`] but for work items which
+/// need to run from a softirq context.
+pub fn system_bh() -> &'static Queue {
+ // SAFETY: `system_bh_wq` is a C global, always available.
+ unsafe { Queue::from_raw(bindings::system_bh_wq) }
+}
+
+/// Returns the system bottom halves high-priority work queue (`system_bh_highpri_wq`).
+///
+/// It is similar to the one returned by [`system_bh`] but for work items which
+/// require higher scheduling priority.
+pub fn system_bh_highpri() -> &'static Queue {
+ // SAFETY: `system_bh_highpri_wq` is a C global, always available.
+ unsafe { Queue::from_raw(bindings::system_bh_highpri_wq) }
+}
--
2.47.1
Powered by blists - more mailing lists