All of lore.kernel.org
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Muchun Song <songmuchun@bytedance.com>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Petr Tesarik <ptesarik@suse.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/sparse: fix BUILD_BUG_ON check for section map alignment
Date: Wed, 1 Apr 2026 10:47:10 +0800	[thread overview]
Message-ID: <A75367AE-4459-4C17-9847-E1963849C3BA@linux.dev> (raw)
In-Reply-To: <29442561-9426-4635-9b7c-cdd138076127@kernel.org>



> On Apr 1, 2026, at 04:04, David Hildenbrand (Arm) <david@kernel.org> wrote:
> 
> On 3/31/26 21:55, Andrew Morton wrote:
>> On Tue, 31 Mar 2026 19:30:23 +0800 Muchun Song <songmuchun@bytedance.com> 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".
> 
> IIUC, there is nothing broken. Could only be revealed by some new
> architecture.

Or increasing SECTION_MAP_LAST_BIT for powerpc in the future.

> 
> So no stable :)

Absolutely right.

Thanks.

> 
> -- 
> Cheers,
> 
> David



  reply	other threads:[~2026-04-01  2:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 11:30 [PATCH] mm/sparse: fix BUILD_BUG_ON check for section map alignment Muchun Song
2026-03-31 19:55 ` Andrew Morton
2026-03-31 20:04   ` David Hildenbrand (Arm)
2026-04-01  2:47     ` Muchun Song [this message]
2026-03-31 20:07 ` Andrew Morton
2026-04-01  2:47   ` Muchun Song
2026-03-31 20:29 ` David Hildenbrand (Arm)
2026-04-01  2:57   ` Muchun Song
2026-04-01  2:59     ` Muchun Song
2026-04-01  4:01     ` Muchun Song
2026-04-01  7:08       ` David Hildenbrand (Arm)
2026-04-01  7:23         ` Muchun Song
2026-04-01  7:26           ` David Hildenbrand (Arm)
2026-04-01  7:28             ` Muchun Song
2026-04-01 16:33             ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2026-04-03  8:45 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A75367AE-4459-4C17-9847-E1963849C3BA@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=ptesarik@suse.com \
    --cc=rppt@kernel.org \
    --cc=songmuchun@bytedance.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.