This revision replaces D59436 and makes LinuxKPI vmap() honor the requested cache policy while preserving that policy across compatible overlapping aliases.
Implementation
- Track one cache-attribute record per vm_page_t in a pctrie. Compatible aliases share the record and hold references until their final vunmap().
- Use LINUXKPI_PROT_VALID to distinguish an unspecified policy from an explicit write-back policy. Reject conflicting explicit attributes and reference-count overflow, with rate-limited diagnostics for rejected mappings.
- Allocate the per-vmap pointer table with kvmalloc_array(), so large mappings do not require physically contiguous memory.
- Split pmap_qenter() and pmap_qremove() calls so their signed-int page count and internal count * PAGE_SIZE calculations remain representable.
- Make the PowerPC AIM OEA64 pmap_qenter() implementation install each page's recorded memory attribute, matching the contract used by the generic LinuxKPI change.
- Remove a departing vmap's PTEs before releasing its attribute references. Restore the saved attribute on the last reference when the tracked attribute is still active and no managed mapping remains.
- Roll back all acquired references and attribute changes when allocation fails.
- Keep the caller responsible for page lifetime and for mappings outside vmap(). linuxkpi_vmap_pfn(), ioremap(), fictitious aliases, and native pmap_qenter() aliases are outside this bookkeeping.
All earlier inline review requests remain applied: pctrie storage, the insertion helper, block-comment placement, requested whitespace, separate rate-limited failure diagnostics, removal of the redundant division check, and a focused test description.
The patch is based on FreeBSD main f74e0184df8cbf39b72fa4b4eab36137e807790e.
D59481 and D59883 concern managed PFN ownership and reclamation. The drm-kmod work in https://github.com/freebsd/drm-kmod/pull/496 concerns separate graphics mappings. Those changes are outside this revision, and this revision does not claim to resolve every reported GPU hang.
Complete standalone patch with full-file context
https://reviews.freebsd.org/F178282641
Source for the native, boundary, allocation-failure, chunking, and concurrency tests