linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-mm@kvack.org
Cc: paulmck@kernel.org, Kent Overstreet <kent.overstreet@linux.dev>
Subject: [PATCH 2/2] mm: __kvsize()
Date: Tue, 27 Feb 2024 02:25:15 -0500	[thread overview]
Message-ID: <20240227072515.3736069-2-kent.overstreet@linux.dev> (raw)
In-Reply-To: <20240227072515.3736069-1-kent.overstreet@linux.dev>

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(+)

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



  reply	other threads:[~2024-02-27  7:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27  7:25 [PATCH 1/2] mm: vmalloc_bytes() Kent Overstreet
2024-02-27  7:25 ` Kent Overstreet [this message]
2024-02-27 19:55 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240227072515.3736069-2-kent.overstreet@linux.dev \
    --to=kent.overstreet@linux.dev \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox