HomeFreeBSD

LinuxKPI: switch mallocarray to an lkpi implementation using __kmalloc()

Description

LinuxKPI: switch mallocarray to an lkpi implementation using __kmalloc()

With mallocarray() we cannot guarantee that any size larger than
PAGE_SIZE will be contiguous. Switch kmalloc_array() and
kmalloc_array_node() to use kmalloc()/lkpi_kmalloc_node() as their
underlying implementation which now does provide that guarantee.
Likewise adjust kcalloc_node() to use kmalloc_array_node().
This means we only have two (plain + _node) underlying allocation
routines for the entire category of functions.

Also adjust kvmalloc() and kvmalloc_array() to be a "mirrored"
implementation to their non-v counterparts. These may return
non-contiguous memory so can use malloc().

Sponsored by: The FreeBSD Foundation
Reviewed by: jhb
Extra thanks to: jhb for helping sorting this out
Differential Revision: https://reviews.freebsd.org/D46657

(cherry picked from commit 1c81ebec74d8a71c770f7835d3bc6e02c13467a0)

Details

Provenance
bzAuthored on Mar 20 2025, 11:54 PM
Reviewer
jhb
Differential Revision
D46657: LinuxKPI: switch mallocarray to an lpi implementation using __kmalloc()
Parents
rGd684da076bbd: LinuxKPi: lkpi___kmalloc change a < into <= for proper boundry check
Branches
Unknown
Tags
Unknown