From nobody Sun Oct 5 14:33:11 2025 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42B89258CE2; Mon, 4 Aug 2025 12:14:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754309683; cv=none; b=XL0Wl/lzamgrV0Dqo97J2I4DE1WLrcZSckZxtV5usg0wEJGiOlTtLdLWSsxjM0T8XtwdjwZa8kYS3OFTxUIw68mVkFvyzjvXKb4BTgiQtJkD8BHCpqImyv6NPtoeJcyAyHJBb/q8ajvUIwIZ+JSnH/54TJGWoyGNc6WiCrUaW3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754309683; c=relaxed/simple; bh=3yvTRW5FhiAKs+vOBuG4HDRUaaXxURgqxp/7gqTmM9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o6eI3zqaxicIa8rTAUjN0IOjgqRCHNpJCiULMhNJVShcgqVTtSO3UXxkUiGaCurdxJftRHhuQYAQuvDYZ3zWiM0yI3CtLv6POO0XM3Vz7FkwM26XIzpuJVlw70rCmWMuzdOmU/Qyje5Yx57pM2y92CAxAku3mf04aIAsqRntdzw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=JogdjNc8; arc=none smtp.client-ip=80.241.56.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="JogdjNc8" Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4bwb8Z5DNqz9sy6; Mon, 4 Aug 2025 14:14:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1754309678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kgGhybuB+tAZvqsghR5tZCuaExpLC7iQdGM6Ue4YApc=; b=JogdjNc8TbOYGaRal6ul2EdZ36M2+wgOdqzDmdw3o4etELnbmBQeg79oT/sOzxB33y0cQN qRMI/4ZoRg0HAWSBDELzHTQzWLCs4YFWROruNL1nq9mQc5FC1/70hgrFl/zGwM3N7u+6V4 KHw5BFNEg0Lu+8WStXiP05uU6wg/0Jis8IHzu52cYC6YBI1Niros/a1LLyH5Xxz4STWBwy J+WhOF6PhL3+9tOHYwpg3yftiilUDt9aL01rwjXaVo49+tWVlwqK+UReV2OsJTo96uRAd/ lriRpdwu9IdqxW56eCKiIwtkfKb21aEBKqavjMlzLVrVV5vJWJhbQExhq+qnGg== From: "Pankaj Raghav (Samsung)" To: Suren Baghdasaryan , Ryan Roberts , Baolin Wang , Borislav Petkov , Ingo Molnar , "H . Peter Anvin" , Vlastimil Babka , Zi Yan , Mike Rapoport , Dave Hansen , Michal Hocko , David Hildenbrand , Lorenzo Stoakes , Andrew Morton , Thomas Gleixner , Nico Pache , Dev Jain , "Liam R . Howlett" , Jens Axboe Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, x86@kernel.org, linux-block@vger.kernel.org, Ritesh Harjani , linux-fsdevel@vger.kernel.org, "Darrick J . Wong" , mcgrof@kernel.org, gost.dev@samsung.com, kernel@pankajraghav.com, hch@lst.de, Pankaj Raghav Subject: [PATCH 4/5] mm: add largest_zero_folio() routine Date: Mon, 4 Aug 2025 14:13:55 +0200 Message-ID: <20250804121356.572917-5-kernel@pankajraghav.com> In-Reply-To: <20250804121356.572917-1-kernel@pankajraghav.com> References: <20250804121356.572917-1-kernel@pankajraghav.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Pankaj Raghav Add largest_zero_folio() routine so that huge_zero_folio can be used directly when CONFIG_STATIC_HUGE_ZERO_FOLIO is enabled. This will return ZERO_PAGE folio if CONFIG_STATIC_HUGE_ZERO_FOLIO is disabled or if we failed to allocate a huge_zero_folio. Co-developed-by: David Hildenbrand Signed-off-by: David Hildenbrand Signed-off-by: Pankaj Raghav --- include/linux/huge_mm.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 78ebceb61d0e..c44a6736704b 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -716,4 +716,21 @@ static inline int split_folio_to_order(struct folio *f= olio, int new_order) return split_folio_to_list_to_order(folio, NULL, new_order); } =20 +/* + * largest_zero_folio - Get the largest zero size folio available + * + * This function will return huge_zero_folio if CONFIG_STATIC_HUGE_ZERO_FO= LIO + * is enabled. Otherwise, a ZERO_PAGE folio is returned. + * + * Deduce the size of the folio with folio_size instead of assuming the + * folio size. + */ +static inline struct folio *largest_zero_folio(void) +{ + struct folio *folio =3D get_static_huge_zero_folio(); + + if (folio) + return folio; + return page_folio(ZERO_PAGE(0)); +} #endif /* _LINUX_HUGE_MM_H */ --=20 2.49.0