The branch stable/14 has been updated by olce:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8e1b8ae7298fc8ec91f6d7dc040341343c894e57

commit 8e1b8ae7298fc8ec91f6d7dc040341343c894e57
Author:     Olivier Certner <o...@freebsd.org>
AuthorDate: 2025-07-07 13:28:21 +0000
Commit:     Olivier Certner <o...@freebsd.org>
CommitDate: 2025-07-28 13:28:50 +0000

    LinuxKPI: Have kvzalloc() rely on kvmalloc(), not kmalloc()
    
    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.
    
    Reviewed by:    bz
    Fixes:          19df0c5abcb9 ("LinuxKPI: make __kmalloc() play by the 
rules")
    MFC after:      10 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D51247
    
    (cherry picked from commit 986edb19a49c7d7d3050c759d9b0826283492ebf)
    
    Forgotten on commit to main/-CURRENT:
    PR:             277476
---
 sys/compat/linuxkpi/common/include/linux/slab.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h 
b/sys/compat/linuxkpi/common/include/linux/slab.h
index f3a840d9bf4b..efa5c8cb67b3 100644
--- a/sys/compat/linuxkpi/common/include/linux/slab.h
+++ b/sys/compat/linuxkpi/common/include/linux/slab.h
@@ -45,7 +45,7 @@
 
 MALLOC_DECLARE(M_KMALLOC);
 
-#define        kvzalloc(size, flags)           kmalloc(size, (flags) | 
__GFP_ZERO)
+#define        kvzalloc(size, flags)           kvmalloc(size, (flags) | 
__GFP_ZERO)
 #define        kvcalloc(n, size, flags)        kvmalloc_array(n, size, (flags) 
| __GFP_ZERO)
 #define        kzalloc(size, flags)            kmalloc(size, (flags) | 
__GFP_ZERO)
 #define        kzalloc_node(size, flags, node) kmalloc_node(size, (flags) | 
__GFP_ZERO, node)

Reply via email to