From patchwork Tue Jul 30 18:49:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13747782 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 7F7E6C3DA49 for ; Tue, 30 Jul 2024 18:51:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DF3E6B008C; Tue, 30 Jul 2024 14:51:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02D416B0092; Tue, 30 Jul 2024 14:51:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E12CE6B0093; Tue, 30 Jul 2024 14:51:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BBEA06B008C for ; Tue, 30 Jul 2024 14:51:04 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 728F01204A5 for ; Tue, 30 Jul 2024 18:51:04 +0000 (UTC) X-FDA: 82397311248.21.4157995 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id D4923140010 for ; Tue, 30 Jul 2024 18:51:02 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZyPXR6Sa; spf=pass (imf23.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722365390; 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=CY+supgkZE9e2vuOlgj/vU2It/36aM8i5ue5rYaMbyw=; b=pmygJTa88tIsmULqJJgGg/Nl6rovAxK0sv+xMFxh7j9R43OHmr03gZ3PTytK/vzPapQd6O j7OrkvZDSCnFBIbKuHAtDEvGPyKXMOQz7HGTsEpkq8XzSSnrXN1b0v41K8sLGT6gQc3HXX 5KRAMNm38IVFOwkxByDo4XKpry+LwJc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZyPXR6Sa; spf=pass (imf23.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722365390; a=rsa-sha256; cv=none; b=zvP3+WxVbKPyoEh/ZilZ/sFx9b/NmiBSrITCNjSJEelqggqilQYytMZdnEfM7qZRx+R63i QvKLakGG+n6EZ6zgbAdCBp9xOVB+icV8Am261TEu7yBs1PWoRjKipFZrO3b6pjnZfjlqC2 5XW6VlIfp0W1hKvdiXrrT1LGn7IXRBs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0A41D62004; Tue, 30 Jul 2024 18:51:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F798C4AF0F; Tue, 30 Jul 2024 18:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722365461; bh=GszPI8ByV+1qtGMCf/91ybTKQ8raCzOdvtpEYU0MI+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZyPXR6SaSqI0F9wenpqipaQ6eymbMTrxBfG7CUNsILMrxtXzoF59HoD/rB34noBng GqC1WjTj4nSG3OFM2vk7pJsF7ZWFZjuhgUtVG4okRj51/vSKSZEz2wuuysJqSeEnBo YTBnoYBeKDlmwBJFr1Afgwpj6W0t2MRMJ2SjM01JAhhm+SnVZFnAYFDXesiku/aQGT lsF3giHR0Qb9pC7sgEx0Zxz5+L850wX3Dq0RJNeAXXHUV1pW2JYbtmsyDRZjpfx4ON R36cynKzYELGkdyX4UfarNSz/i2FJtQC2TR1GoApn7mCnn6sv7/QY5BRHxFCIgu/Gb cNV3RlUzrimGg== 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 3/4] mm: vrealloc: properly document __GFP_ZERO behavior Date: Tue, 30 Jul 2024 20:49:43 +0200 Message-ID: <20240730185049.6244-4-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: rspam06 X-Rspamd-Queue-Id: D4923140010 X-Stat-Signature: 8se694n4qwegk69cxw1rhe7burwgdenb X-Rspam-User: X-HE-Tag: 1722365462-560529 X-HE-Meta: U2FsdGVkX19LFpzus/IdTE1MhP04UXKhISYgghL0GrP39ZpChchj8fTvMEMhNzDOjdMEa+Bz2jXM0ypyUxElthKk9M3A/wosIK21W8VMiL4J4a1Pq+iDEx/GChgGBPcT2xYK13q5bDqIFv3PhLVFE38XqnHWdhfske8czByFWg9H6d27VAHnyyXtLwO2oxEktsL9HcezVRqth94i+ZOQeh1bvHDqpNT2sQ0SQhf3W4gqvNLy9tfP92qIf4FprMHQo9rmQwSmC3gAa4YrUWKeBmCEvw18/CcgNtW1OPZ+UMZFTO7RQLh8RI70bwnXjd1kz/zL1UufjkrG+S+anrkHUrtHy50F9f5qpY9UV9pXSM24JPmsK+7XxY4Q+2foXapc5+F3sDBhtM+baAmTScCoU+HWuz5jyK0Nk3Q8oGM/H51avwrviK8UKhKTncDBf96EuHJRVCIRxB6q2TygKm77n7Fsmz6wZQPvTMlhzd1prx9dO1R8bQ7ekdL7cwXUmzBda169oINF94uRBMZPzBb69pxhdzpJmD6Up0UvNSOTfxdz39WuJd5ZbvY11k9AsULI8dCEUWt9+6boPBUDf6EkmqZ+awLvac3EOhmLrPqt4tUSiIE2hAgpo8IPcYoDGGrgjrBOURI1/k2xH43qdxQUulSuIUbuXa4ku8Li8hkminaPH3MjYcqN58Ko0+rHyi5cjOvUxSmCWfuy4nWxM8xg8XqZPuymlxRIKY3rvjAMoenBOuZaRnIVe6l9Qm2b2auxEwnE0snwl9A02n0jYVT0/9VB7VifnGIDlsoCcLZUK2oCUVhSM/TcUwnRlepjHsGbYU95t5BmV87CWt6muuLfXxlyLGi07bR2DL0WS7tHzf8XiI38Mjb+aKJfkZp1bl+8C6BeJ3hhVxxNyKQ+ltJCFVvso6oV6Y8nIKxAhNJaYnR8o2eyTOnqIc5DPygtljWP0ZLCQcTw0FcBAXe5+9N XFdqS6Wg xRbcPXHsQnVLfcuWL4AGbro50PnRNHkqg6YrvCOPBkmEQ0u28y9fE/reXTfMXUiw3hRkSBsdZV0V9W6bg/Yjeup9tPvPAe6cODTtvoRHG9MGgMhCAqbxDLG0+yjQpAy8eAjF3PV349JyszK9/UtGs8fXxbbhqwBbowwlMHqaZCmvH3Jz7nInabPfCbmRzUcPpSAg18paJ9BjiXOGk8ChMTDSAir23tcFLn2H2ev1SF6eo5O+nisx6ghuAcfUyAnR0QBfme7Bm2tX0p7/cDxekD8pCxhzu/rRaL50r 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/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. *