From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] [RESEND] KVM:VMX: Add support for Pause-Loop Exiting Date: Sun, 27 Sep 2009 10:31:21 +0200 Message-ID: <4ABF22D9.3040308@redhat.com> References: <4ABA2AD7.6080008@intel.com> <4ABA2C22.7020000@redhat.com> <20090925204339.GA29634@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: "Zhai, Edwin" , Ingo Molnar , "kvm@vger.kernel.org" To: Joerg Roedel Return-path: Received: from mx1.redhat.com ([209.132.183.28]:24545 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753488AbZI0Ibl (ORCPT ); Sun, 27 Sep 2009 04:31:41 -0400 In-Reply-To: <20090925204339.GA29634@8bytes.org> Sender: kvm-owner@vger.kernel.org List-ID: On 09/25/2009 11:43 PM, Joerg Roedel wrote: > On Wed, Sep 23, 2009 at 05:09:38PM +0300, Avi Kivity wrote: > >> We haven't sorted out what is the correct thing to do here. I think we >> should go for a directed yield, but until we have it, you can use >> hrtimers to sleep for 100 microseconds and hope the holding vcpu will >> get scheduled. Even if it doesn't, we're only wasting a few percent cpu >> time instead of spinning. >> > How do you plan to find out to which vcpu thread the current thread > should yield? > We can't find exactly which vcpu, but we can: - rule out threads that are not vcpus for this guest - rule out threads that are already running A major problem with sleep() is that it effectively reduces the vm priority relative to guests that don't have spinlock contention. By selecting a random nonrunnable vcpu belonging to this guest, we at least preserve the guest's timeslice. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.