From nobody Sun Jun 14 09:59:47 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 7285D37418C for ; Thu, 2 Apr 2026 10:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775125428; cv=none; b=OWRcPujLi7fzVuS8cRLVeQQmyvdgBI/AdWidRrQbUtlb7Rle7T+uaLn5K7WGltqyyKVMVI7SPoGMTK+RpJ11XAR+JRK/AtQF7rBxmbwJsy2sgFjSENLg585f5+T8GulkhqAsfR7YOTIF9ZbRMZh4yw8JKG4ZBNW4f4OJuDGwzos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775125428; c=relaxed/simple; bh=22hzvQv+Atab9iYYXIdvhVK3QqB+5/xEFUGgGa5elIk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Wp3gFUVWHzGYGQBrsn7+qGorgsld9tZqqQrNTL0PjE6hoOM1wioipjHS23TjjbgY8zDDPXXx629pkhB3qvsJBcaN90RrPIVNVMuUERq9NYLnDHuWfJD+j+vef2zHf2xwN9zN6tJLl17DIx4jbXB/0tCTJq+w106xwhjMsLJkHYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=NPoVcXsg; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="NPoVcXsg" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2b23fcf90b2so6327725ad.3 for ; Thu, 02 Apr 2026 03:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1775125424; x=1775730224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=grFJ78WqgRZrgeWWNHnn4Jx3/rkbuOWgiFKj5zXSxpU=; b=NPoVcXsgfAOKnO4pORk/mKnXFFritMalQSiUEEmRhOinjGWl71GxrrGJJd8cPVasSn 0ifGsMkR567BEIiIjelOLoo7XCV88qyFu7T/u8PCCiGSIUeGJx+2GKStQjleW89U1nm3 0VeHawqKz9pq8CTNngQv34gfrgelZHJvvPHJjVefUNYWgy9dsXyH13rwO1bSoyKlIKMP aOc69rWNdhmfoZK0Wc+pGgMQ+OjtDXoruikmXcYyFYNvB0bcgpiDY2dtsgf+1AwtULsb HJQl/tWzAph3sdutj85voDP78HUzyPfEHQEFtKEixF0pg17suSW1y2wjtOeTKGLmoY9M 7DJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775125424; x=1775730224; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=grFJ78WqgRZrgeWWNHnn4Jx3/rkbuOWgiFKj5zXSxpU=; b=bGIUK9U8Iafj+tLhc+4Ntb2pBnTfvmYHp/X6s2+RUsx4ZmcOaNbgm1mjGUvdbTCArX vYN9V5oM+9a/m9ogcodMHYQmzJSFvSn0+BdSNaRV0Q0K2n3iGFser5zhEkhoaZI5pVLq 2+3As94zHwv2iv21/ihUZetTGnOxLA5RmM9hmFsisMsK0E/tnpFO+fKHM2VnXkawE7O9 ouTdzBZ/es91n6mf3EQlr0i7gim/rWaSgXgzcc4ipk0MghJYrlkZgNixU6buwY6C4fc3 2tIyzasx3KykJzCpBgIcXroKRLU6JIIweimnlYW7jZwo50aZsvN2GUMPTP2QEYAnaw1I HBqA== X-Forwarded-Encrypted: i=1; AJvYcCXq/qf8wu7Z0sO6LBNybYGS6E8kx4ekpfbgke8UCfp9EyZnmgrILsDk8xPbhj3vwBrtiLwDtR5Kjl17ZEc=@vger.kernel.org X-Gm-Message-State: AOJu0Ywvz1OagMrOINKserotxam4v0wADEgw4hnVPkrxTNyuKlRewz3/ PhJ6q2JfADh3mAYhJ3ObsIxWk6cHXx6Dva5X/tZG1aLffrS8UGC1WKar/0L+tAKWu4U= X-Gm-Gg: AeBDievAnefjAK4fKz4jYlyWWF7qiqirgOcu+ZtcC/Min8hojzHNASoh0o6eRd97HHU TYLnJCh2DZEx0iFlFGRAmiQMPknCNIvVQTDRF2su5lSWJTfHx0uV1yU5llmFHmIlPy5UqlhMDvo jHK1WdIDIjHrfM7mBoLW/jNS+acJqP60YlMlJm3OjhdJHkBhDZ+2CyZY298DtQJ6911nVo9gUEC dSDEPuATemXUrJo233kukiAC/WP1HTFxxFKsEPDPdpQoiCnCkGXbIVe9behmeeiopxysI+598Om lfro+zBqBiensYkNhheemKtn8Dt6ZPeKXZDBNlD04mHCh+guxHws1w5lSOc9tarxliOCFSrLig2 tF1IYH2UJ7lhbbL6kKcdjs6yy171T1mrAFv+J3Uhc/WwAfMK7hlYiEfPqTH+4uovgBXjUV391MT SYk22WH5TgtGmZYUaKfQ== X-Received: by 2002:a17:902:ce05:b0:2b2:5428:ead8 with SMTP id d9443c01a7336-2b2699880a8mr71112325ad.0.1775125424197; Thu, 02 Apr 2026 03:23:44 -0700 (PDT) Received: from n232-176-004.byted.org ([240e:83:200::348]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749a475fsm23018775ad.61.2026.04.02.03.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2026 03:23:43 -0700 (PDT) From: Muchun Song To: Andrew Morton , David Hildenbrand Cc: Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Petr Tesarik , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song , muchun.song@linux.dev Subject: [PATCH v2] mm/sparse: fix comment for section map alignment Date: Thu, 2 Apr 2026 18:23:20 +0800 Message-Id: <20260402102320.3617578-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.20.1 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 comment in mmzone.h currently details exhaustive per-architecture bit-width lists and explains alignment using min(PAGE_SHIFT, PFN_SECTION_SHIFT). Such details risk falling out of date over time and may inadvertently be left un-updated. We always expect a single section to cover full pages. Therefore, we can safely assume that PFN_SECTION_SHIFT is large enough to accommodate SECTION_MAP_LAST_BIT. We use BUILD_BUG_ON() to ensure this. Update the comment to accurately reflect this consensus, making it clear that we rely on a single section covering full pages. Signed-off-by: Muchun Song Acked-by: David Hildenbrand (Arm) --- v1 -> v2: - Drop the actual BUILD_BUG_ON logic modification (keeping the simple comparison) and only simplify/clarify the mmzone.h comment. - Add explanation explicitly noting that a single section is always expected to cover full pages, per discussions with David Hildenbrand and Andrew Morton. --- include/linux/mmzone.h | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 7de42be81d4b..a071f1a0e242 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -2056,21 +2056,16 @@ static inline struct mem_section *__nr_to_section(u= nsigned long nr) extern size_t mem_section_usage_size(void); =20 /* - * We use the lower bits of the mem_map pointer to store - * a little bit of information. The pointer is calculated - * as mem_map - section_nr_to_pfn(pnum). The result is - * aligned to the minimum alignment of the two values: - * 1. All mem_map arrays are page-aligned. - * 2. section_nr_to_pfn() always clears PFN_SECTION_SHIFT - * lowest bits. PFN_SECTION_SHIFT is arch-specific - * (equal SECTION_SIZE_BITS - PAGE_SHIFT), and the - * worst combination is powerpc with 256k pages, - * which results in PFN_SECTION_SHIFT equal 6. - * To sum it up, at least 6 bits are available on all architectures. - * However, we can exceed 6 bits on some other architectures except - * powerpc (e.g. 15 bits are available on x86_64, 13 bits are available - * with the worst case of 64K pages on arm64) if we make sure the - * exceeded bit is not applicable to powerpc. + * We use the lower bits of the mem_map pointer to store a little bit of + * information. The pointer is calculated as mem_map - section_nr_to_pfn(). + * The result is aligned to the minimum alignment of the two values: + * + * 1. All mem_map arrays are page-aligned. + * 2. section_nr_to_pfn() always clears PFN_SECTION_SHIFT lowest bits. + * + * We always expect a single section to cover full pages. Therefore, + * we can safely assume that PFN_SECTION_SHIFT is large enough to + * accommodate SECTION_MAP_LAST_BIT. We use BUILD_BUG_ON() to ensure this. */ enum { SECTION_MARKED_PRESENT_BIT, --=20 2.20.1