rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: workqueue: define built-in bh queues
@ 2025-02-21 22:35 Hamza Mahfooz
  2025-02-21 22:45 ` Miguel Ojeda
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Hamza Mahfooz @ 2025-02-21 22:35 UTC (permalink / raw)
  To: rust-for-linux
  Cc: Hamza Mahfooz, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Wedson Almeida Filho, Nell Shamrell-Harrington,
	Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
	linux-kernel

We provide these methods because it lets us access these queues from
Rust without using unsafe code.

Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-02-24 17:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 22:35 [PATCH] rust: workqueue: define built-in bh queues Hamza Mahfooz
2025-02-21 22:45 ` Miguel Ojeda
2025-02-22  4:17   ` Jarkko Sakkinen
2025-02-22  4:37     ` Jarkko Sakkinen
2025-02-22  4:41       ` Boqun Feng
2025-02-22  6:04         ` Jarkko Sakkinen
2025-02-22 11:57           ` Miguel Ojeda
2025-02-24 17:26             ` Tejun Heo
2025-02-22  4:15 ` Jarkko Sakkinen
2025-02-22 11:53   ` Miguel Ojeda
2025-02-24 17:19 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).