[PATCH 2/2] mm: __kvsize()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a __ksize() equivalent for kvmalloc.

Cc: linux-mm@xxxxxxxxx
Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
---
 include/linux/slab.h |  1 +
 mm/slab_common.c     | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index b5f5ee8308d0..9ef26837c72d 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -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))
 
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 238293b1dbe1..6ec0f6543f34 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -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;
-- 
2.43.0





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux