|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 5/5] x86/xen: Replace generic lazy tracking with cpu specific one
Now that lazy mmu state tracking no longer relies on the Xen specific
one, cpu lazy mode is the only user of the Xen generic lazy tracking.
Replace the Xen generic lazy tracking with a cpu lazy specific one.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
arch/x86/include/asm/xen/hypervisor.h | 25 +------------------------
arch/x86/xen/enlighten_pv.c | 23 ++++++++++-------------
arch/x86/xen/mmu_pv.c | 6 +++---
3 files changed, 14 insertions(+), 40 deletions(-)
diff --git a/arch/x86/include/asm/xen/hypervisor.h
b/arch/x86/include/asm/xen/hypervisor.h
index c2fc7869b996..f666637d773e 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -64,30 +64,7 @@ void __init xen_pvh_init(struct boot_params *boot_params);
void __init mem_map_via_hcall(struct boot_params *boot_params_p);
#endif
-/* Lazy mode for batching updates / context switch */
-enum xen_lazy_mode {
- XEN_LAZY_NONE,
- XEN_LAZY_MMU,
- XEN_LAZY_CPU,
-};
-
-DECLARE_PER_CPU(enum xen_lazy_mode, xen_lazy_mode);
-
-static inline void enter_lazy(enum xen_lazy_mode mode)
-{
- BUG_ON(this_cpu_read(xen_lazy_mode) != XEN_LAZY_NONE);
-
- this_cpu_write(xen_lazy_mode, mode);
-}
-
-static inline void leave_lazy(enum xen_lazy_mode mode)
-{
- BUG_ON(this_cpu_read(xen_lazy_mode) != mode);
-
- this_cpu_write(xen_lazy_mode, XEN_LAZY_NONE);
-}
-
-enum xen_lazy_mode xen_get_lazy_mode(void);
+bool xen_is_cpu_lazy_mode(void);
#if defined(CONFIG_XEN_DOM0) && defined(CONFIG_ACPI)
void xen_sanitize_proc_cap_bits(uint32_t *buf);
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 8ee4910d597a..b310b91f2994 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -138,14 +138,11 @@ struct tls_descs {
struct desc_struct desc[3];
};
-DEFINE_PER_CPU(enum xen_lazy_mode, xen_lazy_mode) = XEN_LAZY_NONE;
+static DEFINE_PER_CPU(bool, xen_cpu_lazy_mode);
-enum xen_lazy_mode xen_get_lazy_mode(void)
+bool xen_is_cpu_lazy_mode(void)
{
- if (in_interrupt())
- return XEN_LAZY_NONE;
-
- return this_cpu_read(xen_lazy_mode);
+ return !in_interrupt() && this_cpu_read(xen_cpu_lazy_mode);
}
/*
@@ -425,7 +422,7 @@ static void xen_start_context_switch(struct task_struct
*prev)
BUG_ON(preemptible());
__task_lazy_mmu_mode_pause(prev);
- enter_lazy(XEN_LAZY_CPU);
+ this_cpu_write(xen_cpu_lazy_mode, true);
}
static void xen_end_context_switch(struct task_struct *next)
@@ -433,7 +430,7 @@ static void xen_end_context_switch(struct task_struct *next)
BUG_ON(preemptible());
xen_mc_flush();
- leave_lazy(XEN_LAZY_CPU);
+ this_cpu_write(xen_cpu_lazy_mode, false);
__task_lazy_mmu_mode_resume(next);
}
@@ -541,7 +538,7 @@ static void xen_set_ldt(const void *addr, unsigned entries)
MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
- xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU);
+ xen_mc_issue(!xen_is_cpu_lazy_mode());
}
static void xen_load_gdt(const struct desc_ptr *dtr)
@@ -637,7 +634,7 @@ static void xen_load_tls(struct thread_struct *t, unsigned
int cpu)
* exception between the new %fs descriptor being loaded and
* %fs being effectively cleared at __switch_to().
*/
- if (xen_get_lazy_mode() == XEN_LAZY_CPU)
+ if (xen_is_cpu_lazy_mode())
loadsegment(fs, 0);
xen_mc_batch();
@@ -646,7 +643,7 @@ static void xen_load_tls(struct thread_struct *t, unsigned
int cpu)
load_TLS_descriptor(t, cpu, 1);
load_TLS_descriptor(t, cpu, 2);
- xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU);
+ xen_mc_issue(!xen_is_cpu_lazy_mode());
}
static void xen_load_gs_index(unsigned int idx)
@@ -1008,7 +1005,7 @@ static void xen_load_sp0(unsigned long sp0)
mcs = xen_mc_entry(0);
MULTI_stack_switch(mcs.mc, __KERNEL_DS, sp0);
- xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU);
+ xen_mc_issue(!xen_is_cpu_lazy_mode());
this_cpu_write(cpu_tss_rw.x86_tss.sp0, sp0);
}
@@ -1068,7 +1065,7 @@ static void xen_write_cr0(unsigned long cr0)
MULTI_fpu_taskswitch(mcs.mc, (cr0 & X86_CR0_TS) != 0);
- xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU);
+ xen_mc_issue(!xen_is_cpu_lazy_mode());
}
static void xen_write_cr4(unsigned long cr4)
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
index 928b4b0a4484..aab5f70d407c 100644
--- a/arch/x86/xen/mmu_pv.c
+++ b/arch/x86/xen/mmu_pv.c
@@ -1425,7 +1425,7 @@ static void xen_write_cr3(unsigned long cr3)
else
__xen_write_cr3(false, 0);
- xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); /* interrupts
restored */
+ xen_mc_issue(!xen_is_cpu_lazy_mode()); /* interrupts restored */
}
/*
@@ -1460,7 +1460,7 @@ static void __init xen_write_cr3_init(unsigned long cr3)
__xen_write_cr3(true, cr3);
- xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); /* interrupts
restored */
+ xen_mc_issue(!xen_is_cpu_lazy_mode()); /* interrupts restored */
}
static int xen_pgd_alloc(struct mm_struct *mm)
@@ -1875,7 +1875,7 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd,
unsigned long max_pfn)
*/
xen_mc_batch();
__xen_write_cr3(true, __pa(init_top_pgt));
- xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU);
+ xen_mc_issue(!xen_is_cpu_lazy_mode());
/* We can't that easily rip out L3 and L2, as the Xen pagetables are
* set out this way: [L4], [L1], [L2], [L3], [L1], [L1] ... for
--
2.54.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |