[RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd

Sidong Yang posted 4 patches 2 months, 2 weeks ago
There is a newer version of this series
rust/bindings/bindings_helper.h  |   2 +
rust/kernel/io_uring.rs          | 114 +++++++++++++++++++++++++++++++
rust/kernel/lib.rs               |   1 +
rust/kernel/miscdevice.rs        |  34 +++++++++
samples/rust/rust_misc_device.rs |  30 ++++++++
5 files changed, 181 insertions(+)
create mode 100644 rust/kernel/io_uring.rs
[RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Sidong Yang 2 months, 2 weeks ago
This patch series implemens an abstraction for io-uring sqe and cmd and
adds uring_cmd callback for miscdevice. Also there is an example that use
uring_cmd in rust-miscdevice sample.

Sidong Yang (4):
  rust: bindings: add io_uring headers in bindings_helper.h
  rust: io_uring: introduce rust abstraction for io-uring cmd
  rust: miscdevice: add uring_cmd() for MiscDevice trait
  samples: rust: rust_misc_device: add uring_cmd example

 rust/bindings/bindings_helper.h  |   2 +
 rust/kernel/io_uring.rs          | 114 +++++++++++++++++++++++++++++++
 rust/kernel/lib.rs               |   1 +
 rust/kernel/miscdevice.rs        |  34 +++++++++
 samples/rust/rust_misc_device.rs |  30 ++++++++
 5 files changed, 181 insertions(+)
 create mode 100644 rust/kernel/io_uring.rs

-- 
2.43.0
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Danilo Krummrich 2 months, 2 weeks ago
Hi Sidong,

On 7/19/25 4:33 PM, Sidong Yang wrote:
> This patch series implemens an abstraction for io-uring sqe and cmd and
> adds uring_cmd callback for miscdevice. Also there is an example that use
> uring_cmd in rust-miscdevice sample.

Please also add Greg, maybe get_maintainer.pl does not list him, since the
entries for miscdevice were missing for a while I think.

For new abstractions I also recommend to Cc the RUST reviewers.

Thanks,
Danilo
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Sidong Yang 2 months, 2 weeks ago
On Sat, Jul 19, 2025 at 07:03:24PM +0200, Danilo Krummrich wrote:
> Hi Sidong,
> 
> On 7/19/25 4:33 PM, Sidong Yang wrote:
> > This patch series implemens an abstraction for io-uring sqe and cmd and
> > adds uring_cmd callback for miscdevice. Also there is an example that use
> > uring_cmd in rust-miscdevice sample.
> 
> Please also add Greg, maybe get_maintainer.pl does not list him, since the
> entries for miscdevice were missing for a while I think.
> 
> For new abstractions I also recommend to Cc the RUST reviewers.

Thanks for a advice. I've added Greg, and other RUST reviewers to Cc. 

Thanks,
Sidong

> 
> Thanks,
> Danilo
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Miguel Ojeda 2 months, 2 weeks ago
On Sat, Jul 19, 2025 at 4:34 PM Sidong Yang <sidong.yang@furiosa.ai> wrote:
>
> This patch series implemens an abstraction for io-uring sqe and cmd and
> adds uring_cmd callback for miscdevice. Also there is an example that use
> uring_cmd in rust-miscdevice sample.

Who will be using these?

Thanks!

Cheers,
Miguel
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Sidong Yang 2 months, 2 weeks ago
On Sat, Jul 19, 2025 at 06:34:49PM +0200, Miguel Ojeda wrote:
> On Sat, Jul 19, 2025 at 4:34 PM Sidong Yang <sidong.yang@furiosa.ai> wrote:
> >
> > This patch series implemens an abstraction for io-uring sqe and cmd and
> > adds uring_cmd callback for miscdevice. Also there is an example that use
> > uring_cmd in rust-miscdevice sample.
> 
> Who will be using these?

Hi, Miguel

Although some existing kernel modules already use uring_cmd, they aren’t 
implemented in Rust. Currently, no Rust code leverages this abstraction, 
but it will enable anyone who wants to write kernel drivers in Rust using 
uring_cmd.

Thanks,
Sidong

> 
> Thanks!
> 
> Cheers,
> Miguel
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Miguel Ojeda 2 months, 2 weeks ago
On Sun, Jul 20, 2025 at 6:07 PM Sidong Yang <sidong.yang@furiosa.ai> wrote:
>
> Although some existing kernel modules already use uring_cmd, they aren’t
> implemented in Rust. Currently, no Rust code leverages this abstraction,
> but it will enable anyone who wants to write kernel drivers in Rust using
> uring_cmd.

Do you have a concrete user in mind?

i.e. I am asking because the kernel, in general, requires a user (in
mainline) for code to be merged. So maintainers normally don't merge
code unless it is clear who will use a feature upstream -- please see
the last bullet of:

    https://rust-for-linux.com/contributing#submitting-new-abstractions-and-modules

Thanks!

Cheers,
Miguel
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Sidong Yang 2 months, 2 weeks ago
On Sun, Jul 20, 2025 at 06:41:06PM +0200, Miguel Ojeda wrote:
> On Sun, Jul 20, 2025 at 6:07 PM Sidong Yang <sidong.yang@furiosa.ai> wrote:
> >
> > Although some existing kernel modules already use uring_cmd, they aren’t
> > implemented in Rust. Currently, no Rust code leverages this abstraction,
> > but it will enable anyone who wants to write kernel drivers in Rust using
> > uring_cmd.
> 
> Do you have a concrete user in mind?

Sadly, there isn’t a concrete user yet. I understand that an abstraction by itself
won’t be merged without a real in-tree user.
I’ll identify a suitable kernel module to port to Rust and follow up once I have one.

Thanks,
Sidong

> 
> i.e. I am asking because the kernel, in general, requires a user (in
> mainline) for code to be merged. So maintainers normally don't merge
> code unless it is clear who will use a feature upstream -- please see
> the last bullet of:
> 
>     https://rust-for-linux.com/contributing#submitting-new-abstractions-and-modules
> 
> Thanks!
> 
> Cheers,
> Miguel
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Miguel Ojeda 2 months, 2 weeks ago
On Sun, Jul 20, 2025 at 6:52 PM Sidong Yang <sidong.yang@furiosa.ai> wrote:
>
> Sadly, there isn’t a concrete user yet. I understand that an abstraction by itself
> won’t be merged without a real in-tree user.
> I’ll identify a suitable kernel module to port to Rust and follow up once I have one.

Sounds good, thanks!

(Just in case: maintainers may or may not want to have an equivalent
Rust module for a C one, it is up to them. In that case,
https://rust-for-linux.com/rust-reference-drivers may help.).

Cheers,
Miguel
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Nikita Krasnov 2 months, 2 weeks ago
On Sat, Jul 19, 2025 at 05:33:54PM +0300 Sidong Yang wrote:
> This patch series implemens an abstraction for io-uring sqe and cmd and
> adds uring_cmd callback for miscdevice. Also there is an example that use
> uring_cmd in rust-miscdevice sample.
> 
> Sidong Yang (4):
>   rust: bindings: add io_uring headers in bindings_helper.h
>   rust: io_uring: introduce rust abstraction for io-uring cmd
>   rust: miscdevice: add uring_cmd() for MiscDevice trait
>   samples: rust: rust_misc_device: add uring_cmd example
> 
>  rust/bindings/bindings_helper.h  |   2 +
>  rust/kernel/io_uring.rs          | 114 +++++++++++++++++++++++++++++++
>  rust/kernel/lib.rs               |   1 +
>  rust/kernel/miscdevice.rs        |  34 +++++++++
>  samples/rust/rust_misc_device.rs |  30 ++++++++
>  5 files changed, 181 insertions(+)
>  create mode 100644 rust/kernel/io_uring.rs
> 

Is it just me or did the [PATCH 2/4] get lost? I only see 
[RFC PATCH 0/4], [PATCH 1/4], [PATCH 3/4] and [PATCH 4/4].

-- 
Nikita Krasnov
Re: [RFC PATCH 0/4] rust: miscdevice: abstraction for uring-cmd
Posted by Nikita Krasnov 2 months, 2 weeks ago
On Sat, Jul 19, 2025 at 06:00:18PM +0300 Nikita Krasnov wrote:
> On Sat, Jul 19, 2025 at 05:33:54PM +0300 Sidong Yang wrote:
>> This patch series implemens an abstraction for io-uring sqe and cmd and
>> adds uring_cmd callback for miscdevice. Also there is an example that use
>> uring_cmd in rust-miscdevice sample.
>> 
>> Sidong Yang (4):
>>   rust: bindings: add io_uring headers in bindings_helper.h
>>   rust: io_uring: introduce rust abstraction for io-uring cmd
>>   rust: miscdevice: add uring_cmd() for MiscDevice trait
>>   samples: rust: rust_misc_device: add uring_cmd example
>> 
>>  rust/bindings/bindings_helper.h  |   2 +
>>  rust/kernel/io_uring.rs          | 114 +++++++++++++++++++++++++++++++
>>  rust/kernel/lib.rs               |   1 +
>>  rust/kernel/miscdevice.rs        |  34 +++++++++
>>  samples/rust/rust_misc_device.rs |  30 ++++++++
>>  5 files changed, 181 insertions(+)
>>  create mode 100644 rust/kernel/io_uring.rs
>> 
> 
> Is it just me or did the [PATCH 2/4] get lost? I only see 
> [RFC PATCH 0/4], [PATCH 1/4], [PATCH 3/4] and [PATCH 4/4].

Never mind, there it is. Sorry for noise.

-- 
Nikita Krasnov