Date: Fri, 26 Jul 2024 11:51:41 GMT From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 1f7df7570174 - main - LinuxKPI: move __kmalloc from slab.h to slab.c Message-ID: <202407261151.46QBpfBo000933@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=1f7df757017404011732196e65981d9325f7a89f commit 1f7df757017404011732196e65981d9325f7a89f Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2024-06-30 20:37:07 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2024-07-26 11:51:04 +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 MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D45815 --- 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407261151.46QBpfBo000933>