From: "Li,Rongqing" <lirongqing@baidu.com>
To: Sean Christopherson <seanjc@google.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>,
"wanpengli@tencent.com" <wanpengli@tencent.com>,
"jmattson@google.com" <jmattson@google.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"bp@alien8.de" <bp@alien8.de>, "x86@kernel.org" <x86@kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"joro@8bytes.org" <joro@8bytes.org>
Subject: 答复: [PATCH][v3] KVM: x86: refine kvm_vcpu_is_preempted
Date: Sun, 6 Feb 2022 11:26:07 +0000 [thread overview]
Message-ID: <3ca3f4b132f14d079de706310ee393cf@baidu.com> (raw)
In-Reply-To: <Yfq19FSnASMfd0BH@google.com>
> On Wed, Feb 02, 2022, Peter Zijlstra wrote:
> > On Mon, Jan 17, 2022 at 01:37:22PM +0800, Li RongQing wrote:
> > > After support paravirtualized TLB shootdowns, steal_time.preempted
> > > includes not only KVM_VCPU_PREEMPTED, but also KVM_VCPU_FLUSH_TLB
> > >
> > > and kvm_vcpu_is_preempted should test only with KVM_VCPU_PREEMPTED
> >
> > This still fails to actually explain what the problem is, why did you
> > write this patch?
>
> Ya, definitely is lacking details. I think this captures everything...
>
> Tweak the assembly code for detecting KVM_VCPU_PREEMPTED to future
> proof
> it against new features, code refactorings, and theoretical compiler
> behavior.
>
> Explicitly test only the KVM_VCPU_PREEMPTED flag; steal_time.preempted
> has already been overloaded once for KVM_VCPU_FLUSH_TLB, and checking
> the
> entire byte for a non-zero value could yield a false positive. This
> currently isn't problematic as PREEMPTED and FLUSH_TLB are mutually
> exclusive, but that may not hold true for future flags.
>
> Use AND instead of TEST for querying PREEMPTED to clear RAX[63:8] before
> returning to avoid a potential false postive in the caller due to leaving
> the address (non-zero value) in the upper bits. Compilers are technically
> allowed to use more than a byte for storing _Bool, and it would be all too
> easy for someone to refactor the return type to something larger.
>
> Keep the SETcc (but change it to setnz for sanity's sake) as the fact that
> KVM_VCPU_PREEMPTED happens to be bit 0, i.e. the AND will yield 0/1 as
> needed for _Bool, is pure coincidence.
> cpu_is_preempted;"
Sean:
Could you resubmit this patch, thanks
-Li
prev parent reply other threads:[~2022-02-06 11:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 5:37 [PATCH][v3] KVM: x86: refine kvm_vcpu_is_preempted Li RongQing
2022-02-02 14:54 ` Peter Zijlstra
2022-02-02 16:48 ` Sean Christopherson
2022-02-02 22:17 ` Peter Zijlstra
2022-02-06 11:26 ` Li,Rongqing [this message]
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=3ca3f4b132f14d079de706310ee393cf@baidu.com \
--to=lirongqing@baidu.com \
--cc=bp@alien8.de \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--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