On Wed, Sep 23, 2026 at 09:16:34PM +0800, Lance Yang wrote:
>
> On Tue, Sep 22, 2026 at 04:35:40PM +0100, Lorenzo Stoakes (ARM) wrote:
> >sun3 and coldfire are already supported, however motorola requires a little
> >more care.
> >
> >Here, custom table removal logic is required, so
> >CONFIG_HAVE_ARCH_TLB_REMOVE_TABLE is enabled for m68k-motorola.
> >
> >Firstly as part of this change, the page table level must be communicated
> >to the underlying __tlb_remove_table() implementation.
> >
> >Take advantage of the fact that page tables are aligned by more than enough
> >to permit setting TABLE_PTE or TABLE_PMD in the low bits of the pointer,
> >and store this there.
> >
> >Then update __pte_free_tlb() and __pmd_free_tlb() to pass this through,
> >then have __tlb_remove_table() decode this and pass it to
> >free_pointer_table().
> >
> >The page table freeing is performed via call_rcu(), so free_pointer_table()
> >now will be invoked from softirq context, and as such may be re-entrant.
> >
> >Introduce an irq save/restore spinlock to handle this, and hold it over the
> >time a given ptable entry is being referenced in both get_pointer_table()
> >and free_pointer_table().
> >
> >In order to make things a little easier in this respect, separate out the
> >logic for adding a new ptable entry into add_pointer_table() and only hold
> >the lock during ptable entry insertion in this case.
> >
> >Note that original list_add_tail(new, dp) added new prior to dp, which is
> >ptable_list[type].next, i.e. after ptable_list[type].
> >
> >The equivalent therefore is list_add(new, &ptable_list[type]), which adds
> >new after ptable_list[type], only without needing to make reference to dp.
> >
> >Note that, as m68k-motorola specifies CONFIG_HAVE_ARCH_TLB_REMOVE_TABLE, it
> >does not enable CONFIG_PT_RECLAIM. This isn't meaningfully impactful.
> >
> >With this applied, all of m68k implements CONFIG_MMU_GATHER_RCU_TABLE_FREE.
> >
> >This forms part of an overall effort to switch every architecture to this
> >mode.
> >
> >Acked-by: Kiryl Shutsemau (Meta) <[email protected]>
> >Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
> >---
>
> I wondered about slot reuse during the RCU wait, but that can't happen :)
>
> The slot stays marked busy until free_pointer_table() runs after RCU, and
> the last free unlinks the page under ptable_lock.
>
> Also ran page-table teardown stress and fork/exec churn on
> qemu-system-m68k (virt, m68040, CONFIG_MMU_MOTOROLA=y). All 40 rounds ran
> cleanly :D
>
> Acked-by: Lance Yang <[email protected]>
>
> Tested-by: Lance Yang <[email protected]>

Great, thanks! Really appreciate the testing :)

--
Cheers, Lorenzo

Reply via email to