kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Li,Rongqing" <lirongqing@baidu.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Sean Christopherson <seanjc@google.com>
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] KVM: X86: set vcpu preempted only if it is preempted
Date: Sun, 6 Feb 2022 11:23:23 +0000	[thread overview]
Message-ID: <f01888124ade425fb88c8f7e3a5c0f6f@baidu.com> (raw)
In-Reply-To: <20220112213129.GO16608@worktop.programming.kicks-ass.net>



> -----邮件原件-----
> 发件人: Peter Zijlstra <peterz@infradead.org>
> 发送时间: 2022年1月13日 5:31
> 收件人: Sean Christopherson <seanjc@google.com>
> 抄送: Li,Rongqing <lirongqing@baidu.com>; pbonzini@redhat.com;
> vkuznets@redhat.com; wanpengli@tencent.com; jmattson@google.com;
> tglx@linutronix.de; bp@alien8.de; x86@kernel.org; kvm@vger.kernel.org;
> joro@8bytes.org
> 主题: Re: [PATCH] KVM: X86: set vcpu preempted only if it is preempted
> 
> On Wed, Jan 12, 2022 at 05:30:47PM +0000, Sean Christopherson wrote:
> > On Wed, Jan 12, 2022, Peter Zijlstra wrote:
> > > On Wed, Jan 12, 2022 at 08:02:01PM +0800, Li RongQing wrote:
> > > > vcpu can schedule out when run halt instruction, and set itself to
> > > > INTERRUPTIBLE and switch to idle thread, vcpu should not be set
> > > > preempted for this condition
> > >
> > > Uhhmm, why not? Who says the vcpu will run the moment it becomes
> > > runnable again? Another task could be woken up meanwhile occupying
> > > the real cpu.
> >
> > Hrm, but when emulating HLT, e.g. for an idling vCPU, KVM will
> > voluntarily schedule out the vCPU and mark it as preempted from the
> > guest's perspective.  The vast majority, probably all, usage of
> > steal_time.preempted expects it to truly mean "preempted" as opposed to
> "not running".
> 
> No, the original use-case was locking and that really cares about running.
> 
> If the vCPU isn't running, we must not busy-wait for it etc..
> 
> Similar to the scheduler use of it, if the vCPU isn't running, we should not
> consider it so. Getting the vCPU task scheduled back on the CPU can take a 'long'
> time.
> 
> If you have pinned vCPU threads and no overcommit, we have other knobs to
> indicate this I tihnk.


If vcpu is idle, and be marked as preempted, is it right in kvm_smp_send_call_func_ipi?

static void kvm_smp_send_call_func_ipi(const struct cpumask *mask)
{
    int cpu;

    native_send_call_func_ipi(mask);

    /* Make sure other vCPUs get a chance to run if they need to. */
    for_each_cpu(cpu, mask) {
        if (vcpu_is_preempted(cpu)) {
            kvm_hypercall1(KVM_HC_SCHED_YIELD, per_cpu(x86_cpu_to_apicid, cpu));
            break;
        }
    }
}


-Li 

  parent reply	other threads:[~2022-02-06 11:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 12:02 [PATCH] KVM: X86: set vcpu preempted only if it is preempted Li RongQing
2022-01-12 13:08 ` Peter Zijlstra
2022-01-12 17:30   ` Sean Christopherson
2022-01-12 18:44     ` Paolo Bonzini
2022-01-12 19:07       ` Sean Christopherson
2022-01-12 21:31     ` Peter Zijlstra
2022-01-13  4:52       ` 答复: " Li,Rongqing
2022-01-13  9:33         ` Peter Zijlstra
2022-01-13 11:55           ` 答复: " Li,Rongqing
2022-01-13 12:48         ` Wanpeng Li
2022-01-14  9:58           ` 答复: " Li,Rongqing
2022-01-13 16:34       ` Sean Christopherson
2022-02-06 11:23       ` Li,Rongqing [this message]
2022-02-06 13:42       ` 答复: " 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=f01888124ade425fb88c8f7e3a5c0f6f@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;
as well as URLs for NNTP newsgroup(s).