public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Li,Rongqing" <lirongqing@baidu.com>
To: "x86@kernel.org" <x86@kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: 答复: [PATCH][v2] KVM: x86: directly call wbinvd for local cpu when emulate wbinvd
Date: Fri, 22 Oct 2021 04:16:05 +0000	[thread overview]
Message-ID: <4857464fb9684af8a485ce9eb790fd75@baidu.com> (raw)
In-Reply-To: <1634118172-32699-1-git-send-email-lirongqing@baidu.com>

Ping 

-Li

> -----邮件原件-----
> 发件人: Li,Rongqing <lirongqing@baidu.com>
> 发送时间: 2021年10月13日 17:43
> 收件人: x86@kernel.org; kvm@vger.kernel.org; Li,Rongqing
> <lirongqing@baidu.com>
> 主题: [PATCH][v2] KVM: x86: directly call wbinvd for local cpu when emulate
> wbinvd
> 
> directly call wbinvd for local cpu, instead of calling atomic cpumask_set_cpu to
> set local cpu, and then check if local cpu needs to run in on_each_cpu_mask
> 
> on_each_cpu_mask is less efficient than smp_call_function_many, since it will
> close preempt again and running call function by checking flag with
> SCF_RUN_LOCAL. and here wbinvd can be called directly
> 
> In fact, This change reverts commit 2eec73437487 ("KVM: x86: Avoid issuing
> wbinvd twice"), since smp_call_function_many is skiping the local cpu (as
> description of c2162e13d6e2f), wbinvd is not issued twice
> 
> and reverts commit c2162e13d6e2f ("KVM: X86: Fix missing local pCPU when
> executing wbinvd on all dirty pCPUs") too, which fixed the previous patch, when
> revert previous patch, it is not needed.
> 
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> diff v2: rewrite commit log
> 
>  arch/x86/kvm/x86.c |   13 ++++++-------
>  1 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index aabd3a2..28c4c72
> 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6991,15 +6991,14 @@ static int kvm_emulate_wbinvd_noskip(struct
> kvm_vcpu *vcpu)
>  		return X86EMUL_CONTINUE;
> 
>  	if (static_call(kvm_x86_has_wbinvd_exit)()) {
> -		int cpu = get_cpu();
> -
> -		cpumask_set_cpu(cpu, vcpu->arch.wbinvd_dirty_mask);
> -		on_each_cpu_mask(vcpu->arch.wbinvd_dirty_mask,
> +		preempt_disable();
> +		smp_call_function_many(vcpu->arch.wbinvd_dirty_mask,
>  				wbinvd_ipi, NULL, 1);
> -		put_cpu();
> +		preempt_enable();
>  		cpumask_clear(vcpu->arch.wbinvd_dirty_mask);
> -	} else
> -		wbinvd();
> +	}
> +
> +	wbinvd();
>  	return X86EMUL_CONTINUE;
>  }
> 
> --
> 1.7.1


  reply	other threads:[~2021-10-22  4:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13  9:42 [PATCH][v2] KVM: x86: directly call wbinvd for local cpu when emulate wbinvd Li RongQing
2021-10-22  4:16 ` Li,Rongqing [this message]
2021-10-22  5:28   ` Nadav Amit
2021-10-22  6:18     ` 答复: " Li,Rongqing

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=4857464fb9684af8a485ce9eb790fd75@baidu.com \
    --to=lirongqing@baidu.com \
    --cc=kvm@vger.kernel.org \
    --cc=x86@kernel.org \
    /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