From: Alexander Gordeev <agordeev@linux.ibm.com>
To: Heiko Carstens <hca@linux.ibm.com>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"Mike Rapoport (IBM)" <rppt@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Will Deacon <will@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Qi Zheng <zhengqi.arch@bytedance.com>,
linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org,
linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org,
linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org,
linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org,
linux-snps-arc@lists.infradead.org, linux-um@lists.infradead.org,
loongarch@lists.linux.dev, x86@kernel.org
Subject: Re: [PATCH v2 6/6] mm: Introduce ctor/dtor at PGD level
Date: Wed, 22 Jan 2025 15:06:05 +0100 [thread overview]
Message-ID: <Z5D7TSR3AttkC0Jf@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com> (raw)
In-Reply-To: <20250122074954.8685-A-hca@linux.ibm.com>
On Wed, Jan 22, 2025 at 08:49:54AM +0100, Heiko Carstens wrote:
> > > static inline pgd_t *pgd_alloc(struct mm_struct *mm)
> > > {
> > > - return (pgd_t *) crst_table_alloc(mm);
> > > + unsigned long *table = crst_table_alloc(mm);
> > > +
> > > + if (!table)
> > > + return NULL;
> >
> > I do not know status of this series, but FWIW, this call is missed:
> >
> > crst_table_init(table, _REGION1_ENTRY_EMPTY);
>
> Why is that missing?
Because the follow-up pagetable_pgd_ctor() is called against uninitialized
page table, while other pagetable_pXd_ctor() variants are called against
initialized one. I could imagine complications as result of that.
Whether Region1 table is the right choice is a big question though, as you
noticed below.
> A pgd table can be a Region1, Region2, or Region3 table. The only caller of
> this function is mm_init() via mm_alloc_pgd(); and right after mm_alloc_pgd()
> there is a call to init_new_context() which will initialize the pgd correctly.
init_new_context() is in a way a constructor as well, so whole thing looks odd
to me. But I do not immedeately see a better way :(
> I guess what really gets odd, and might be broken (haven't checked yet) is
> what happens on dynamic upgrade of page table levels (->crst_table_upgrade()).
Hmm, that is a good point.
> With that a pgd may become a pud, and with that we get an imbalance with
> the ctor/dtor calls for the various page table levels when they get freed
The ctor/dtor mismatch should not be a problem, as pagetable_pgd|p4d|pud_ctor()
are the same and there is one pagetable_dtor() for all top levels as of now.
But if it ever comes to separate implementations, then we are in the world
of pain.
> again. Plus, at first glance, it looks also broken that we have open-coded
> crst_alloc() calls instead of using the "proper" page table allocation API
> within crst_table_upgrade(), which again would cause an imbalance.
This is a good point too.
Many thanks!
next prev parent reply other threads:[~2025-01-22 14:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 18:44 [PATCH v2 0/6] Account page tables at all levels Kevin Brodsky
2025-01-03 18:44 ` [PATCH v2 1/6] mm: Move common part of pagetable_*_ctor to helper Kevin Brodsky
2025-01-03 18:44 ` [PATCH v2 2/6] parisc: mm: Ensure pagetable_pmd_[cd]tor are called Kevin Brodsky
2025-01-03 18:44 ` [PATCH v2 3/6] m68k: mm: Add calls to pagetable_pmd_[cd]tor Kevin Brodsky
2025-01-03 18:44 ` [PATCH v2 4/6] ARM: mm: Rename PGD helpers Kevin Brodsky
2025-01-03 18:44 ` [PATCH v2 5/6] asm-generic: pgalloc: Provide generic __pgd_{alloc,free} Kevin Brodsky
2025-01-03 18:44 ` [PATCH v2 6/6] mm: Introduce ctor/dtor at PGD level Kevin Brodsky
2025-01-21 16:37 ` Alexander Gordeev
2025-01-22 7:49 ` Heiko Carstens
2025-01-22 14:06 ` Alexander Gordeev [this message]
2025-01-22 21:16 ` Alexander Gordeev
2025-01-06 8:38 ` [PATCH v2 0/6] Account page tables at all levels Qi Zheng
2025-01-07 9:15 ` Kevin Brodsky
2025-02-03 19:15 ` patchwork-bot+linux-riscv
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=Z5D7TSR3AttkC0Jf@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com \
--to=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=hca@linux.ibm.com \
--cc=kevin.brodsky@arm.com \
--cc=linus.walleij@linaro.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-hexagon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-openrisc@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=linux-um@lists.infradead.org \
--cc=loongarch@lists.linux.dev \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
--cc=zhengqi.arch@bytedance.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