git: ab1a5d8e2ade - main - LinuxKPI: Add kmalloc_size_roundup function
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 21 Jul 2024 13:14:47 UTC
The branch main has been updated by wulf:
URL: https://cgit.FreeBSD.org/src/commit/?id=ab1a5d8e2ade8c706ff8cd7aa3d5c88a95633228
commit ab1a5d8e2ade8c706ff8cd7aa3d5c88a95633228
Author: Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2024-07-21 13:08:37 +0000
Commit: Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2024-07-21 13:08:37 +0000
LinuxKPI: Add kmalloc_size_roundup function
kmalloc_size_roundup reports allocation bucket size for the given size.
Sponsored by: Serenity CyberSecurity, LLC
MFC after: 1 week
Reviewed by: manu, emaste
Differential Revision: https://reviews.freebsd.org/D45841
---
sys/compat/linuxkpi/common/include/linux/slab.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h
index e2d17e0558c2..3f2d1621e148 100644
--- a/sys/compat/linuxkpi/common/include/linux/slab.h
+++ b/sys/compat/linuxkpi/common/include/linux/slab.h
@@ -237,6 +237,14 @@ ksize(const void *ptr)
return (malloc_usable_size(ptr));
}
+static inline size_t
+kmalloc_size_roundup(size_t size)
+{
+ if (unlikely(size == 0 || size == SIZE_MAX))
+ return (size);
+ return (malloc_size(size));
+}
+
extern struct linux_kmem_cache *linux_kmem_cache_create(const char *name,
size_t size, size_t align, unsigned flags, linux_kmem_ctor_t *ctor);
extern void *lkpi_kmem_cache_alloc(struct linux_kmem_cache *, gfp_t);