[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <CACB1415-0535-4A05-B904-5F388A1F7C08@collabora.com>
Date: Sun, 27 Jul 2025 14:17:05 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Sidong Yang <sidong.yang@...iosa.ai>
Cc: Caleb Sander Mateos <csander@...estorage.com>,
Benno Lossin <lossin@...nel.org>,
Miguel Ojeda <ojeda@...nel.org>,
Arnd Bergmann <arnd@...db.de>,
Jens Axboe <axboe@...nel.dk>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
io-uring@...r.kernel.org
Subject: Re: [RFC PATCH v2 0/4] rust: miscdevice: abstraction for uring-cmd
Hi Sidong,
> On 27 Jul 2025, at 12:03, Sidong Yang <sidong.yang@...iosa.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.
>
> I received a email from kernel bot that `io_tw_state` is not FFI-safe.
> It seems that the struct has no field how can I fix this?
It’s not something that you introduced. Empty structs are problematic when
used in FFI, because ZSTs are not defined in the C standard AFAIK, although
they are supported in some compilers. For example, this is not illegal nor UB
in GCC [0]. The docs say:
> The structure has size zero.
This aligns with Rust's treatment of ZSTs, which are also zero-sized, so I
don't think this will be a problem, but lets wait for others to chime in.
I'll review this tomorrow.
>
> Changelog:
> v2:
> * use pinned &mut for IoUringCmd
> * add missing safety comments
> * use write_volatile for read uring_cmd in 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 | 183 +++++++++++++++++++++++++++++++
> rust/kernel/lib.rs | 1 +
> rust/kernel/miscdevice.rs | 41 +++++++
> samples/rust/rust_misc_device.rs | 34 ++++++
> 5 files changed, 261 insertions(+)
> create mode 100644 rust/kernel/io_uring.rs
>
> --
> 2.43.0
>
>
— Daniel
[0]: https://gcc.gnu.org/onlinedocs/gcc/Empty-Structures.html
Powered by blists - more mailing lists