From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <wanpeng.li@hotmail.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v6 2/4] KVM: X86: Add Paravirt TLB Shootdown
Date: Wed, 29 Nov 2017 17:21:19 +0100 [thread overview]
Message-ID: <20171129162118.GA10661@flask> (raw)
In-Reply-To: <1511841955-7375-3-git-send-email-wanpeng.li@hotmail.com>
2017-11-27 20:05-0800, Wanpeng Li:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> Remote flushing api's does a busy wait which is fine in bare-metal
> scenario. But with-in the guest, the vcpus might have been pre-empted
> or blocked. In this scenario, the initator vcpu would end up
> busy-waiting for a long amount of time.
>
> This patch set implements para-virt flush tlbs making sure that it
> does not wait for vcpus that are sleeping. And all the sleeping vcpus
> flush the tlb on guest enter.
>
> The best result is achieved when we're overcommiting the host by running
> multiple vCPUs on each pCPU. In this case PV tlb flush avoids touching
> vCPUs which are not scheduled and avoid the wait on the main CPU.
>
> Testing on a Xeon Gold 6142 2.6GHz 2 sockets, 32 cores, 64 threads,
> so 64 pCPUs, and each VM is 64 vCPUs.
>
> ebizzy -M
> vanilla optimized boost
> 1VM 46799 48670 4%
> 2VM 23962 42691 78%
> 3VM 16152 37539 132%
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> @@ -498,6 +498,37 @@ static void __init kvm_apf_trap_init(void)
> update_intr_gate(X86_TRAP_PF, async_page_fault);
> }
>
> +static DEFINE_PER_CPU(cpumask_t, __pv_tlb_mask);
> +
> +static void kvm_flush_tlb_others(const struct cpumask *cpumask,
> + const struct flush_tlb_info *info)
> +{
> + u8 state;
> + int cpu;
> + struct kvm_steal_time *src;
> + cpumask_t *flushmask = &per_cpu(__pv_tlb_mask, smp_processor_id());
> +
> + if (unlikely(!flushmask))
> + return;
I don't see how this can be NULL and if it could, we'd have to call
native_flush_tlb_others() instead of returning anyway.
Also, Peter mentioned that we're wasting memory (default is 1k per CPU)
when not running on KVM. Hyper-V hijacks x86_platform.apic_post_init()
to achieve late allocation. smp_ops.smp_prepare_cpus seems slightly
better for our purposes, but I don't really like either.
Couldn't we use use arch_initcall(), or early_initcall() if there are
complications with allocating after smp_init()?
Thanks.
next prev parent reply other threads:[~2017-11-29 16:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 4:05 [PATCH v6 0/4] KVM: X86: Add Paravirt TLB Shootdown Wanpeng Li
2017-11-28 4:05 ` [PATCH v6 1/4] KVM: X86: Add vCPU running/preempted state Wanpeng Li
2017-11-28 4:05 ` [PATCH v6 2/4] KVM: X86: Add Paravirt TLB Shootdown Wanpeng Li
2017-11-29 16:21 ` Radim Krčmář [this message]
2017-11-30 6:24 ` Wanpeng Li
2017-11-30 15:14 ` Radim Krčmář
2017-11-28 4:05 ` [PATCH v6 3/4] KVM: X86: introduce invalidate_gpa argument to tlb flush Wanpeng Li
2017-11-28 4:05 ` [PATCH v6 4/4] KVM: X86: Add flush_on_enter before guest enter Wanpeng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171129162118.GA10661@flask \
--to=rkrcmar@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=wanpeng.li@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.