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
Unknown Object (File)
Sat, Oct 11, 10:46 PM
Unknown Object (File)
Sat, Oct 11, 10:45 PM
Unknown Object (File)
Sat, Oct 11, 1:26 PM
Unknown Object (File)
Sat, Oct 11, 1:26 PM
Unknown Object (File)
Sat, Oct 11, 1:26 PM
Unknown Object (File)
Sat, Oct 11, 5:12 AM
Unknown Object (File)
Sun, Oct 5, 7:52 AM
Unknown Object (File)
Wed, Sep 24, 8:37 AM
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