git: f9edc5b3f687 - stable/14 - LinuxKPI: move __kmalloc from slab.h to slab.c
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 28 Sep 2024 10:38:11 UTC
The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=f9edc5b3f687ad0cd01ee4cac664a95d21413f3c commit f9edc5b3f687ad0cd01ee4cac664a95d21413f3c Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2024-06-30 20:37:07 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2024-09-28 10:35:12 +0000 LinuxKPI: move __kmalloc from slab.h to slab.c In order to allow the allocator to change in the future move it into the implementation file from being an inline function in the header. While here factor out the size calculation and add a comment as-to why this is done. We will need the size (_s) in the future to make a decision on how to allocate. Sponsored by: The FreeBSD Foundation Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D45815 (cherry picked from commit 1f7df757017404011732196e65981d9325f7a89f) --- sys/compat/linuxkpi/common/include/linux/slab.h | 9 ++------- sys/compat/linuxkpi/common/src/linux_slab.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index 3f2d1621e148..07c16884b00e 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -92,6 +92,8 @@ struct linux_kmem_cache; #define ZERO_OR_NULL_PTR(x) ((x) == NULL || (x) == ZERO_SIZE_PTR) extern void *lkpi_kmalloc(size_t size, gfp_t flags); +void *lkpi___kmalloc(size_t size, gfp_t flags); +#define __kmalloc(_s, _f) lkpi___kmalloc(_s, _f) static inline gfp_t linux_check_m_flags(gfp_t flags) @@ -108,13 +110,6 @@ linux_check_m_flags(gfp_t flags) return (flags & GFP_NATIVE_MASK); } -static inline void * -__kmalloc(size_t size, gfp_t flags) -{ - return (malloc(MAX(size, sizeof(struct llist_node)), M_KMALLOC, - linux_check_m_flags(flags))); -} - static inline void * kmalloc_node(size_t size, gfp_t flags, int node) { diff --git a/sys/compat/linuxkpi/common/src/linux_slab.c b/sys/compat/linuxkpi/common/src/linux_slab.c index 68117d1c9fa7..72b35fee9214 100644 --- a/sys/compat/linuxkpi/common/src/linux_slab.c +++ b/sys/compat/linuxkpi/common/src/linux_slab.c @@ -207,6 +207,17 @@ linux_kmem_cache_destroy(struct linux_kmem_cache *c) free(c, M_KMALLOC); } +void * +lkpi___kmalloc(size_t size, gfp_t flags) +{ + size_t _s; + + /* sizeof(struct llist_node) is used for kfree_async(). */ + _s = MAX(size, sizeof(struct llist_node)); + + return (malloc(_s, M_KMALLOC, linux_check_m_flags(flags))); +} + struct lkpi_kmalloc_ctx { size_t size; gfp_t flags;