rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] rust: workqueue: define built-in bh queues
@ 2025-02-24 14:23 Hamza Mahfooz
  2025-02-24 17:31 ` Tejun Heo
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Hamza Mahfooz @ 2025-02-24 14:23 UTC (permalink / raw)
  To: rust-for-linux
  Cc: Tejun Heo, Lai Jiangshan, 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, Dirk Behme, Konstantin Andrikopoulos,
	Danilo Krummrich, Roland Xu, linux-kernel

Provide safe getters to the system bh work queues. They will be used
to reimplement the Hyper-V VMBus in rust.

Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
---
v2: make the commit message suck less.
---
 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] 6+ messages in thread

* Re: [PATCH v2] rust: workqueue: define built-in bh queues
  2025-02-24 14:23 [PATCH v2] rust: workqueue: define built-in bh queues Hamza Mahfooz
@ 2025-02-24 17:31 ` Tejun Heo
  2025-02-24 18:03   ` Hamza Mahfooz
  2025-02-24 18:09 ` Boqun Feng
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Tejun Heo @ 2025-02-24 17:31 UTC (permalink / raw)
  To: Hamza Mahfooz
  Cc: rust-for-linux, Lai Jiangshan, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Wedson Almeida Filho,
	Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
	linux-kernel

On Mon, Feb 24, 2025 at 09:23:23AM -0500, Hamza Mahfooz wrote:
> Provide safe getters to the system bh work queues. They will be used
> to reimplement the Hyper-V VMBus in rust.
> 
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>

Ah, you already sent v2.

  Acked-by: Tejun Heo <tj@kernel.org>

Again, let me know how you want route it.

Thanks.

-- 
tejun

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

* Re: [PATCH v2] rust: workqueue: define built-in bh queues
  2025-02-24 17:31 ` Tejun Heo
@ 2025-02-24 18:03   ` Hamza Mahfooz
  0 siblings, 0 replies; 6+ messages in thread
From: Hamza Mahfooz @ 2025-02-24 18:03 UTC (permalink / raw)
  To: Tejun Heo
  Cc: rust-for-linux, Lai Jiangshan, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Wedson Almeida Filho,
	Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
	linux-kernel

On Mon, Feb 24, 2025 at 07:31:49AM -1000, Tejun Heo wrote:
> On Mon, Feb 24, 2025 at 09:23:23AM -0500, Hamza Mahfooz wrote:
> > Provide safe getters to the system bh work queues. They will be used
> > to reimplement the Hyper-V VMBus in rust.
> > 
> > Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
> 
> Ah, you already sent v2.
> 
>   Acked-by: Tejun Heo <tj@kernel.org>
> 
> Again, let me know how you want route it.

I would prefer it it went through the workqueue tree, thanks!

> 
> Thanks.
> 
> -- 
> tejun

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

* Re: [PATCH v2] rust: workqueue: define built-in bh queues
  2025-02-24 14:23 [PATCH v2] rust: workqueue: define built-in bh queues Hamza Mahfooz
  2025-02-24 17:31 ` Tejun Heo
@ 2025-02-24 18:09 ` Boqun Feng
  2025-02-24 18:12 ` Alice Ryhl
  2025-02-24 18:14 ` Tejun Heo
  3 siblings, 0 replies; 6+ messages in thread
From: Boqun Feng @ 2025-02-24 18:09 UTC (permalink / raw)
  To: Hamza Mahfooz
  Cc: rust-for-linux, Tejun Heo, Lai Jiangshan, Miguel Ojeda,
	Alex Gaynor, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Wedson Almeida Filho,
	Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
	linux-kernel

Hi Hamza,

On Mon, Feb 24, 2025 at 09:23:23AM -0500, Hamza Mahfooz wrote:
> Provide safe getters to the system bh work queues. They will be used
> to reimplement the Hyper-V VMBus in rust.
> 
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
> ---
> v2: make the commit message suck less.
> ---
>  rust/kernel/workqueue.rs | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 

while you're at it, could you also add some usage of system_bh() in the
example at around line 77 in workqueue.rs? It could demonstrate the
usage and generate unit tests. Thanks!

Regards,
Boqun

> 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	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] rust: workqueue: define built-in bh queues
  2025-02-24 14:23 [PATCH v2] rust: workqueue: define built-in bh queues Hamza Mahfooz
  2025-02-24 17:31 ` Tejun Heo
  2025-02-24 18:09 ` Boqun Feng
@ 2025-02-24 18:12 ` Alice Ryhl
  2025-02-24 18:14 ` Tejun Heo
  3 siblings, 0 replies; 6+ messages in thread
From: Alice Ryhl @ 2025-02-24 18:12 UTC (permalink / raw)
  To: Hamza Mahfooz
  Cc: rust-for-linux, Tejun Heo, Lai Jiangshan, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Trevor Gross,
	Wedson Almeida Filho, Dirk Behme, Konstantin Andrikopoulos,
	Danilo Krummrich, Roland Xu, linux-kernel

On Mon, Feb 24, 2025 at 3:23 PM Hamza Mahfooz
<hamzamahfooz@linux.microsoft.com> wrote:
>
> Provide safe getters to the system bh work queues. They will be used
> to reimplement the Hyper-V VMBus in rust.
>
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

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

* Re: [PATCH v2] rust: workqueue: define built-in bh queues
  2025-02-24 14:23 [PATCH v2] rust: workqueue: define built-in bh queues Hamza Mahfooz
                   ` (2 preceding siblings ...)
  2025-02-24 18:12 ` Alice Ryhl
@ 2025-02-24 18:14 ` Tejun Heo
  3 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2025-02-24 18:14 UTC (permalink / raw)
  To: Hamza Mahfooz
  Cc: rust-for-linux, Lai Jiangshan, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Wedson Almeida Filho,
	Dirk Behme, Konstantin Andrikopoulos, Danilo Krummrich, Roland Xu,
	linux-kernel

On Mon, Feb 24, 2025 at 09:23:23AM -0500, Hamza Mahfooz wrote:
> Provide safe getters to the system bh work queues. They will be used
> to reimplement the Hyper-V VMBus in rust.
> 
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>

Applied to wq/for-6.15.

Thanks.

-- 
tejun

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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 14:23 [PATCH v2] rust: workqueue: define built-in bh queues Hamza Mahfooz
2025-02-24 17:31 ` Tejun Heo
2025-02-24 18:03   ` Hamza Mahfooz
2025-02-24 18:09 ` Boqun Feng
2025-02-24 18:12 ` Alice Ryhl
2025-02-24 18:14 ` 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).