@@ -227,6 +227,7 @@ void * __must_check krealloc(const void *objp, size_t new_size, gfp_t flags) __r
void kfree(const void *objp);
void kfree_sensitive(const void *objp);
size_t __ksize(const void *objp);
+size_t __kvsize(const void *objp);
DEFINE_FREE(kfree, void *, if (_T) kfree(_T))
@@ -972,6 +972,19 @@ size_t __ksize(const void *object)
return slab_ksize(folio_slab(folio)->slab_cache);
}
+/**
+ * __kvsize -- Report full size of underlying allocation
+ * @object: pointer to the object
+ *
+ * __ksize equivalent, but for kvmalloc
+ */
+size_t __kvsize(const void *addr)
+{
+ return is_vmalloc_addr(addr)
+ ? vmalloc_bytes(addr)
+ : __ksize(addr);
+}
+
gfp_t kmalloc_fix_flags(gfp_t flags)
{
gfp_t invalid_mask = flags & GFP_SLAB_BUG_MASK;
Add a __ksize() equivalent for kvmalloc. Cc: linux-mm@kvack.org Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> --- include/linux/slab.h | 1 + mm/slab_common.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)