[Bug 228335] [patch] virtio indirect descriptors should use contiguous memory

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri May 18 23:54:53 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=228335

--- Comment #1 from Bryan Venteicher <bryanv at FreeBSD.org> ---
See this comment in virtio.h:

/*
 * Each virtqueue indirect descriptor list must be physically contiguous.
 * To allow us to malloc(9) each list individually, limit the number
 * supported to what will fit in one page. With 4KB pages, this is a limit
 * of 256 descriptors. If there is ever a need for more, we can switch to
 * contigmalloc(9) for the larger allocations, similar to what
 * bus_dmamem_alloc(9) does.
 *
 * Note the sizeof(struct vring_desc) is 16 bytes.
 */
#define VIRTIO_MAX_INDIRECT ((int) (PAGE_SIZE / 16))

This code is quite old but my recollection is that the minimum allocation
returned by contigmalloc() is (was?) a page which ends up wasting a lot of
memory. What is the "different memory allocator"? If you're indifferent to
VirtIO then disabling indrect descriptors is an option. However, I believe
there are a handful of other places in VirtIO where the malloc allocation is
capped at one page.

That being said, I don't like depending on the behavior of malloc behavior
here. I'm working on VirtIO V1 support, and after that, was going to switch
VirtIO to bus_dma(9) for later IOMMU/"physical" virtio devices support.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list