Page MenuHomeFreeBSD

busdma: Avoid overallocation of bounce pages
Needs ReviewPublic

Authored by markj on Mon, Dec 23, 9:01 PM.
Tags
None
Referenced Files
F106498023: D48182.diff
Tue, Dec 31, 6:27 PM
Unknown Object (File)
Fri, Dec 27, 11:37 AM
Unknown Object (File)
Fri, Dec 27, 7:44 AM
Unknown Object (File)
Fri, Dec 27, 5:52 AM

Details

Summary

A busdma tag maintains a "bounce zone", an allocator of pages that can
be used to transfer data when a DMA mapping requires bouncing. These
pages are generally reserved at DMA map creation time, or at tag
creation time (if BUS_DMA_ALLOCNOW is specified).

busdma tags may share a single bounce zone. If BUS_DMA_ALLOCNOW is not
specified when creating a tag, then the first mapping created for that
tag will reserve a page in the bounce zone, even though it may not be
needed. This can result in overallocation and leaks of memory if many
busdma tags and mappings are created, or if tags and mappings are
destroyed and re-created over time.

Commit 6fa7734d6fbbe attempted to fix this, but made the bounce page
reservation logic too restrictive, causing some drivers to fail to
reserve bounce pages entirely; it was reverted in commit eae22c44301.

Try again to fix the same problem: try to reserve pages if the zone does
not already exceed its maximum. While here, simplify logic used to set
the BUS_DMA_MI_ALLOC_COMP flag on a tag after bounce pages are
successfully reserved.

PR: 278569

Test Plan

I modified e1000 to require bouncing for buffers above 4GB, and verified that it reserved and used bounce pages during a stress test.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 61310
Build 58194: arc lint + arc unit