From: Mike Rapoport <rppt@kernel.org>
To: Muchun Song <muchun.song@linux.dev>
Cc: Alexander Potapenko <glider@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Marco Elver <elver@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Chris Down <chris@chrisdown.name>,
David Hildenbrand <david@kernel.org>,
"Liam R . Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Brendan Jackman <brendan.jackman@linux.dev>,
Zi Yan <ziy@nvidia.com>, Joerg Roedel <joerg.roedel@amd.com>,
Lu Baolu <baolu.lu@linux.intel.com>,
Pranjal Shrivastava <praan@google.com>,
Ketan <ketan.kishore@oss.qualcomm.com>,
Mostafa Saleh <smostafa@google.com>,
Muchun Song <songmuchun@bytedance.com>,
Sang-Heon Jeon <ekffu200098@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Sashiko <sashiko-bot@kernel.org>,
kasan-dev@googlegroups.com, workflows@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH v2 5/7] mm/page_ext: allocate page extensions early for SPARSEMEM
Date: Wed, 18 Nov 2026 21:03:50 +0200 [thread overview]
Message-ID: <av32ls56XJmaAO8C@kernel.org> (raw)
In-Reply-To: <7f651049-f0dd-4053-a666-ea1c5d49669e@linux.dev>
On Wed, Nov 18, 2026 at 11:13:29PM +0800, Muchun Song wrote:
>
>
> On 2026/11/18 22:22, Mike Rapoport wrote:
> > On Tue, Nov 17, 2026 at 08:06:25PM +0800, Muchun Song wrote:
> > > KMSAN needs page extensions when kmsan_init_shadow() installs per-page
> > > metadata, before memblock_free_all() releases memory to the buddy
> > > allocator. FLATMEM makes page extensions available by this point,
> > > whereas SPARSEMEM initializes them later in boot.
> > >
> > > Allocate boot-time SPARSEMEM page extensions from memblock to match
> > > FLATMEM's initialization timing. This gives early clients the same
> > > page_ext availability guarantee across both memory models, while runtime
> > > memory hotplug continues to use vmalloc.
> > >
> > > Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> > Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
>
> Thanks for reviewing.
>
> >
> > with a nit below
> >
> > > ---
> > > v2:
> > > - Allocate all boot-time SPARSEMEM page extensions from memblock
> > > (suggested by Mike Rapoport)
> > > - Keep memblock allocations above DMA and suppress per-section free
> > > messages (suggested by Chris Down)
> > > ---
> > > include/linux/page_ext.h | 9 +--
> > > mm/mm_init.c | 4 --
> > > mm/page_ext.c | 119 +++++++++++++++++++--------------------
> > > 3 files changed, 60 insertions(+), 72 deletions(-)
> > >
> > > +static __ref void *alloc_page_ext(size_t size, int nid)
> > > {
> > > void *addr;
> > > + if (!slab_is_available()) {
> > > + addr = memblock_alloc_try_nid(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS),
> > > + MEMBLOCK_ALLOC_ACCESSIBLE, nid);
> > > + if (addr)
> > > + memmap_boot_pages_add(size / PAGE_SIZE);
> > I think it should be DIV_ROUND_UP().
>
> size is currently page-aligned by init_section_page_ext(), so both forms are
> equivalent here. Is the suggestion to avoid relying on this caller-side
> invariant and make it more robust? If so, I'll use DIV_ROUND_UP() for both
> accounting calls.
Yeah, keeping it here does not cost much and whatever
init_section_page_ext() does we still count the pages right.
Especially if we move the whole thingy to memmap_alloc().
> Thanks,
> Muchun
>
> >
> > > + return addr;
> > > + }
> > > +
> > > addr = vzalloc_node(size, nid);
> > > if (addr)
> > > - memmap_pages_add(DIV_ROUND_UP(size, PAGE_SIZE));
> > > + memmap_pages_add(size / PAGE_SIZE);
> > And here too.
> >
> > > return addr;
> > > }
> > > @@ -304,7 +300,7 @@ static int __meminit init_section_page_ext(unsigned long pfn, int nid)
> > > if (section->page_ext)
> > > return 0;
> > > - table_size = page_ext_size * PAGES_PER_SECTION;
> > > + table_size = PAGE_ALIGN(page_ext_size * PAGES_PER_SECTION);
> > > base = alloc_page_ext(table_size, nid);
> > > /*
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-11-18 19:04 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 12:06 [PATCH v2 0/7] KMSAN: Move per-page metadata out of struct page Muchun Song
2026-11-17 12:06 ` [PATCH v2 1/7] kmsan: encapsulate per-page metadata access Muchun Song
2026-11-17 12:06 ` [PATCH v2 2/7] mm/page_ext: fix client data alignment Muchun Song
2026-11-17 19:36 ` sashiko-bot
2026-11-17 19:46 ` Andrew Morton
2026-11-18 3:49 ` Muchun Song
2026-11-18 4:21 ` Andrew Morton
2026-11-18 5:39 ` Muchun Song
2026-11-18 5:51 ` Andrew Morton
2026-11-18 5:57 ` Muchun Song
2026-11-18 13:40 ` Mike Rapoport
2026-11-18 15:03 ` Muchun Song
2026-11-17 12:06 ` [PATCH v2 3/7] mm/page_ext: always use vmalloc for section page extensions Muchun Song
2026-11-18 13:43 ` Mike Rapoport
2026-11-17 12:06 ` [PATCH v2 4/7] mm/page_ext: use common allocation and initialization entry points Muchun Song
2026-11-18 14:18 ` Mike Rapoport
2026-11-17 12:06 ` [PATCH v2 5/7] mm/page_ext: allocate page extensions early for SPARSEMEM Muchun Song
2026-11-18 0:06 ` Chris Down
2026-11-18 3:11 ` Muchun Song
2026-11-18 7:00 ` Chris Down
2026-11-18 14:17 ` Mike Rapoport
2026-11-18 15:37 ` Muchun Song
2026-11-18 14:22 ` Mike Rapoport
2026-11-18 15:13 ` Muchun Song
2026-11-18 19:03 ` Mike Rapoport [this message]
2026-11-17 12:06 ` [PATCH v2 6/7] mm/page_ext: inline unchecked page extension lookup Muchun Song
2026-11-17 12:06 ` [PATCH v2 7/7] kmsan: fix metadata loss during HugeTLB struct page reinitialization Muchun Song
2026-11-18 0:06 ` [PATCH v2 0/7] KMSAN: Move per-page metadata out of struct page Chris Down
2026-11-18 3:12 ` Muchun Song
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=av32ls56XJmaAO8C@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=baolu.lu@linux.intel.com \
--cc=brendan.jackman@linux.dev \
--cc=chris@chrisdown.name \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=dvyukov@google.com \
--cc=ekffu200098@gmail.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=hannes@cmpxchg.org \
--cc=joerg.roedel@amd.com \
--cc=kasan-dev@googlegroups.com \
--cc=ketan.kishore@oss.qualcomm.com \
--cc=liam@infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=praan@google.com \
--cc=rdunlap@infradead.org \
--cc=sashiko-bot@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=smostafa@google.com \
--cc=songmuchun@bytedance.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=workflows@vger.kernel.org \
--cc=ziy@nvidia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox