Skip to content

Commit

Permalink
LinuxKPI: Add kmalloc_size_roundup function
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wulf7 committed Jul 21, 2024
1 parent ab6e116 commit ab1a5d8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sys/compat/linuxkpi/common/include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ab1a5d8

Please sign in to comment.