From: Andrew Morton <akpm@linux-foundation.org>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: linux-mm@kvack.org, paulmck@kernel.org
Subject: Re: [PATCH 1/2] mm: vmalloc_bytes()
Date: Tue, 27 Feb 2024 11:55:40 -0800 [thread overview]
Message-ID: <20240227115540.2dbf9bde0f3ccb7163030ab0@linux-foundation.org> (raw)
In-Reply-To: <20240227072515.3736069-1-kent.overstreet@linux.dev>
On Tue, 27 Feb 2024 02:25:14 -0500 Kent Overstreet <kent.overstreet@linux.dev> wrote:
> Add a __ksize() equivalent for vmalloc.
> +++ b/mm/vmalloc.c
> @@ -2848,6 +2848,26 @@ void vfree(const void *addr)
> }
> EXPORT_SYMBOL(vfree);
>
> +/**
> + * vmalloc_bytes - Return size of a vmalloc() allocation
> + * @addr: Memory base address
> + *
> + * Returns the size of the allocation as passed to vmalloc() rounded up to
> + * PAGE_SIZE; does not include extra internal allocations.
> + */
> +size_t vmalloc_bytes(const void *addr)
> +{
> + struct vm_struct *vm = find_vm_area(addr);
> + if (unlikely(!vm)) {
> + WARN(1, KERN_ERR "vmalloc_bytes() called on nonexistent vm area (%p)\n",
> + addr);
> + return 0;
if (WARN(!vm, "..."))
and I don't think the explicit KERN_ERR facility is needed?
prev parent reply other threads:[~2024-02-27 19:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 7:25 Kent Overstreet
2024-02-27 7:25 ` [PATCH 2/2] mm: __kvsize() Kent Overstreet
2024-02-27 19:55 ` Andrew Morton [this message]
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=20240227115540.2dbf9bde0f3ccb7163030ab0@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=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