Page MenuHomeFreeBSD

LinuxKPI: always use contig allocations in linux_alloc_kmem()
ClosedPublic

Authored by bz on Sep 12 2024, 9:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 29, 1:03 AM
Unknown Object (File)
Wed, Apr 29, 1:00 AM
Unknown Object (File)
Tue, Apr 28, 1:32 AM
Unknown Object (File)
Mon, Apr 27, 8:58 AM
Unknown Object (File)
Apr 8 2026, 9:13 PM
Unknown Object (File)
Apr 8 2026, 8:15 AM
Unknown Object (File)
Apr 7 2026, 6:49 AM
Unknown Object (File)
Apr 5 2026, 11:24 AM

Details

Summary

In linux_alloc_kmem() [used by *get_page*()] we always at least allocate
PAGE_SIZE and we want the allocation to be contiguous so it can be passed
to DMA. Always use kmem_alloc_contig() and only change the low argument
depending on the GFP_DMA32 flag being given or not.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested review of this revision.Sep 12 2024, 9:25 PM

I just built a kernel with this patch and will use it starting from tomorrow.

The documentation is not entirely clear, but both core-api/dma-api-howto.rst and kernel-hacking/hacking.rst do imply that these functions allocate contiguous memory. Also, the PMAP_HAS_DMAP version in the caller of this function is careful to allocate contiguous memory always.

This revision is now accepted and ready to land.Jan 29 2025, 9:42 PM

After three days of using it, I didn’t see any regressions.