From nobody Sat Feb 7 21:08:20 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0F24333A714 for ; Thu, 18 Dec 2025 15:09:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766070598; cv=none; b=fW3UIDuWnpCW9oAJBAUlEOqgEkjuQl5DIYKwcsOhlVTaxKnb2Jtl157X8HwOd7SA+0ObUPz6g9mdpSbSvTXw3kb4iU0nJznhSiO0iyHLsMldU8VX5WWNu9QYpBmQwsjG4G826aID71KEkYrnDU4ZKlSnecwiCsUjKX+YONz5MdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766070598; c=relaxed/simple; bh=9tLpQ9D7laIhJe2k13i2JMUzd18FwyrCUsedyAAXldw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y82jbB+7KxBK0ygfiSvttAFlpoaDQACvR0KuHPa0dOxlLhz1wx6SgQfuWqEv/0F1RIRwrKVnAjgn2pY1FJYDiq0w8ZCu27b+swY7Qfq9jEhW+S/xL6Qa3PJthYwSVca7OHZf7Z1+aF4HFpX0z0OSKc5ZuNf7doKY8vx6KD0bv3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QQSva+qX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QQSva+qX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F26E1C19423; Thu, 18 Dec 2025 15:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766070597; bh=9tLpQ9D7laIhJe2k13i2JMUzd18FwyrCUsedyAAXldw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QQSva+qXAV/iy5U1+Gb1iCUvWGDgAUWoCxTdIxlEzvm3gjMlXKlFAmGWvuvRb1nAn G++siGXaPMw2oW3hDZ6e3lmPQfgw82PUxPEtLgG/Sf9rMlLfmIO2t5lKlBhtfEbPri gRdwMG1mnHkWRmHNlrLbSEAWdEbIcYB2SuyhsleYH4A0Mu6MBgkF5qrRMGcNrsD+95 iwoIh5vUXWvCjlKQOjwG7HF4RHD9vgt9bBxyKr0PRxwMFCOFFCx9ScYtTU970nSIH0 gc2FkgrlSYakJRiRAtSmwJNr0LQiaJuyCOOVIf0lm9l5aLOLX+/Y1LbzmG/v5xZ7Ij xZXApF1PZjbzA== Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfauth.phl.internal (Postfix) with ESMTP id 4AEC9F40072; Thu, 18 Dec 2025 10:09:56 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 18 Dec 2025 10:09:56 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdegheejhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmihhrhihlucfu hhhuthhsvghmrghuuceokhgrsheskhgvrhhnvghlrdhorhhgqeenucggtffrrghtthgvrh hnpefhudefjeehhfektdeuvdefveejffdvhfevtddugfduffejfeeikeelhedvtedvveen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehkihhrih hllhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudeiudduiedvieehhedq vdekgeeggeejvdekqdhkrghspeepkhgvrhhnvghlrdhorhhgsehshhhuthgvmhhovhdrnh grmhgvpdhnsggprhgtphhtthhopedvtddpmhhouggvpehsmhhtphhouhhtpdhrtghpthht oheprghkphhmsehlihhnuhigqdhfohhunhgurghtihhonhdrohhrghdprhgtphhtthhope hmuhgthhhunhdrshhonhhgsehlihhnuhigrdguvghvpdhrtghpthhtohepuggrvhhiuges khgvrhhnvghlrdhorhhgpdhrtghpthhtohepfihilhhlhiesihhnfhhrrgguvggrugdroh hrghdprhgtphhtthhopehushgrmhgrrghrihhfieegvdesghhmrghilhdrtghomhdprhgt phhtthhopehfvhgulhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepohhsrghlvhgrug horhesshhushgvrdguvgdprhgtphhtthhopehrphhptheskhgvrhhnvghlrdhorhhgpdhr tghpthhtohepvhgsrggskhgrsehsuhhsvgdrtgii X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Dec 2025 10:09:55 -0500 (EST) From: Kiryl Shutsemau To: Andrew Morton , Muchun Song , David Hildenbrand , Matthew Wilcox , Usama Arif , Frank van der Linden Cc: Oscar Salvador , Mike Rapoport , Vlastimil Babka , Lorenzo Stoakes , Zi Yan , Baoquan He , Michal Hocko , Johannes Weiner , Jonathan Corbet , kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Kiryl Shutsemau Subject: [PATCHv2 02/14] mm/sparse: Check memmap alignment Date: Thu, 18 Dec 2025 15:09:33 +0000 Message-ID: <20251218150949.721480-3-kas@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251218150949.721480-1-kas@kernel.org> References: <20251218150949.721480-1-kas@kernel.org> 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" The upcoming changes in compound_head() require memmap to be naturally aligned to the maximum folio size. Add a warning if it is not. A warning is sufficient as MAX_FOLIO_ORDER is very rarely used, so the kernel is still likely to be functional if this strict check fails. Signed-off-by: Kiryl Shutsemau --- include/linux/mmzone.h | 1 + mm/sparse.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 6cfede39570a..9f44dc760cdc 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -91,6 +91,7 @@ #endif =20 #define MAX_FOLIO_NR_PAGES (1UL << MAX_FOLIO_ORDER) +#define MAX_FOLIO_SIZE (PAGE_SIZE << MAX_FOLIO_ORDER) =20 enum migratetype { MIGRATE_UNMOVABLE, diff --git a/mm/sparse.c b/mm/sparse.c index 17c50a6415c2..c5810ff7c6f7 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -600,6 +600,9 @@ void __init sparse_init(void) BUILD_BUG_ON(!is_power_of_2(sizeof(struct mem_section))); memblocks_present(); =20 + WARN_ON(!IS_ALIGNED((unsigned long)pfn_to_page(0), + MAX_FOLIO_SIZE / sizeof(struct page))); + pnum_begin =3D first_present_section_nr(); nid_begin =3D sparse_early_nid(__nr_to_section(pnum_begin)); =20 --=20 2.51.2