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
F154435298: D51247.id.diff
Tue, Apr 28, 1:13 PM
Unknown Object (File)
Sat, Apr 25, 2:44 PM
Unknown Object (File)
Sat, Apr 25, 9:38 AM
Unknown Object (File)
Fri, Apr 24, 12:16 PM
Unknown Object (File)
Fri, Apr 17, 3:04 AM
Unknown Object (File)
Thu, Apr 16, 10:07 PM
Unknown Object (File)
Wed, Apr 15, 1:33 AM
Unknown Object (File)
Tue, Apr 14, 8:42 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