Page MenuHomeFreeBSD

LinuxKPI: Have kvzalloc() rely on kvmalloc(), not kmalloc()
ClosedPublic

Authored by olce on Jul 11 2025, 6:52 AM.
Tags
None
Referenced Files
F164541467: D51247.id.diff
Sun, Aug 2, 12:17 AM
Unknown Object (File)
Sun, Jul 26, 1:45 PM
Unknown Object (File)
Sat, Jul 25, 1:20 PM
Unknown Object (File)
Tue, Jul 21, 6:05 PM
Unknown Object (File)
Wed, Jul 15, 11:41 AM
Unknown Object (File)
Sun, Jul 12, 8:07 PM
Unknown Object (File)
Fri, Jul 10, 12:38 PM
Unknown Object (File)
May 20 2026, 4:22 PM
Subscribers

Details

Summary

Since commit 19df0c5abcb9d4e9 ("LinuxKPI: make __kmalloc() play by the
rules"), kmalloc() systematically allocates contiguous physical memory,
as it should. However, kvzalloc() was left defined in terms of
kmalloc(), which makes it allocate contiguous physical memory too. This
is a too stringent restriction, as kvzalloc() is supposed to be a simple
page-zeroing wrapper around kvmalloc().

According to Linux's documentation ("memory-allocation.rst"), kvmalloc()
first tries to allocate contiguous memory, falling back to
non-contiguous one if that fails. Thus, callers are already supposed to
deal with the possibility of non-contiguous memory being returned.

Diff Detail

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