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
This commit is contained in:
Vladimir Kondratyev 2024-07-21 16:08:37 +03:00
parent ab6e116790
commit ab1a5d8e2a

View file

@ -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);