From patchwork Tue Jul 30 18:49:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13747783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4188AC49EA1 for ; Tue, 30 Jul 2024 18:51:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 782256B0092; Tue, 30 Jul 2024 14:51:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 731CA6B0095; Tue, 30 Jul 2024 14:51:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D3406B0096; Tue, 30 Jul 2024 14:51:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3B34B6B0092 for ; Tue, 30 Jul 2024 14:51:07 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EA513160441 for ; Tue, 30 Jul 2024 18:51:06 +0000 (UTC) X-FDA: 82397311332.20.5B103B4 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 463CB160016 for ; Tue, 30 Jul 2024 18:51:05 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MB49LOJn; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722365420; a=rsa-sha256; cv=none; b=6NWORibKiZ7mGbhezZmJi7sQgEB9Sfy45jnSBsaIDurqnEK8pKLLsaGqUyZFI1efgg8wK0 UKPY9XcYF6UgaXYvuAyyn6h4gJhl/Eb6oG2nL66j/tZEb98GwJd4P/uM0Myi2tNsqIehqv EX3+D+RsnbZ5mz9cgy8LuZUakC7Rp8s= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MB49LOJn; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722365420; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XMRLNLiTM0AVkiAwykusY/ZI/wVK4OHI5IKc8SVQ0jM=; b=F5WylQHHX3Lz8AlpKOaQBm1A3p434+smd+zpODKOPZNOMj4zs1yL0taKWcCniIc7RgByt1 1jhK9BytOUAILKiFOxkNtnnQnkdWilrD8VWv7Aji2ckBDKcG26Y+OC0QnjVWi5aenws3Zg ig+HlefxcmtMesLwSzAlp9t8kiBG4ms= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 64A6162020; Tue, 30 Jul 2024 18:51:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A8A7C4AF15; Tue, 30 Jul 2024 18:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722365464; bh=BHHTORiqnQEnevgg1pb2AO84I1O2tlm7LAzk7DzpiX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MB49LOJnSd0dC4i1DwOZpB6+J6dWDCYVb4aSAN6rq0/ja5W5I7SYG+wE1+aCIUFzd qLTmTZJeY7DM4oAUSLBwxmJlYBSkMKJ4Lgy38nAr8xtUz3tDqG7PFRd9EkHPTSsXgp uiNANAfLVkyCrv++Py4nHn2Qc70r9BsXtBvAYYGIYrcGRd9Gbx5rbHEMA/NjfAJIHg oiAan8YjdJEtq65lpESfuPIXm/LAHoAVVCpWsYBypKKRkqiKCSs3nOxmd7zcttkvdy WjHTBWA9p73oJdDGNxRP4CgozeSPolMLJrOFaVt0O5mDaoLu5lsAtRrn0K9LPNHYm8 FkwzOtJa9/qqg== From: Danilo Krummrich 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 Subject: [PATCH 4/4] mm: kvrealloc: properly document __GFP_ZERO behavior Date: Tue, 30 Jul 2024 20:49:44 +0200 Message-ID: <20240730185049.6244-5-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730185049.6244-1-dakr@kernel.org> References: <20240730185049.6244-1-dakr@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 463CB160016 X-Stat-Signature: sfamac4br4y7x1hyc7kus47y4doiksqp X-Rspam-User: X-HE-Tag: 1722365465-726655 X-HE-Meta: U2FsdGVkX1+KpWaSSCXj+K2ElkCnbv0hufHshkusJGf9e5r7WKIv6c7tNguVNK5LYLLrZE6ZjBtRte4cVdRZm4ZenUHuDvMZyr2WUhs5qpCPhi5DfrPFz6dkj0/BufOZLlGBh+sLisKKpZLrIXaDX7mVEK+HTdJlL3SWSD97QmUtD+7/kUXPecCtjVq1DLUqld5a3V0BnCT2v20XWsXj24Uz0YbUu87rRMiswaSNdEux9sPlA93oBBDIz2hVmHM2p4GDOFE5/LBRCriCkliGTedNA0AYhLNx6SYV/WKvzX3kaBx/uSQKlmh5g306OrIUHamcXVp1lZidlPwR1ELyz2vkOfaIY1N+TnAnZChZLhHT4pVjW1wxnJTStNZPUWMyHEsE3Lo5qk9RydrErZ79TDJaE28fZdefZTnrE8Fu36cjQYO+5eWATrvEx4jVOAyJX9wti+PRaNwzzaijfv6xosixauGa4pB2ag0kfgN3f+lnNH+TJriiD0xFrwO+TKheFMNy5GQQA6PaWAsTu+NUbkouwtyhTJRYqvfr44s/+nqjZc312wot93s/GUZMgOv7k7ud5310wUkA0pSMO4UXaLS/tM773qOMbXkVSBRLIvvrWgtwJgZ/mWt924aAKviMFSfmsQGMga8gA6dv+tfoJ6vCWlDebbEX2o01ztzCGRWqO8b4dysgQRESF8rrSEoL+YkLcX66HKnVCFAxzF+bOVHNkL17dapXjMihcmdAh9dbddJ5aSNBcjZwlXsIMRP78bnyAHavJ90aaVN7a9058dKGnRL2hL0TlbclwKFHIU3XfIaRBwfcVm5aJMPpWplxq/EgM5NXcNAAC1mHX2lYJ1n24bB3ncXwYxOkSjYIzBYZ7pRxGIS/HlAoofoSVZV34Dk01SmhBE1hgjJKiEl2pFX9Jfp9sgPTUUW4Ljjibm+dwyuD8AwOt3VkifJpms+atStTHriCEOFbk7bk05a PMr8GGmG HE/zppUIf0/atW5+9vrRlvFh0mQSyrROEo8YX6J/nw0wzRozcn2Wq4TSHP7d+hHu7kN+5M9VSgqGiyIvU+4JAzTsSR9gEqHW8KyV4k+E0gmsucXx2CUmeNZ61ug1s0w0AuKMlThrbzd9l3p1CW/Zja64R7FsEJt9EPCZTvPWShnjjJT+ihAdoosvyH8M6chTqscWdKU9sRuwzVn4tN7xmR8obRbQ6Km3MPfbyIcL7Zj/gS1QQGYXnBEchuOD9yJecWG/gGY69+8qfZeK97yg36dz6hZHy2HqK4mSB X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 --- mm/util.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/util.c b/mm/util.c index bfb2d69b6434..f899b0f984a0 100644 --- a/mm/util.c +++ b/mm/util.c @@ -726,12 +726,17 @@ EXPORT_SYMBOL(kvfree_sensitive); * @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, kvrealloc() behaves exactly like kvmalloc(). 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 kvfree() for the * same memory allocation. *