Re: [PATCH 1/2] rust: add initial scatterlist bindings
From: Abdiel Janulgue
Date: Mon Jun 02 2025 - 08:26:14 EST
On 02/06/2025 14:40, Jason Gunthorpe wrote:
On Sat, May 31, 2025 at 09:54:20PM +0900, Alexandre Courbot wrote:
So if I understood your idea correctly, this would mean creating the
SGTable and mapping it in one call, eschewing the typestate entirely?
Probably no need for a type state
And the `SGTable` would own the backing data, and only release it upon
destruction and unmapping?
But I don't think you can do this, it is not allowed to pin kmalloc
memory for instance so you have to do something as you showed to tie
the lifetime to the kmalloc across the sgtable lifetime.
We could explicitly have the SGTable own the backing store, so the
lifetime of the pages is connected to it? ie., we have a VVec with the
kmalloc allocator, instead of passing a a reference to pages, one could
have the page builder something in the likes of:
sgt.init(||
let k = Vec::<PageSlice, Kmalloc>::new();
k.reserve(pages, GFP_KERNEL) {
...
)
Anyway this probably needs the related (still WIP btw) support in:
https://lore.kernel.org/rust-for-linux/20241119112408.779243-3-abdiel.janulgue@xxxxxxxxx/
/Abdiel