From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67C4ACA0EFC for ; Sun, 24 Aug 2025 13:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sTgVSQ/agc49mf+WMVj/m/VVuvPKZX5i68p4dayRd8w=; b=nR8XHwUT36OM7GB0FUasAioPy4 NeGbR9MDK1wq1rTTu3YvngOYxtp1m5bM7hffpdVXq+/pJ7DnlVVxZ0PRu+SvEQtcZjcwW5pfbyR0u iNWEY7DduGTS7Pyaadg4fX1qKzgtEZf4mkAoUVps0FnekeIhwpnkljjs03Z5T1TGq/KP8W0cutNlt Fl0vXTpyQoNax9V7R/nPldzSzDypsLnWDBV9S1qw2gjSFQRHc3aKqxOutLkg85xZiKqUHFGQefm0b 0yafbWAt331he8SwGt+DlaAgQPPV5foSsGvp+vuEYQ4k6FxMIMo1GF06jlfEEGjYUoVfgwTbJHx++ Xxi6WBUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uqAkw-00000006BPV-1V1v; Sun, 24 Aug 2025 13:27:34 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uqAiK-00000006BEM-0pSu; Sun, 24 Aug 2025 13:24:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 7D3EC43442; Sun, 24 Aug 2025 13:24:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4638C4CEEB; Sun, 24 Aug 2025 13:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756041880; bh=ULWSWvx5qOQocuXhhEVwmUdZJ/jQrpo8zzXV1kr+XYk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SquWihWK3f+VpRPVHREvb/KU1Ip2U18TP7N1MuJITOAx4rQrPZH3cvqtkOP5SvK7q i6NO1TPVUbZk8RWkAk3LTCsFqBTBZ14HIKev8nasvhFuIsLkIUiO3cKzio2Q51II/F wyed5FtAlddWEWPif7U0YGP0VU7Jz0WnTx8oiBRZXCVwF7SJXztCvl7h61L8oudm/m ZzJcPQiQ6a3vkdslZGaL+map5bzuxrOH69hNlp4a8gDkADVHKqlXnjP6H9fUKUPAle G5RP+5YSDJFPCZAOfsIK30ngRx5fl+uNMhMZuFtvohYRU68gjsyw/nUrRlnisE/5CR 1GDLoGVBUCvXA== Date: Sun, 24 Aug 2025 16:24:23 +0300 From: Mike Rapoport To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Alexander Potapenko , Andrew Morton , Brendan Jackman , Christoph Lameter , Dennis Zhou , Dmitry Vyukov , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, iommu@lists.linux.dev, io-uring@vger.kernel.org, Jason Gunthorpe , Jens Axboe , Johannes Weiner , John Hubbard , kasan-dev@googlegroups.com, kvm@vger.kernel.org, "Liam R. Howlett" , Linus Torvalds , linux-arm-kernel@axis.com, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-ide@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mips@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, Lorenzo Stoakes , Marco Elver , Marek Szyprowski , Michal Hocko , Muchun Song , netdev@vger.kernel.org, Oscar Salvador , Peter Xu , Robin Murphy , Suren Baghdasaryan , Tejun Heo , virtualization@lists.linux.dev, Vlastimil Babka , wireguard@lists.zx2c4.com, x86@kernel.org, Zi Yan Subject: Re: [PATCH RFC 12/35] mm: limit folio/compound page sizes in problematic kernel configs Message-ID: References: <20250821200701.1329277-1-david@redhat.com> <20250821200701.1329277-13-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250821200701.1329277-13-david@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250824_062452_280503_C6B20670 X-CRM114-Status: GOOD ( 21.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 21, 2025 at 10:06:38PM +0200, David Hildenbrand wrote: > Let's limit the maximum folio size in problematic kernel config where > the memmap is allocated per memory section (SPARSEMEM without > SPARSEMEM_VMEMMAP) to a single memory section. > > Currently, only a single architectures supports ARCH_HAS_GIGANTIC_PAGE > but not SPARSEMEM_VMEMMAP: sh. > > Fortunately, the biggest hugetlb size sh supports is 64 MiB > (HUGETLB_PAGE_SIZE_64MB) and the section size is at least 64 MiB > (SECTION_SIZE_BITS == 26), so their use case is not degraded. > > As folios and memory sections are naturally aligned to their order-2 size > in memory, consequently a single folio can no longer span multiple memory > sections on these problematic kernel configs. > > nth_page() is no longer required when operating within a single compound > page / folio. > > Signed-off-by: David Hildenbrand Acked-by: Mike Rapoport (Microsoft) > --- > include/linux/mm.h | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 77737cbf2216a..48a985e17ef4e 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2053,11 +2053,25 @@ static inline long folio_nr_pages(const struct folio *folio) > return folio_large_nr_pages(folio); > } > > -/* Only hugetlbfs can allocate folios larger than MAX_ORDER */ > -#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE > -#define MAX_FOLIO_ORDER PUD_ORDER > -#else > +#if !defined(CONFIG_ARCH_HAS_GIGANTIC_PAGE) > +/* > + * We don't expect any folios that exceed buddy sizes (and consequently > + * memory sections). > + */ > #define MAX_FOLIO_ORDER MAX_PAGE_ORDER > +#elif defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) > +/* > + * Only pages within a single memory section are guaranteed to be > + * contiguous. By limiting folios to a single memory section, all folio > + * pages are guaranteed to be contiguous. > + */ > +#define MAX_FOLIO_ORDER PFN_SECTION_SHIFT > +#else > +/* > + * There is no real limit on the folio size. We limit them to the maximum we > + * currently expect. > + */ > +#define MAX_FOLIO_ORDER PUD_ORDER > #endif > > #define MAX_FOLIO_NR_PAGES (1UL << MAX_FOLIO_ORDER) > -- > 2.50.1 > -- Sincerely yours, Mike.