With mallocarray() we cannot guarantee that any size larger than
PAGE_SIZE will be contiguous. Switch to use the internal __kmalloc()
implementation which now does provide that guarantee.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential D46657
LinuxKPI: switch mallocarray to an lpi implementation using __kmalloc() bz on Sep 12 2024, 6:27 PM. Authored by Tags None Referenced Files
Details
Diff Detail
Event TimelineComment Actions Also change the (internal) mallocarray() calls in linux_compat.c to lkpi_mallocarray() Comment Actions I'm not a fan of this, mallocarray is a OpenBSD thing, not a Linux thing, I don't see why we should have an lkpi implementation. Comment Actions It's a helper function; because we do use mallocarray internally and it doesn't go by Linux guarantees on memory being physically contiguous in some cases. I can replace all the mallocarray calls directly with __kmalloc() but that just makes it harder to maintain in many places rather one. We can name this whatever we want it to be if you do not like the name... Comment Actions This seems certainly fine. This is the semantics required for kcalloc and kmalloc_array
Comment Actions Drop lkpi_mallocarray as requested by @manu. Add a lkpi___kmalloc_node() in parallel to lkpi___kmalloc() which does the if and the actual Follow the path suggested by @jhb which works out nicely: Switch to kmalloc_array() inseatd of our lkpi_ version to avoid further exposure of it. Add comments about realloc as it seems kern_malloc.c does not handle that yet and we need Comment Actions I really shouldn't code with a fever. Need to reshuffle the functions so they will compile. Also ) |