All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org,
	vbabka@suse.cz
Cc: mhocko@suse.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH 3/4] mm: vrealloc: properly document __GFP_ZERO behavior
Date: Tue, 30 Jul 2024 20:49:43 +0200	[thread overview]
Message-ID: <20240730185049.6244-4-dakr@kernel.org> (raw)
In-Reply-To: <20240730185049.6244-1-dakr@kernel.org>

Properly document that if __GFP_ZERO logic is requested, callers must
ensure that, starting with the initial memory allocation, every
subsequent call to this API for the same memory allocation is flagged
with __GFP_ZERO. Otherwise, it is possible that __GFP_ZERO is not fully
honored by this API.

Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
 mm/vmalloc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 6a2fef6378e4..48cc10dd06c0 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -4043,12 +4043,17 @@ EXPORT_SYMBOL(vzalloc_node_noprof);
  * @size: the size to reallocate
  * @flags: the flags for the page level allocator
  *
- * The contents of the object pointed to are preserved up to the lesser of the
- * new and old size (__GFP_ZERO flag is effectively ignored).
- *
  * 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.
  *
+ * If __GFP_ZERO logic is requested, callers must ensure that, starting with the
+ * initial memory allocation, every subsequent call to this API for the same
+ * memory allocation is flagged with __GFP_ZERO. Otherwise, it is possible that
+ * __GFP_ZERO is not fully honored by this API.
+ *
+ * In any case, the contents of the object pointed to are preserved up to the
+ * lesser of the new and old sizes.
+ *
  * This function must not be called concurrently with itself or vfree() for the
  * same memory allocation.
  *
-- 
2.45.2



  parent reply	other threads:[~2024-07-30 18:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30 18:49 [PATCH 0/4] (k)vrealloc (__GFP_ZERO) fixes Danilo Krummrich
2024-07-30 18:49 ` [PATCH 1/4] mm: kvrealloc: disable KASAN when switching to vmalloc Danilo Krummrich
2024-07-30 21:15   ` Andrew Morton
2024-07-30 22:47     ` Danilo Krummrich
2024-07-30 18:49 ` [PATCH 2/4] mm: vrealloc: consider spare memory for __GFP_ZERO Danilo Krummrich
2024-07-30 21:15   ` Andrew Morton
2024-07-30 18:49 ` Danilo Krummrich [this message]
2024-07-30 21:19   ` [PATCH 3/4] mm: vrealloc: properly document __GFP_ZERO behavior Andrew Morton
2024-07-30 22:43     ` Danilo Krummrich
2024-07-31 14:43       ` Vlastimil Babka
2024-07-31 15:10         ` Danilo Krummrich
2024-07-30 18:49 ` [PATCH 4/4] mm: kvrealloc: " Danilo Krummrich

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=20240730185049.6244-4-dakr@kernel.org \
    --to=dakr@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=urezki@gmail.com \
    --cc=vbabka@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.