Skip to content

Commit 95a7d76

Browse files
committed
xen/mmu: Use Xen specific TLB flush instead of the generic one.
As Mukesh explained it, the MMUEXT_TLB_FLUSH_ALL allows the hypervisor to do a TLB flush on all active vCPUs. If instead we were using the generic one (which ends up being xen_flush_tlb) we end up making the MMUEXT_TLB_FLUSH_LOCAL hypercall. But before we make that hypercall the kernel will IPI all of the vCPUs (even those that were asleep from the hypervisor perspective). The end result is that we needlessly wake them up and do a TLB flush when we can just let the hypervisor do it correctly. This patch gives around 50% speed improvement when migrating idle guest's from one host to another. Oracle-bug: 14630170 CC: stable@vger.kernel.org Tested-by: Jingjie Jiang <jingjie.jiang@oracle.com> Suggested-by: Mukesh Rathor <mukesh.rathor@oracle.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1 parent c8d258a commit 95a7d76

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

arch/x86/xen/mmu.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,25 @@ unsigned long xen_read_cr2_direct(void)
12881288
return this_cpu_read(xen_vcpu_info.arch.cr2);
12891289
}
12901290

1291+
void xen_flush_tlb_all(void)
1292+
{
1293+
struct mmuext_op *op;
1294+
struct multicall_space mcs;
1295+
1296+
trace_xen_mmu_flush_tlb_all(0);
1297+
1298+
preempt_disable();
1299+
1300+
mcs = xen_mc_entry(sizeof(*op));
1301+
1302+
op = mcs.args;
1303+
op->cmd = MMUEXT_TLB_FLUSH_ALL;
1304+
MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
1305+
1306+
xen_mc_issue(PARAVIRT_LAZY_MMU);
1307+
1308+
preempt_enable();
1309+
}
12911310
static void xen_flush_tlb(void)
12921311
{
12931312
struct mmuext_op *op;
@@ -2518,7 +2537,7 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
25182537
err = 0;
25192538
out:
25202539

2521-
flush_tlb_all();
2540+
xen_flush_tlb_all();
25222541

25232542
return err;
25242543
}

include/trace/events/xen.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,14 @@ DECLARE_EVENT_CLASS(xen_mmu_pgd,
377377
DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_pin);
378378
DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_unpin);
379379

380+
TRACE_EVENT(xen_mmu_flush_tlb_all,
381+
TP_PROTO(int x),
382+
TP_ARGS(x),
383+
TP_STRUCT__entry(__array(char, x, 0)),
384+
TP_fast_assign((void)x),
385+
TP_printk("%s", "")
386+
);
387+
380388
TRACE_EVENT(xen_mmu_flush_tlb,
381389
TP_PROTO(int x),
382390
TP_ARGS(x),

0 commit comments

Comments
 (0)