On 2025-09-08 at 21:42 +1000, Alexandre Courbot <[email protected]> wrote... > On Mon Sep 8, 2025 at 8:31 PM JST, Alistair Popple wrote: > > On 2025-09-07 at 20:54 +1000, Alice Ryhl <[email protected]> wrote... > >> On Wed, Aug 27, 2025 at 06:20:01PM +1000, Alistair Popple wrote: > >> > From: Joel Fernandes <[email protected]> > >> > > >> > A data structure that can be used to write across multiple slices which > >> > may be out of order in memory. This lets SBuffer user correctly and > >> > safely write out of memory order, without error-prone tracking of > >> > pointers/offsets. > >> > > >> > let mut buf1 = [0u8; 3]; > >> > let mut buf2 = [0u8; 5]; > >> > let mut sbuffer = SBuffer::new([&mut buf1[..], &mut buf2[..]]); > >> > > >> > let data = b"hellowo"; > >> > let result = sbuffer.write(data); > >> > > >> > An internal conversion of gsp.rs to use this resulted in a nice -ve > >> > delta: > >> > gsp.rs: 37 insertions(+), 99 deletions(-) > >> > > >> > Co-developed-by: Alistair Popple <[email protected]> > >> > Signed-off-by: Alistair Popple <[email protected]> > >> > Signed-off-by: Joel Fernandes <[email protected]> > >> > >> This seems like duplication of the logic in rust/kernel/iov_iter.rs [1]. > > > > Conceptually I guess there is some overlap. The thing that's different here > > is we don't have any C version of the iovec struct or iov_iter, and AFAICT > > [1] > > doesn't provide any way of creating one from within Rust code. > > Yup, I was about to ask as well - I am not familiar with the C API, but > how can we use it from Rust, using e.g. a pair of slices as the data > source/destination? I see that `struct iovec` also has `__user` marker > for its base, which hints to me that it is not designed to work with > kernel data?
There are various flavours of iovec which you can iterate over. For example there is kvec[1] which doesn't have the `__user` marker. But none of these are what we want because we're not interacting with C code at all here. [1] - https://elixir.bootlin.com/linux/v6.16.5/source/include/linux/uio.h#L18
