From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5CBD321434 for ; Tue, 18 Nov 2025 14:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763475142; cv=none; b=fBigvTpmK+NXhpTq7TGhjApKA2PVHQ7cTxFT9Pd7Xmsd/63SeszHIeY4fnWTb7qpf84azFec8z7Uogwq/gE2YvJItG0TPg83l85KaTH8hWkTJLaJyBRiB74Jk0atw26eC7XkyZ90C3stJUd9erCh4hHISB/5XqPx5Om4SPHLcsk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763475142; c=relaxed/simple; bh=YJCbMXrFxc4lBmLKP9PfJMMIBxBx2LBYdV5jtGktq70=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:References; b=XCFYm5X1hqJzdmVxwX4xuzJkDAMouPS+gzWJCgPOclzixseJ/MlClHtANDYHHu7mbL2yX7SuCJvw1CDjGHfoy8weUEyjevd7A4TqcPADpFT/B0wHWmy3qf7XWYJiFZUFLRfqp+NiSyIrvjO8u0w06gp7bPvxKSdhC+9JxSaFric= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QIyxA6W7; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QIyxA6W7" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-3414de5b27eso4504423a91.0 for ; Tue, 18 Nov 2025 06:12:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763475140; x=1764079940; darn=vger.kernel.org; h=references:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=YJCbMXrFxc4lBmLKP9PfJMMIBxBx2LBYdV5jtGktq70=; b=QIyxA6W7wRiMWwyi2ClbyFws/xnTmhhO+GNuez02pQOZq05pK/QJa2kCKquYrkMFxU Kb3FWsvPnageV1TIFQbc1cfCrAyiD1N0vlM3tR3nUzg6Xwy82OV1go3jL0so9A3MucyM v0oW3iFBWa4gt7kj8lNfMzWWp4kyl+16+hzPjC9hy5TCZVj5laUr+Ex8OY4p8xrkAoRz Zo7+FY//Grh0Xvi2nWhdFoFYZsBfWHLQKUzzKC2IgsReIylIY4Ob8OF79QKVlTiwFxYw 0GFKb82BeWwonYautiRBFvxqg7/mg+VMlvadePEWML5zgLjOqRzM8hxJEWEvvewWmJ32 ES/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763475140; x=1764079940; h=references:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YJCbMXrFxc4lBmLKP9PfJMMIBxBx2LBYdV5jtGktq70=; b=hT+npijUn16Oyrv/ANMKB6IKCN+Njyr1cJBByEzhddTN0T799uBPVA8iHdWqCLtfDj bagY0mTKqOZcp95lzztx7HcRNklgLOpw0dEupJQ1LBlyUnLz6kzQpiVV/7eZuUbnp3tF x6A3z1e6wAj6yN3qOn6/zWECsvgu0mhy8ZQxVv01XSPBcSc2qRgo84sEWhUUisbxy5uF 0ExDDGUDqCbuOPHqyYm3wrPsy+oPN23ppGTtUmV31IMh9OIcQtUW5LxBApDf76/Ypca/ 56PMD07W2e7JXGJWdHKq4XYHdpZRqLAdoSNzjzhr+UeAV6BsnqoWnIl9LFwF96yWZI0e z2vA== X-Forwarded-Encrypted: i=1; AJvYcCVHwPEkDijVu7/I9TMEsI9C72gxI6Os/SST7iR92zGQx9FgPvjaWuDkeBhPPBLbP3c3eQ60GO1lf8onovE=@vger.kernel.org X-Gm-Message-State: AOJu0YzE0s6xD7MiCIHNAq4bkh/n5+cWlKnYHFRWI1a7YTuDPAsZ7Pcx HjBO2GlmofHlQIv03d7jKfXuIoek0Md3qapxZC8Ua6EBivc+akpmJjZS X-Gm-Gg: ASbGnctGC2/9f8OAe3HHfMtEI2GOqqtVpS1aQXzsIzWILS3m8Ri1EUeEwiY327YlRWj CEd23Jp8eQQ7/T0mxD27GaZ/CUiYRo4XOu+VnvA5iDd7EcyDPsf1oRYINAhfpB7tTP/I3mqjHYZ SZuYi1sbqyMDZHSm9D1yicIxeDPlnCHuRRyaQ7/pieI8WkenQyx0za7X/Av3KZRgEGkUKCrGWPy jUenWq1S65EF3rmjdtKvihIth5MktmFbSnHRKFjCWX+BbfotkQb6RY2LHcsluuNzeNqImG1XICf RWV+d4qjD4nydQF8HsE9Wk3s9tLB5Nskje0MJB+faPEfWtWW94wpCvVTC19QCnwhAbo0C3X5716 LO+FtZDpCXGI+WDUFYbz96FgxhzwwGsAWMVsP+eh/PVDPIav8XrBQREYkmo4oezhgBg4wp5Degq q1FhkCIw== X-Google-Smtp-Source: AGHT+IF1qIVKiE8DwAos/+cPYxxS2D1JpAkt4IZSDQhzjgwOLH+AWMhFOTG9x0eI/Lnzwx1Y2YGH7Q== X-Received: by 2002:a17:90b:4e8f:b0:32e:3c57:8a9e with SMTP id 98e67ed59e1d1-343fa76c377mr19701586a91.35.1763475139949; Tue, 18 Nov 2025 06:12:19 -0800 (PST) Received: from dw-tp ([49.207.232.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7b92772e713sm16374708b3a.54.2025.11.18.06.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 06:12:19 -0800 (PST) From: Ritesh Harjani (IBM) To: "David Hildenbrand (Red Hat)" , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev , "David Hildenbrand (Red Hat)" , Christophe Leroy , Sourabh Jain , Andrew Morton , Madhavan Srinivasan , Donet Tom , Michael Ellerman , Nicholas Piggin , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Nathan Chancellor Subject: Re: [PATCH v2] mm: fix MAX_FOLIO_ORDER on powerpc configs with hugetlb In-Reply-To: <20251114214920.2550676-1-david@kernel.org> Date: Tue, 18 Nov 2025 19:19:01 +0530 Message-ID: <87a50j30z6.ritesh.list@gmail.com> References: <20251114214920.2550676-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: "David Hildenbrand (Red Hat)" writes: > In the past, CONFIG_ARCH_HAS_GIGANTIC_PAGE indicated that we support > runtime allocation of gigantic hugetlb folios. In the meantime it evolved > into a generic way for the architecture to state that it supports > gigantic hugetlb folios. > > In commit fae7d834c43c ("mm: add __dump_folio()") we started using > CONFIG_ARCH_HAS_GIGANTIC_PAGE to decide MAX_FOLIO_ORDER: whether we could > have folios larger than what the buddy can handle. In the context of > that commit, we started using MAX_FOLIO_ORDER to detect page corruptions > when dumping tail pages of folios. Before that commit, we assumed that > we cannot have folios larger than the highest buddy order, which was > obviously wrong. > > In commit 7b4f21f5e038 ("mm/hugetlb: check for unreasonable folio sizes > when registering hstate"), we used MAX_FOLIO_ORDER to detect > inconsistencies, and in fact, we found some now. > > Powerpc allows for configs that can allocate gigantic folio during boot > (not at runtime), that do not set CONFIG_ARCH_HAS_GIGANTIC_PAGE and can > exceed PUD_ORDER. > > To fix it, let's make powerpc select CONFIG_ARCH_HAS_GIGANTIC_PAGE with > hugetlb on powerpc, and increase the maximum folio size with hugetlb to 16 > GiB on 64bit (possible on arm64 and powerpc) and 1 GiB on 32 bit (powerpc). > Note that on some powerpc configurations, whether we actually have gigantic > pages depends on the setting of CONFIG_ARCH_FORCE_MAX_ORDER, but there is > nothing really problematic about setting it unconditionally: we just try to > keep the value small so we can better detect problems in __dump_folio() > and inconsistencies around the expected largest folio in the system. > > Ideally, we'd have a better way to obtain the maximum hugetlb folio size > and detect ourselves whether we really end up with gigantic folios. Let's > defer bigger changes and fix the warnings first. > > While at it, handle gigantic DAX folios more clearly: DAX can only > end up creating gigantic folios with HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD. > > Add a new Kconfig option HAVE_GIGANTIC_FOLIOS to make both cases > clearer. In particular, worry about ARCH_HAS_GIGANTIC_PAGE only with > HUGETLB_PAGE. > > Note: with enabling CONFIG_ARCH_HAS_GIGANTIC_PAGE on powerpc, we will now > also allow for runtime allocations of folios in some more powerpc configs. So, book3s64 anyways always default to Radix which by default always select CONFIG_ARCH_HAS_GIGANTIC_PAGE. So even if during runtime Hash mmu gets selected, we anyways by default had this config enabled on book3s64. > I don't think this is a problem, but if it is we could handle it through > __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED. Exactly, I see we already have the above config knob at most places where this could be needed to prevent runtime gigantic pages. > > While __dump_page()/__dump_folio was also problematic (not handling dumping > of tail pages of such gigantic folios correctly), it doesn't seem > critical enough to mark it as a fix. > > Fixes: 7b4f21f5e038 ("mm/hugetlb: check for unreasonable folio sizes when registering hstate") > Reported-by: Christophe Leroy > Closes: https://lore.kernel.org/r/3e043453-3f27-48ad-b987-cc39f523060a@csgroup.eu/ > Reported-by: Sourabh Jain > Closes: https://lore.kernel.org/r/94377f5c-d4f0-4c0f-b0f6-5bf1cd7305b1@linux.ibm.com/ > Cc: Andrew Morton > Cc: Ritesh Harjani (IBM) > Cc: Madhavan Srinivasan > Cc: Donet Tom > Cc: Michael Ellerman > Cc: Nicholas Piggin > Cc: Christophe Leroy > Cc: Lorenzo Stoakes > Cc: "Liam R. Howlett" > Cc: Vlastimil Babka > Cc: Mike Rapoport > Cc: Suren Baghdasaryan > Cc: Michal Hocko > Cc: Nathan Chancellor > Signed-off-by: David Hildenbrand (Red Hat) > --- > > v1 -> v2: Sorry, this got delayed a bit as I wanted to run mm selftests and then update. As I had updated in previous version, this patch also fixes the warning during boot when RADIX MMU config is kept disabled at build time (that means only Hash is selected) on book3s64. No new tests failures were reported on running mm selftests with Hash mmu on book3s64. Also verified boot tests on few other ppc configs. So even though I know this patch is already taken in rc6, but still - Reviewed-and-tested-by: Ritesh Harjani (IBM) Thanks again for providing a quick fix! -ritesh