From: Muchun Song <songmuchun@bytedance.com>
To: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>,
Muchun Song <songmuchun@bytedance.com>,
Arnd Bergmann <arnd@arndb.de>,
"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Helge Deller <deller@gmx.de>,
linux-mm@kvack.org, linux-arch@vger.kernel.org,
loongarch@lists.linux.dev, linux-mips@vger.kernel.org,
linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] mm: generalize kernel PTE table allocation
Date: Wed, 14 Oct 2026 11:59:08 +0800 [thread overview]
Message-ID: <20261014035910.687847-2-songmuchun@bytedance.com> (raw)
In-Reply-To: <20261014035910.687847-1-songmuchun@bytedance.com>
Architectures whose empty kernel PTE representation is not all zero must
initialize new kernel PTE tables. LoongArch therefore wraps
__pte_alloc_one_kernel() solely to call kernel_pte_init().
Call the architecture initialization hook from the generic allocator so
LoongArch can use it directly. The default hook is empty, so this does not
change other architectures.
Assisted-by: LLM
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
arch/loongarch/include/asm/pgalloc.h | 11 -----------
include/asm-generic/pgalloc.h | 6 +++++-
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/arch/loongarch/include/asm/pgalloc.h b/arch/loongarch/include/asm/pgalloc.h
index 248f62d0b590..a3f93a8b58be 100644
--- a/arch/loongarch/include/asm/pgalloc.h
+++ b/arch/loongarch/include/asm/pgalloc.h
@@ -10,7 +10,6 @@
#define __HAVE_ARCH_PMD_ALLOC_ONE
#define __HAVE_ARCH_PUD_ALLOC_ONE
-#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
#include <asm-generic/pgalloc.h>
static inline void pmd_populate_kernel(struct mm_struct *mm,
@@ -45,16 +44,6 @@ extern void pagetable_init(void);
extern pgd_t *pgd_alloc(struct mm_struct *mm);
-static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
-{
- pte_t *pte = __pte_alloc_one_kernel(mm);
-
- if (pte)
- kernel_pte_init(pte);
-
- return pte;
-}
-
#define __pte_free_tlb(tlb, pte, address) tlb_remove_ptdesc((tlb), page_ptdesc(pte))
#ifndef __PAGETABLE_PMD_FOLDED
diff --git a/include/asm-generic/pgalloc.h b/include/asm-generic/pgalloc.h
index 051aa1331051..a1de7d246754 100644
--- a/include/asm-generic/pgalloc.h
+++ b/include/asm-generic/pgalloc.h
@@ -19,6 +19,7 @@
static inline pte_t *__pte_alloc_one_kernel_noprof(struct mm_struct *mm)
{
struct ptdesc *ptdesc = pagetable_alloc_noprof(GFP_PGTABLE_KERNEL, 0);
+ pte_t *pte;
if (!ptdesc)
return NULL;
@@ -29,7 +30,10 @@ static inline pte_t *__pte_alloc_one_kernel_noprof(struct mm_struct *mm)
ptdesc_set_kernel(ptdesc);
- return ptdesc_address(ptdesc);
+ pte = ptdesc_address(ptdesc);
+ kernel_pte_init(pte);
+
+ return pte;
}
#define __pte_alloc_one_kernel(...) alloc_hooks(__pte_alloc_one_kernel_noprof(__VA_ARGS__))
--
2.54.0
next prev parent reply other threads:[~2026-10-14 3:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 3:59 [PATCH 0/3] mm: Generalize page table allocation helpers Muchun Song
2026-10-14 3:59 ` Muchun Song [this message]
2026-10-26 10:37 ` [PATCH 1/3] mm: generalize kernel PTE table allocation David Hildenbrand (Arm)
2026-10-14 3:59 ` [PATCH 2/3] mm: generalize PMD page " Muchun Song
2026-10-26 10:38 ` David Hildenbrand (Arm)
2026-10-14 3:59 ` [PATCH 3/3] mm: generalize PUD " Muchun Song
2026-10-26 10:38 ` David Hildenbrand (Arm)
2026-10-15 8:33 ` [PATCH 0/3] mm: Generalize page table allocation helpers Mike Rapoport
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=20261014035910.687847-2-songmuchun@bytedance.com \
--to=songmuchun@bytedance.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=chenhuacai@kernel.org \
--cc=david@kernel.org \
--cc=deller@gmx.de \
--cc=kernel@xen0n.name \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-parisc@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=muchun.song@linux.dev \
--cc=rppt@kernel.org \
--cc=tsbogend@alpha.franken.de \
/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
all inboxes | Powered by JetHome®