Alice Ryhl
2025-Sep-07 10:54 UTC
[PATCH 04/10] gpu: nova-core: Add a slice-buffer (sbuffer) datastructure
On Wed, Aug 27, 2025 at 06:20:01PM +1000, Alistair Popple wrote:> From: Joel Fernandes <joelagnelf at nvidia.com> > > 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 <apopple at nvidia.com> > Signed-off-by: Alistair Popple <apopple at nvidia.com> > Signed-off-by: Joel Fernandes <joelagnelf at nvidia.com>This seems like duplication of the logic in rust/kernel/iov_iter.rs [1]. Alice [1]: https://lore.kernel.org/r/20250822-iov-iter-v5-0-6ce4819c2977 at google.com
Alistair Popple
2025-Sep-08 11:31 UTC
[PATCH 04/10] gpu: nova-core: Add a slice-buffer (sbuffer) datastructure
On 2025-09-07 at 20:54 +1000, Alice Ryhl <aliceryhl at google.com> wrote...> On Wed, Aug 27, 2025 at 06:20:01PM +1000, Alistair Popple wrote: > > From: Joel Fernandes <joelagnelf at nvidia.com> > > > > 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 <apopple at nvidia.com> > > Signed-off-by: Alistair Popple <apopple at nvidia.com> > > Signed-off-by: Joel Fernandes <joelagnelf at nvidia.com> > > 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.> Alice > > [1]: https://lore.kernel.org/r/20250822-iov-iter-v5-0-6ce4819c2977 at google.com