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)
Fri, Nov 21, 12:50 AM
Unknown Object (File)
Wed, Nov 19, 2:39 AM
Unknown Object (File)
Tue, Nov 11, 12:57 AM
Unknown Object (File)
Thu, Nov 6, 8:56 PM
Unknown Object (File)
Sun, Nov 2, 2:23 PM
Unknown Object (File)
Sun, Nov 2, 7:36 AM
Unknown Object (File)
Sun, Nov 2, 7:33 AM
Unknown Object (File)
Sun, Nov 2, 7:29 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.