From mboxrd@z Thu Jan 1 00:00:00 1970 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 3E01E331203 for ; Tue, 31 Mar 2026 19:55:31 +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=1774986931; cv=none; b=pkZ9LXGBOtjTfKUrZ16bgcJxoq1e2L3Ni3emBj7GgridufZ7VUZKZLzsyy1x5K9zYlwI3WHefUmRsyMutdR5mVVPY2tAC8EUZ4FiGWZ+SPG/4SzTyoH20ZXgQvC0n8aMRgD4rl+zg6xTyb6/9epKOOGRdm/7hWbRPORMyH6NYkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774986931; c=relaxed/simple; bh=4Z/YbbK/WBO5GmBjI0jCkVx8hWOxUtFdzK5FPKnb4jQ=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=cwPtQMDXAqd+iFy9X8TdIfoD+b+DL0cxAuMXMb3TL3QtO38WNVoQeeyobniKau0baA0PdDmwB/xl5a1r3D5mBXnHyAfoZXah75CMfgVmhDSZPVcJpTX5kUR49aLo527bNOJf8CAX2SbUXHee6arv9OrGb3rI+gM/z1MvefTgBn4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=weaybsoz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="weaybsoz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 960D1C19423; Tue, 31 Mar 2026 19:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774986931; bh=4Z/YbbK/WBO5GmBjI0jCkVx8hWOxUtFdzK5FPKnb4jQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=weaybsozmNvrlJV0s1e4b9zuIdwEDOfFoOpEYXO+IvefIKiedZ2vPq6TFOlkJKw9X iMcwYbBTqhsc8TjWAN5Sc+UeLDvltXqvIOwrQ/veRiLvnZTPy3Ngi50cs5oASb5PlP Bj2QdpN2z4Ejih2XtTWitbJWH0luMUeG94YMMrfM= Date: Tue, 31 Mar 2026 12:55:29 -0700 From: Andrew Morton To: Muchun Song Cc: David Hildenbrand , 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@linux.dev Subject: Re: [PATCH] mm/sparse: fix BUILD_BUG_ON check for section map alignment Message-Id: <20260331125529.de4deb7b46239fb13e4be517@linux-foundation.org> In-Reply-To: <20260331113023.2068075-1-songmuchun@bytedance.com> References: <20260331113023.2068075-1-songmuchun@bytedance.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 31 Mar 2026 19:30:23 +0800 Muchun Song wrote: > The comment in mmzone.h states that the alignment requirement > is the minimum of PAGE_SHIFT and PFN_SECTION_SHIFT. However, the > pointer arithmetic (mem_map - section_nr_to_pfn()) results in > a byte offset scaled by sizeof(struct page). Thus, the actual > alignment provided by the second term is PFN_SECTION_SHIFT + > __ffs(sizeof(struct page)). > > Update the compile-time check and the mmzone.h comment to > accurately reflect this mathematically guaranteed alignment by > taking the minimum of PAGE_SHIFT and PFN_SECTION_SHIFT + > __ffs(sizeof(struct page)). This avoids the issue of the check > being overly restrictive on architectures like powerpc where > PFN_SECTION_SHIFT alone is very small (e.g., 6). > > Also, remove the exhaustive per-architecture bit-width list from the > comment; such details risk falling out of date over time and may > inadvertently be left un-updated, while the existing BUILD_BUG_ON > provides sufficient compile-time verification of the constraint. > > No runtime impact so far: SECTION_MAP_LAST_BIT happens to fit within > the smaller limit on all existing architectures. Thanks. So this can fix the build on some arch/kconfig combinations? Do you think we should fix older kernels? > Fixes: def9b71ee651 ("include/linux/mmzone.h: fix explanation of lower bits in the SPARSEMEM mem_map pointer") Eight years ago so I'm going with "no".