Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 02:28:56PM +0800, Wanpeng Li wrote: > > - have the TLB invalidate handler do something like: > > > >state = READ_ONCE(src->preempted); > >if (!(state & KVM_VCPU_IPI_PENDING)) > >return; > > > >local_flush_tlb(); > > > >do { > >} while (!try_c

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 02:10:16PM +0800, Wanpeng Li wrote: > 2017-11-13 21:02 GMT+08:00 Peter Zijlstra : > > That can be written like: > > > > do { > > if (state & KVM_VCPU_PREEMPTED) > > new_state = state | KVM_VCPU_SHOULD_FLUSH; > >

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Wanpeng Li
2017-11-13 18:46 GMT+08:00 Peter Zijlstra : > On Mon, Nov 13, 2017 at 04:26:57PM +0800, Wanpeng Li wrote: >> 2017-11-13 16:04 GMT+08:00 Peter Zijlstra : > >> > So if at this point a vCPU gets preempted we'll still spin-wait for it, >> > which is sub-optimal. >> > >> > I think we can come up with so

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Wanpeng Li
2017-11-13 21:02 GMT+08:00 Peter Zijlstra : > On Mon, Nov 13, 2017 at 11:46:34AM +0100, Peter Zijlstra wrote: >> On Mon, Nov 13, 2017 at 04:26:57PM +0800, Wanpeng Li wrote: >> > 2017-11-13 16:04 GMT+08:00 Peter Zijlstra : >> >> > > So if at this point a vCPU gets preempted we'll still spin-wait for

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Peter Zijlstra
On Mon, Nov 13, 2017 at 11:46:34AM +0100, Peter Zijlstra wrote: > On Mon, Nov 13, 2017 at 04:26:57PM +0800, Wanpeng Li wrote: > > 2017-11-13 16:04 GMT+08:00 Peter Zijlstra : > > > > So if at this point a vCPU gets preempted we'll still spin-wait for it, > > > which is sub-optimal. > > > > > > I th

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Peter Zijlstra
On Mon, Nov 13, 2017 at 04:26:57PM +0800, Wanpeng Li wrote: > 2017-11-13 16:04 GMT+08:00 Peter Zijlstra : > > So if at this point a vCPU gets preempted we'll still spin-wait for it, > > which is sub-optimal. > > > > I think we can come up with something to get around that 'problem' if > > indeed i

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Wanpeng Li
2017-11-13 16:04 GMT+08:00 Peter Zijlstra : > On Sun, Nov 12, 2017 at 04:33:24PM -0800, Wanpeng Li wrote: >> +static void kvm_flush_tlb_others(const struct cpumask *cpumask, >> + const struct flush_tlb_info *info) >> +{ >> + u8 state; >> + int cpu; >> + struct kvm_st

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Wanpeng Li
2017-11-13 15:59 GMT+08:00 Peter Zijlstra : > On Sun, Nov 12, 2017 at 04:33:24PM -0800, Wanpeng Li wrote: >> +static void kvm_flush_tlb_others(const struct cpumask *cpumask, >> + const struct flush_tlb_info *info) >> +{ >> + u8 state; >> + int cpu; >> + struct kvm_st

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Peter Zijlstra
On Sun, Nov 12, 2017 at 04:33:24PM -0800, Wanpeng Li wrote: > +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; > + struct cpumask *flushmask = t

Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush

2017-11-13 Thread Peter Zijlstra
On Sun, Nov 12, 2017 at 04:33:24PM -0800, Wanpeng Li wrote: > +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; > + struct cpumask *flushmask = t