mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: wanpengli@tencent.com, rkrcmar@redhat.com, paulus@ozlabs.org,
	maz@kernel.org
Subject: Re: [PATCH 1/2] KVM: Boost vCPUs that are delivering interrupts
Date: Thu, 18 Jul 2019 15:45:10 +0200	[thread overview]
Message-ID: <c28fb650-8150-4f42-4d01-8e8b2490c8b6@de.ibm.com> (raw)
In-Reply-To: <1563457031-21189-2-git-send-email-pbonzini@redhat.com>



On 18.07.19 15:37, Paolo Bonzini wrote:
> From: Wanpeng Li <wanpengli@tencent.com>
> 
> Inspired by commit 9cac38dd5d (KVM/s390: Set preempted flag during
> vcpu wakeup and interrupt delivery), we want to also boost not just
> lock holders but also vCPUs that are delivering interrupts. Most
> smp_call_function_many calls are synchronous, so the IPI target vCPUs
> are also good yield candidates.  This patch introduces vcpu->ready to
> boost vCPUs during wakeup and interrupt delivery time; unlike s390 we do
> not reuse vcpu->preempted so that voluntarily preempted vCPUs are taken
> into account by kvm_vcpu_on_spin, but vmx_vcpu_pi_put is not affected
> (VT-d PI handles voluntary preemption separately, in pi_pre_block).
> 
> Testing on 80 HT 2 socket Xeon Skylake server, with 80 vCPUs VM 80GB RAM:
> ebizzy -M
> 
>             vanilla     boosting    improved
> 1VM          21443       23520         9%
> 2VM           2800        8000       180%
> 3VM           1800        3100        72%
> 
> Testing on my Haswell desktop 8 HT, with 8 vCPUs VM 8GB RAM, two VMs,
> one running ebizzy -M, the other running 'stress --cpu 2':
> 
> w/ boosting + w/o pv sched yield(vanilla)
> 
>             vanilla     boosting   improved
>               1570         4000      155%
> 
> w/ boosting + w/ pv sched yield(vanilla)
> 
>             vanilla     boosting   improved
>               1844         5157      179%
> 
> w/o boosting, perf top in VM:
> 
>  72.33%  [kernel]       [k] smp_call_function_many
>   4.22%  [kernel]       [k] call_function_i
>   3.71%  [kernel]       [k] async_page_fault
> 
> w/ boosting, perf top in VM:
> 
>  38.43%  [kernel]       [k] smp_call_function_many
>   6.31%  [kernel]       [k] async_page_fault
>   6.13%  libc-2.23.so   [.] __memcpy_avx_unaligned
>   4.88%  [kernel]       [k] call_function_interrupt
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Paul Mackerras <paulus@ozlabs.org>
> Cc: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 	v2->v3: put it in kvm_vcpu_wake_up, use WRITE_ONCE


Looks good. Some more comments

> 
>  arch/s390/kvm/interrupt.c | 2 +-
>  include/linux/kvm_host.h  | 1 +
>  virt/kvm/kvm_main.c       | 9 +++++++--
[...]

> @@ -4205,6 +4206,8 @@ static void kvm_sched_in(struct preempt_notifier *pn, int cpu)
>  
>  	if (vcpu->preempted)
>  		vcpu->preempted = false;
> +	if (vcpu->ready)
> +		WRITE_ONCE(vcpu->ready, false);

What is the rationale of checking before writing. Avoiding writable cache line ping pong?


>  
>  	kvm_arch_sched_in(vcpu, cpu);
>  
> @@ -4216,8 +4219,10 @@ static void kvm_sched_out(struct preempt_notifier *pn,
>  {
>  	struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn);
>  
> -	if (current->state == TASK_RUNNING)
> +	if (current->state == TASK_RUNNING) {
>  		vcpu->preempted = true;

WOuld it make sense to also use WRITE_ONCE for vcpu->preempted ?

> +		WRITE_ONCE(vcpu->ready, true);
> +	}
>  	kvm_arch_vcpu_put(vcpu);
>  }
>  
> 


  reply	other threads:[~2019-07-18 13:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18 13:37 [PATCH v3 0/2] Boost vCPUs that are ready to deliver interrupts Paolo Bonzini
2019-07-18 13:37 ` [PATCH 1/2] KVM: Boost vCPUs that are delivering interrupts Paolo Bonzini
2019-07-18 13:45   ` Christian Borntraeger [this message]
2019-07-18 13:50     ` Paolo Bonzini
2019-07-18 13:37 ` [PATCH 2/2] KVM: s390: Use kvm_vcpu_wake_up in kvm_s390_vcpu_wakeup Paolo Bonzini
2019-07-18 13:47   ` Christian Borntraeger

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=c28fb650-8150-4f42-4d01-8e8b2490c8b6@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=paulus@ozlabs.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=wanpengli@tencent.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®