From: Muchun Song <muchun.song@linux.dev>
To: Lance Yang <lance.yang@linux.dev>
Cc: Sashiko <sashiko-bot@kernel.org>,
Muchun Song <songmuchun@bytedance.com>,
David Hildenbrand <david@kernel.org>,
maddy@linux.ibm.com, Mike Rapoport <rppt@kernel.org>,
akpm@linux-foundation.org, mpe@ellerman.id.au, npiggin@gmail.com,
chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com,
osalvador@suse.de, Qi Zheng <qi.zheng@linux.dev>,
chenhuacai@kernel.org, kernel@xen0n.name, linux-mm@kvack.org,
x86@kernel.org, linux-s390@vger.kernel.org, hca@linux.ibm.com,
gor@linux.ibm.com, agordeev@linux.ibm.com,
borntraeger@linux.ibm.com
Subject: Re: [PATCH v2 2/5] powerpc/mm: drop powerpc vmemmap_can_optimize()
Date: Fri, 6 Nov 2026 14:09:39 +0800 [thread overview]
Message-ID: <2AB0A0B1-1613-44CC-A007-2453F6206D77@linux.dev> (raw)
In-Reply-To: <20261105080241.57241-1-lance.yang@linux.dev>
> On Nov 5, 2026, at 16:02, Lance Yang <lance.yang@linux.dev> wrote:
>
>
> On Thu, Nov 05, 2026 at 07:16:48AM +0000, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>> - [Low] mm: undeclared vmemmap in section_vmemmap_optimization_disable()
>> - [Low] mm: define vmemmap_optimizable_order() before section_vmemmap_optimizable()
>> --
>
> IIUC, on LoongArch, asm/pgtable.h includes vmemmap-optimization.h before
> defining vmemmap.
Yeah. Really nasty.
>
> How about taking a PFN and page count instead, and leaving the conversion
> to the callers?
However, although this can solve the compilation problem, for the caller,
it is not very straightforward because they need to calculate nr_pages.
section_vmemmap_optimization_disable is only supposed to be used in the
vmemmap population path, and in these paths, the most direct parameters
are start and end. I think this function could be moved to
mm/sparse-vmemmap.c, and that way the compilation dependency problem
would be solved.
What do you think?
Thanks,
Muchun
>
> ---8<---
> diff --git a/arch/loongarch/mm/init.c b/arch/loongarch/mm/init.c
> index c91afce46136..5a3a225135be 100644
> --- a/arch/loongarch/mm/init.c
> +++ b/arch/loongarch/mm/init.c
> @@ -143,7 +143,8 @@ void __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node,
> int __meminit vmemmap_populate(unsigned long start, unsigned long end,
> int node, struct vmem_altmap *altmap)
> {
> - section_vmemmap_optimization_disable(start, end);
> + section_vmemmap_optimization_disable(page_to_pfn((struct page *)start),
> + (end - start) / sizeof(struct page));
> #if CONFIG_PGTABLE_LEVELS == 2
> return vmemmap_populate_basepages(start, end, node, NULL);
> #else
> diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
> index 4d6928f717cf..43c98aec29aa 100644
> --- a/arch/powerpc/mm/init_64.c
> +++ b/arch/powerpc/mm/init_64.c
> @@ -283,7 +283,8 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
> return radix__vmemmap_populate(start, end, node, altmap);
> #endif
>
> - section_vmemmap_optimization_disable(start, end);
> + section_vmemmap_optimization_disable(page_to_pfn((struct page *)start),
> + (end - start) / sizeof(struct page));
> return __vmemmap_populate(start, end, node, altmap);
> }
>
> diff --git a/include/linux/vmemmap-optimization.h b/include/linux/vmemmap-optimization.h
> index 9d9f7a67d195..0501234ab16b 100644
> --- a/include/linux/vmemmap-optimization.h
> +++ b/include/linux/vmemmap-optimization.h
> @@ -76,11 +76,9 @@ static inline bool section_vmemmap_optimizable(const struct mem_section *section
> return vmemmap_optimizable_order(section_compound_order(section));
> }
>
> -static inline void section_vmemmap_optimization_disable(unsigned long start,
> - unsigned long end)
> +static inline void section_vmemmap_optimization_disable(unsigned long pfn,
> + unsigned long nr_pages)
> {
> - unsigned long pfn = page_to_pfn((struct page *)start);
> - unsigned long nr_pages = (end - start) / sizeof(struct page);
> struct mem_section *section = __pfn_to_section(pfn);
>
> if (nr_pages < PAGES_PER_SECTION) {
> @@ -119,8 +117,8 @@ static inline bool section_vmemmap_optimizable(const struct mem_section *section
> return false;
> }
>
> -static inline void section_vmemmap_optimization_disable(unsigned long start,
> - unsigned long end)
> +static inline void section_vmemmap_optimization_disable(unsigned long pfn,
> + unsigned long nr_pages)
> {
> }
>
> diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
> index 5777f2e29684..64bc346d0fc5 100644
> --- a/mm/sparse-vmemmap.c
> +++ b/mm/sparse-vmemmap.c
> @@ -474,7 +474,7 @@ struct page * __meminit __populate_section_memmap(unsigned long pfn,
>
> /* Altmap-backed vmemmap pages cannot be optimized. */
> if (altmap)
> - section_vmemmap_optimization_disable(start, end);
> + section_vmemmap_optimization_disable(pfn, nr_pages);
> r = vmemmap_populate(start, end, nid, altmap);
> if (r < 0)
> return NULL;
> ---
>
> Cheers, Lance
next prev parent reply other threads:[~2026-11-06 6:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 6:12 [PATCH v2 0/5] mm: Simplify device DAX vmemmap optimization plumbing Muchun Song
2026-11-05 6:12 ` [PATCH v2 1/5] powerpc/mm: make vmemmap_populate_compound_pages() static Muchun Song
2026-11-05 7:16 ` sashiko-bot
2026-11-06 4:38 ` Lance Yang
2026-11-05 6:12 ` [PATCH v2 2/5] powerpc/mm: drop powerpc vmemmap_can_optimize() Muchun Song
2026-11-05 7:16 ` sashiko-bot
2026-11-05 8:02 ` Lance Yang
2026-11-06 6:09 ` Muchun Song [this message]
2026-11-06 9:48 ` Lance Yang
2026-11-05 12:13 ` kernel test robot
2026-11-05 6:12 ` [PATCH v2 3/5] loongarch/mm: disable device DAX vmemmap optimization Muchun Song
2026-11-05 7:16 ` sashiko-bot
2026-11-05 6:12 ` [PATCH v2 4/5] mm/sparse-vmemmap: drop vmemmap_can_optimize() Muchun Song
2026-11-05 7:16 ` sashiko-bot
2026-11-05 6:12 ` [PATCH v2 5/5] mm/sparse-vmemmap: drop @pgmap from vmemmap population APIs Muchun Song
2026-11-05 7:16 ` sashiko-bot
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=2AB0A0B1-1613-44CC-A007-2453F6206D77@linux.dev \
--to=muchun.song@linux.dev \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=borntraeger@linux.ibm.com \
--cc=chenhuacai@kernel.org \
--cc=chleroy@kernel.org \
--cc=david@kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kernel@xen0n.name \
--cc=lance.yang@linux.dev \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=osalvador@suse.de \
--cc=qi.zheng@linux.dev \
--cc=ritesh.list@gmail.com \
--cc=rppt@kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=songmuchun@bytedance.com \
--cc=sshegde@linux.ibm.com \
--cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox