Re: [PATCH 15/22] mm: only initialise pt_share_count for user pgtables
Kevin Brodsky <[email protected]> Fri, 24 Jul 2026 18:25:35 +0200
| Newsgroups | org.infradead.lists.linux-um,dev.linux.lists.loongarch,org.infradead.lists.linux-riscv,org.kernel.vger.linux-arch,org.kernel.vger.linux-efi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-parisc,org.kernel.vger.linux-s390,org.kernel.vger.sparclinux,org.kvack.linux-mm,org.ozlabs.lists.linuxppc-dev |
|---|---|
| Message-ID | <[email protected]> |
On 21/07/2026 17:12, David Hildenbrand (Arm) wrote: > On 7/14/26 16:04, Kevin Brodsky wrote: >> ptdesc_pmd_pts_init() initialises the pt_share_count ptdesc field. >> That field is only used for hugetlb tracking purposes, so there is >> no need to initialise it for kernel page tables. Skip the call for >> kernel page tables, like pmd_ptlock_init(). >> >> From now on pagetable_*_ctor() and pagetable_dtor() do nothing for >> kernel page tables. >> >> Signed-off-by: Kevin Brodsky <[email protected]> >> --- >> include/linux/mm.h | 9 ++++++--- >> 1 file changed, 6 insertions(+), 3 deletions(-) >> >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index 94f0fb1c662a..b217ccbed5a3 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -3905,9 +3905,12 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, pmd_t *pmd) >> static inline bool pagetable_pmd_ctor(struct mm_struct *mm, >> struct ptdesc *ptdesc) >> { >> - if (!mm_is_kernel(mm) && !pmd_ptlock_init(ptdesc)) >> - return false; >> - ptdesc_pmd_pts_init(ptdesc); >> + if (!mm_is_kernel(mm)) { >> + if (!pmd_ptlock_init(ptdesc)) >> + return false; >> + ptdesc_pmd_pts_init(ptdesc); >> + } >> + > I'd have said "the initialization is cheap, why bother", but we already do have > the mm_is_kernel() check in place, so This isn't mainly about the overhead, but rather the fact that from here on the ctor/dtor do nothing for kernel page tables. Patch 20-22 rely on this, and in part 2 I would go further and only ever call the ctor/dtor for user page tables, so that the mm_is_kernel() check can be dropped. > Acked-by: David Hildenbrand (Arm) <[email protected]> Thanks for the reviews! - Kevin