]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/xen: Get rid of last XEN_LAZY_MMU uses
authorJuergen Gross <jgross@suse.com>
Tue, 26 May 2026 15:05:13 +0000 (17:05 +0200)
committerJuergen Gross <jgross@suse.com>
Mon, 8 Jun 2026 07:21:06 +0000 (09:21 +0200)
There are only very few use cases of XEN_LAZY_MMU left. Get rid of
them in order to avoid having to call enter_lazy(XEN_LAZY_MMU) and
leave_lazy(XEN_LAZY_MMU).

The query in xen_batched_set_pte() can be replaced by using
is_lazy_mmu_mode_active() instead.

As xen_flush_lazy_mmu() will be called only with lazy MMU mode being
active, the test for the lazy mode can just be dropped.

In xen_start_context_switch() and xen_end_context_switch() use
__task_lazy_mmu_mode_pause() and __task_lazy_mmu_mode_resume(),
allowing to drop xen_enter_lazy_mmu() and xen_leave_lazy_mmu()
completely.

Call arch_flush_lazy_mmu_mode() from arch_leave_lazy_mmu_mode(), as
this is the only required action now.

Drop the lazy mmu enter and leave paravirt hooks, leaving the flush
hook as the only needed one.

Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20260526150514.129330-5-jgross@suse.com>

arch/x86/include/asm/paravirt.h
arch/x86/include/asm/paravirt_types.h
arch/x86/kernel/paravirt.c
arch/x86/xen/enlighten_pv.c
arch/x86/xen/mmu_pv.c

index cdfe4007443eeab1e2a131123acbee77f48c1aea..0591aa38fd859d8404b4b3f59b37cdf0d4600ec9 100644 (file)
@@ -483,17 +483,16 @@ static inline void arch_end_context_switch(struct task_struct *next)
 
 static inline void arch_enter_lazy_mmu_mode(void)
 {
-       PVOP_VCALL0(pv_ops, mmu.lazy_mode.enter);
 }
 
-static inline void arch_leave_lazy_mmu_mode(void)
+static inline void arch_flush_lazy_mmu_mode(void)
 {
-       PVOP_VCALL0(pv_ops, mmu.lazy_mode.leave);
+       PVOP_VCALL0(pv_ops, mmu.lazy_mode_flush);
 }
 
-static inline void arch_flush_lazy_mmu_mode(void)
+static inline void arch_leave_lazy_mmu_mode(void)
 {
-       PVOP_VCALL0(pv_ops, mmu.lazy_mode.flush);
+       arch_flush_lazy_mmu_mode();
 }
 
 static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
index 4f5ae0068aab9de92227d6d6ed8c8da853ba8eea..b4c4a23e77a1beb21b3b5649c538d930e14c0a38 100644 (file)
@@ -19,15 +19,6 @@ struct cpumask;
 struct flush_tlb_info;
 struct vm_area_struct;
 
-#ifdef CONFIG_PARAVIRT_XXL
-struct pv_lazy_ops {
-       /* Set deferred update mode, used for batching operations. */
-       void (*enter)(void);
-       void (*leave)(void);
-       void (*flush)(void);
-} __no_randomize_layout;
-#endif
-
 struct pv_cpu_ops {
        /* hooks for various privileged instructions */
 #ifdef CONFIG_PARAVIRT_XXL
@@ -171,7 +162,7 @@ struct pv_mmu_ops {
 
        void (*set_pgd)(pgd_t *pgdp, pgd_t pgdval);
 
-       struct pv_lazy_ops lazy_mode;
+       void (*lazy_mode_flush)(void);
 
        /* dom0 ops */
 
index 792fa96b32330c2e1d3a182929d49ee0a03dbcd1..22f72034470f9adfbf24cc671ddb1303bdb6f826 100644 (file)
@@ -204,11 +204,7 @@ struct paravirt_patch_template pv_ops = {
 
        .mmu.enter_mmap         = paravirt_nop,
 
-       .mmu.lazy_mode = {
-               .enter          = paravirt_nop,
-               .leave          = paravirt_nop,
-               .flush          = paravirt_nop,
-       },
+       .mmu.lazy_mode_flush    = paravirt_nop,
 
        .mmu.set_fixmap         = native_set_fixmap,
 #endif /* CONFIG_PARAVIRT_XXL */
index 428189f5d437e3344a6a97937ad91391dfc70421..8ee4910d597a4760ad997ceb67b868ba5c8cfbb8 100644 (file)
@@ -424,9 +424,7 @@ static void xen_start_context_switch(struct task_struct *prev)
 {
        BUG_ON(preemptible());
 
-       if (this_cpu_read(xen_lazy_mode) == XEN_LAZY_MMU) {
-               arch_leave_lazy_mmu_mode();
-       }
+       __task_lazy_mmu_mode_pause(prev);
        enter_lazy(XEN_LAZY_CPU);
 }
 
@@ -436,8 +434,7 @@ static void xen_end_context_switch(struct task_struct *next)
 
        xen_mc_flush();
        leave_lazy(XEN_LAZY_CPU);
-       if (__task_lazy_mmu_mode_active(next))
-               arch_enter_lazy_mmu_mode();
+       __task_lazy_mmu_mode_resume(next);
 }
 
 static unsigned long xen_store_tr(void)
index 51dbdc67c73c27c1bbdf603baa9da64071d1982e..928b4b0a44841c09ea0fcaacaf78dccc5f326a06 100644 (file)
@@ -324,7 +324,7 @@ static bool xen_batched_set_pte(pte_t *ptep, pte_t pteval)
 {
        struct mmu_update u;
 
-       if (xen_get_lazy_mode() != XEN_LAZY_MMU)
+       if (!is_lazy_mmu_mode_active())
                return false;
 
        xen_mc_batch();
@@ -2151,21 +2151,10 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
 #endif
 }
 
-static void xen_enter_lazy_mmu(void)
-{
-       preempt_disable();
-       if (xen_get_lazy_mode() != XEN_LAZY_MMU)
-               enter_lazy(XEN_LAZY_MMU);
-       preempt_enable();
-}
-
 static void xen_flush_lazy_mmu(void)
 {
        preempt_disable();
-
-       if (xen_get_lazy_mode() == XEN_LAZY_MMU)
-               xen_mc_flush();
-
+       xen_mc_flush();
        preempt_enable();
 }
 
@@ -2189,15 +2178,6 @@ static void __init xen_post_allocator_init(void)
        pv_ops.mmu.write_cr3 = &xen_write_cr3;
 }
 
-static void xen_leave_lazy_mmu(void)
-{
-       preempt_disable();
-       xen_mc_flush();
-       if (xen_get_lazy_mode() != XEN_LAZY_NONE)
-               leave_lazy(XEN_LAZY_MMU);
-       preempt_enable();
-}
-
 void __init xen_init_mmu_ops(void)
 {
        x86_init.paging.pagetable_init = xen_pagetable_init;
@@ -2237,9 +2217,7 @@ void __init xen_init_mmu_ops(void)
        pv_ops.mmu.make_p4d = PV_CALLEE_SAVE(xen_make_p4d);
        pv_ops.mmu.enter_mmap = xen_enter_mmap;
        pv_ops.mmu.exit_mmap = xen_exit_mmap;
-       pv_ops.mmu.lazy_mode.enter = xen_enter_lazy_mmu;
-       pv_ops.mmu.lazy_mode.leave = xen_leave_lazy_mmu;
-       pv_ops.mmu.lazy_mode.flush = xen_flush_lazy_mmu;
+       pv_ops.mmu.lazy_mode_flush = xen_flush_lazy_mmu;
        pv_ops.mmu.set_fixmap = xen_set_fixmap;
 
        memset(dummy_mapping, 0xff, PAGE_SIZE);