Re: [PATCH v2 02/22] x86/mm: Generalize LDT remap into "mm-local region"
From: Dave Hansen
Date: Fri Mar 20 2026 - 15:56:45 EST
On 3/20/26 11:23, Brendan Jackman wrote:
>
> +#ifdef CONFIG_MM_LOCAL_REGION
> +static inline void mm_local_region_free(struct mm_struct *mm)
> +{
> + if (mm_local_region_used(mm)) {
> + struct mmu_gather tlb;
> + unsigned long start = MM_LOCAL_BASE_ADDR;
> + unsigned long end = MM_LOCAL_END_ADDR;
> +
> + /*
> + * Although free_pgd_range() is intended for freeing user
> + * page-tables, it also works out for kernel mappings on x86.
> + * We use tlb_gather_mmu_fullmm() to avoid confusing the
> + * range-tracking logic in __tlb_adjust_range().
> + */
> + tlb_gather_mmu_fullmm(&tlb, mm);
These are superficial nits and I need to go through this series in
actual detail, but here are the nits:
Indentation is bad. What you have here double-indents the whole function.
Do this:
struct mmu_gather tlb;
unsigned long start = MM_LOCAL_BASE_ADDR;
unsigned long end = MM_LOCAL_END_ADDR;
if (!mm_local_region_used(mm))
return;
... rest of code here
> + * We use tlb_gather_mmu_fullmm() to avoid confusing the
> + * range-tracking logic in __tlb_adjust_range().
> + */
Imperative voice, please.
And a meta-comment:
> Documentation/arch/x86/x86_64/mm.rst | 4 +-
> arch/x86/Kconfig | 2 +
> arch/x86/include/asm/mmu_context.h | 119 ++++++++++++++++++++++++++++-
> arch/x86/include/asm/page.h | 32 ++++++++
> arch/x86/include/asm/pgtable_32_areas.h | 9 ++-
> arch/x86/include/asm/pgtable_64_types.h | 12 ++-
> arch/x86/kernel/ldt.c | 130 +++++---------------------------
This is too big and there's too much going on here. This is doing a few
logical things like both introducing mm-local regions *and* making the
LDT remap one of them.