On Wed, Jan 04, 2023 at 06:14:34PM +0000, Richard W.M. Jones wrote:
(3) It seems like some drivers require pre-allocated memory regions,
and since some do that means we might as well implement this. It
also seems like some drivers require file-backed pre-allocated
memory regions, and so we might as well implement that too.
However what is not clear: does memfd_create(2) always allocate
sufficiently aligned memory regions, such that we never need to bother
reading the mem-region-alignment property?
I notice that the example:
https://gitlab.com/libblkio/libblkio/-/blob/main/examples/blkio-copy.c
just passes on this and calls blkio_alloc_mem_region(). Is that the
safest and easiest thing to do which will always work?
So this seems to be the reverse of what I thought.
In nbdkit plugins ideally we'd like to avoid using bounce buffers if
possible. Also NBD requests can be up to (IIRC) 32M, although we can
hint to the client to limit them to some smaller number.
If I call blkio_alloc_mem_region() unconditionally then it seems as if
I always need to use this as a bounce buffer. Plus, is 32M too large
for a memory region allocated this way? The example allocates 128K.
It seems like for drivers which _don't_ require pre-allocated memory
regions then we should avoid calling blkio_alloc_mem_region which
would avoid bounce buffers.
Some guidance about this would be appreciated.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html