From: Dave Hansen <dave.hansen@intel.com>
To: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>,
linux-kernel@vger.kernel.org
Cc: osalvador@suse.de, 42.hyeyoo@gmail.com, byungchul@sk.com,
dave.hansen@linux.intel.com, luto@kernel.org,
peterz@infradead.org, akpm@linux-foundation.org,
stable@vger.kernel.org, linux-mm@kvack.org,
max.byungchul.park@sk.com, max.byungchul.park@gmail.com
Subject: Re: [PATCH] x86/vmemmap: Synchronize with global pgds if populating init_mm's pgd
Date: Thu, 20 Feb 2025 10:02:54 -0800 [thread overview]
Message-ID: <d1da214c-53d3-45ac-a8b6-51821c5416e4@intel.com> (raw)
In-Reply-To: <20250220064105.808339-1-gwan-gyeong.mun@intel.com>
On 2/19/25 22:41, Gwan-gyeong Mun wrote:
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 01ea7c6df303..7935859bcc21 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1498,6 +1498,54 @@ static long __meminitdata addr_start, addr_end;
> static void __meminitdata *p_start, *p_end;
> static int __meminitdata node_start;
>
> +static void * __meminit vmemmap_alloc_block_zero(unsigned long size, int node)
> +{
> + void *p = vmemmap_alloc_block(size, node);
> +
> + if (!p)
> + return NULL;
> + memset(p, 0, size);
> +
> + return p;
> +}
This is a pure copy and paste of the generic function. I assume this is
because the mm/sparse-vmemmap.c is static. But this kind of copying is
really unfortunate.
...
> +pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
> +{
> + pgd_t *pgd = pgd_offset_k(addr);
> +
> + if (pgd_none(*pgd)) {
> + void *p = vmemmap_alloc_block_zero(PAGE_SIZE, node);
> +
> + if (!p)
> + return NULL;
> +
> + pgd_populate(&init_mm, pgd, p);
> + sync_global_pgds(addr, addr);
> + }
> +
> + return pgd;
> +}
I'd _really_ like to find another way to do this. We really don't want
to add copy-and-paste versions of generic functions that we now need to
maintain on the x86 side.
The _best_ way is probably to create some p*d_populate_kernel() helpers:
void pgd_populate_kernel(unsigned long addr, pgd_t *pgd, p4d_t *p4d)
{
pgd_populate(&init_mm, pgd, p4d);
arch_sync_global_pgds(addr, addr+something);
}
and move over most of the callers of:
p*d_populate(&init_mm, ...);
Because I suspect that'll fix your issue _and_ solve the generic class
of issues where folks populate a kernel page table entry but forget to
call sync_global_pgds().
next prev parent reply other threads:[~2025-02-20 18:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 6:41 Gwan-gyeong Mun
2025-02-20 18:02 ` Dave Hansen [this message]
2025-02-25 8:36 ` Oscar Salvador
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=d1da214c-53d3-45ac-a8b6-51821c5416e4@intel.com \
--to=dave.hansen@intel.com \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=byungchul@sk.com \
--cc=dave.hansen@linux.intel.com \
--cc=gwan-gyeong.mun@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=max.byungchul.park@gmail.com \
--cc=max.byungchul.park@sk.com \
--cc=osalvador@suse.de \
--cc=peterz@infradead.org \
--cc=stable@vger.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