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)
Mon, Sep 29, 6:30 AM
Unknown Object (File)
Fri, Sep 26, 5:40 PM
Unknown Object (File)
Fri, Sep 26, 5:40 PM
Unknown Object (File)
Fri, Sep 26, 5:40 PM
Unknown Object (File)
Sun, Sep 21, 9:52 PM
Unknown Object (File)
Fri, Sep 19, 5:19 PM
Unknown Object (File)
Sep 7 2025, 2:29 PM
Unknown Object (File)
Sep 2 2025, 10:57 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.