Re: [RFC] mm: Drop pxd_ERROR()
From: Anshuman Khandual
Date: Thu Aug 06 2026 - 23:05:06 EST
On Thu, Aug 06, 2026 at 01:47:23PM +0200, David Hildenbrand (Arm) wrote:
> On 8/6/26 10:06, Anshuman Khandual wrote:
> > pxd_ERROR() has been used in generic mm just to print the page table entry
> > in pxd_clear_bad() before clearing those out with pxd_clear() later. These
> > pxd_ERROR() macros have been provided by all platforms which basically did
> > the same thing.
> >
> > Make pxd_clear_bad() use recently added ptval_to_str() instead for printing
> > page table entries thus completely dropping dependency on platform provided
> > pxd_ERROR() macros which can then be dropped off. First move all required
> > helpers in core MM into a header file which could then be used else where.
> >
> > Although some platforms still use those macros internally as well. In which
> > case just move these macros inside the platform for now.
>
> No, just get rid of them first.
>
> The ones in arch/sh/mm/init.c are just supid:
>
> if (pgd_none(*pgd)) {
> pgd_ERROR(*pgd);
>
> printing a none PGD? Stupid. :)
Will drop them from arch/sh in a pre-requsite patch.
>
> Then there is arch/parisc/kernel/pci-dma.c, which just open-codes
> pmd_clear_bad() ?
>
> pmd_ERROR(*pmd);
> pmd_clear(pmd);
Will replace these instances in arch/parisc/ with corresponding generic
[pmd|pgd]_clear_bad() helpers as necessary in a pre-requsite patch.
>
>
> Anything else?
Just one more instance inside arch/loongarch/mm/init.c which could be
dropped as well.
if (!pte_none(ptep_get(ptep))) {
pte_ERROR(*ptep);
return;
}
>
> >
> > Cc: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> > Cc: linux-arch@xxxxxxxxxxxxxxx
> > Cc: linux-mm@xxxxxxxxx
> > Cc: linux-kernel@xxxxxxxxxxxxxxx
> > Signed-off-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>
> > ---
> > This applies on v7.2-rc6 but after the following patch
> >
> > https://lore.kernel.org/all/20260709044334.1741263-1-anshuman.khandual@xxxxxxx/
> >
> > Would it also make sense to just drop __FILE__ and __LINE__ from the output
> > in pxd_clear_bad() helpers as they always print the same details regardless
> > the error path and does not add much value.
>
> Yes, drop that, it's nonsensical given that all relevant calls are from
> mm/pgtable-generic.c
Will drop them.
>
> Thanks for looking into this!
>
> --
> Cheers,
>
> David