public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Danilo Krummrich <dakr@kernel.org>,
	akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm: (k)vrealloc: document concurrency restrictions
Date: Fri, 26 Jul 2024 11:31:48 +0200	[thread overview]
Message-ID: <a6a65d06-2472-4f8d-a5de-8dcd66cea203@kernel.org> (raw)
In-Reply-To: <20240725125442.4957-1-dakr@kernel.org>

On 7/25/24 2:54 PM, Danilo Krummrich wrote:
> Document that concurrent calls to vrealloc() with itself or vfree() for
> the same memory allocation are not permitted, since it leads to undefined
> behavior.
> 
> Consequently, the same applies for kvrealloc(), hence also document it
> for kvrealloc().
> 
> Suggested-by: Christoph Hellwig <hch@infradead.org>
> Suggested-by: Uladzislau Rezki <urezki@gmail.com>
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>

Huh, did anyone ever assume otherwise and why?

> ---
>  mm/util.c    | 3 +++
>  mm/vmalloc.c | 3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/mm/util.c b/mm/util.c
> index 0ff5898cc6de..29ae93f6344f 100644
> --- a/mm/util.c
> +++ b/mm/util.c
> @@ -732,6 +732,9 @@ EXPORT_SYMBOL(kvfree_sensitive);
>   * If @p is %NULL, kvrealloc() behaves exactly like kvmalloc(). If @size is 0
>   * and @p is not a %NULL pointer, the object pointed to is freed.
>   *
> + * This function must not be called concurrently with itself or kvfree() for the
> + * same memory allocation.
> + *
>   * Return: pointer to the allocated memory or %NULL in case of error
>   */
>  void *kvrealloc_noprof(const void *p, size_t size, gfp_t flags)
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index caf032f0bd69..2a6d4ce57b73 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -4049,6 +4049,9 @@ EXPORT_SYMBOL(vzalloc_node_noprof);
>   * If @p is %NULL, vrealloc() behaves exactly like vmalloc(). If @size is 0 and
>   * @p is not a %NULL pointer, the object pointed to is freed.
>   *
> + * This function must not be called concurrently with itself or vfree() for the
> + * same memory allocation.
> + *
>   * Return: pointer to the allocated memory; %NULL if @size is zero or in case of
>   *         failure
>   */
> 
> base-commit: d270beaca6818349b2aed7e6034b800a777087cc


      reply	other threads:[~2024-07-26  9:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-25 12:54 [PATCH] mm: (k)vrealloc: document concurrency restrictions Danilo Krummrich
2024-07-26  9:31 ` Vlastimil Babka (SUSE) [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=a6a65d06-2472-4f8d-a5de-8dcd66cea203@kernel.org \
    --to=vbabka@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dakr@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=urezki@gmail.com \
    /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