x86/busdma: Limit reserved pages if low nsegs
When bus_dmamap_create is called, if bouncing might be required we reserve enough pages for a maximum-length request, subject to the MAX_BPAGES constraint (32 MB on amd64; 32 MB or 2 MB on i386 depending on the amount of RAM). Since pages used for bouncing are typically non-consecutive, each bounced page will typically constitute a busdma segment; as such, we are unlikely to ever successfully use more pages than the nsegments limit. Limit the number of pages reserved to nsegments. On FreeBSD/Firecracker, this reduces bounce page memory consumption from 32 MB to 512 kB, making VMs with 128 MB of RAM usable. Reviewed by: imp, mav Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D37082
This commit is contained in:
parent
f585d13dd6
commit
b7761f1f08
@ -325,6 +325,7 @@ bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
|
||||
if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) == 0 ||
|
||||
(bz->map_count > 0 && bz->total_bpages < maxpages)) {
|
||||
pages = MAX(atop(dmat->common.maxsize), 1);
|
||||
pages = MIN(dmat->common.nsegments, pages);
|
||||
pages = MIN(maxpages - bz->total_bpages, pages);
|
||||
pages = MAX(pages, 1);
|
||||
if (alloc_bounce_pages(dmat, pages) < pages)
|
||||
|
Loading…
x
Reference in New Issue
Block a user