From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (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 45CD73644DE for ; Wed, 1 Apr 2026 02:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775011680; cv=none; b=dy3F8Azb8vv+pZ906wUd8VjIdV1h34F6ijw1kR0dKQSpcriP/Al6XCPAdnU89LcNuc1w2yYdV1G1BmH1RmULDwdv9RocksC1Zc217pCnH7DziDnBWeX9hMTSmH5f/Cb66RH4UXvFlBB2WEkkxFAgQ3jJndr7lom2uXI/5vTW9Yk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775011680; c=relaxed/simple; bh=DisHX0GhBDe73RuFJj7HpzyNS8jNvLboEGl7kfhivoA=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=LtgcPstqNRGB5vOAbM9+ZaLyvRVYhYZGcPUgo7jglcrj/Dl3C/7THB3r7UJriyIXOaFDg57ly8aJNe+4BTctx510iapCnWcyihEhVdnnGbhR/elDQk+7KFn8D+11eMMGPkLJSI2IGnNGHzfEng1QWJI1qqoUbN61d+tkqlSKMe0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=CFaEf11v; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="CFaEf11v" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1775011667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CukHr5iu9h+eVEsN1hruv3LZlxiR3whhorbvL1gsP6g=; b=CFaEf11vAIM+Q1ildXdtLdEWJOJcvrAttxpq+jrrWS7fCZTZVm3n7d4nyovGUW/KG9zmIc cmpp0sRwnMqwtvSPgh3+hHJ8ohCbJ+QU8Om0pzjVbwcjEbUmLIqP6/QNVyUc/ItBP6a49d 1sJDU1kKbyiGgTXfTQUKsKdMDKGV0m0= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: [PATCH] mm/sparse: fix BUILD_BUG_ON check for section map alignment X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <29442561-9426-4635-9b7c-cdd138076127@kernel.org> Date: Wed, 1 Apr 2026 10:47:10 +0800 Cc: Andrew Morton , Muchun Song , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Petr Tesarik , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20260331113023.2068075-1-songmuchun@bytedance.com> <20260331125529.de4deb7b46239fb13e4be517@linux-foundation.org> <29442561-9426-4635-9b7c-cdd138076127@kernel.org> To: "David Hildenbrand (Arm)" X-Migadu-Flow: FLOW_OUT > On Apr 1, 2026, at 04:04, David Hildenbrand (Arm) = wrote: >=20 > On 3/31/26 21:55, Andrew Morton wrote: >> On Tue, 31 Mar 2026 19:30:23 +0800 Muchun Song = wrote: >>=20 >>> 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)). >>>=20 >>> 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). >>>=20 >>> 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. >>>=20 >>> No runtime impact so far: SECTION_MAP_LAST_BIT happens to fit within >>> the smaller limit on all existing architectures. >>=20 >> Thanks. So this can fix the build on some arch/kconfig combinations? >>=20 >> Do you think we should fix older kernels? >>=20 >>> Fixes: def9b71ee651 ("include/linux/mmzone.h: fix explanation of = lower bits in the SPARSEMEM mem_map pointer") >>=20 >> Eight years ago so I'm going with "no". >=20 > IIUC, there is nothing broken. Could only be revealed by some new > architecture. Or increasing SECTION_MAP_LAST_BIT for powerpc in the future. >=20 > So no stable :) Absolutely right. Thanks. >=20 > --=20 > Cheers, >=20 > David