Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753430Ab0HBPIQ (ORCPT ); Mon, 2 Aug 2010 11:08:16 -0400 Received: from claw.goop.org ([74.207.240.146]:55733 "EHLO claw.goop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215Ab0HBPIO (ORCPT ); Mon, 2 Aug 2010 11:08:14 -0400 Message-ID: <4C56DF5D.807@goop.org> Date: Mon, 02 Aug 2010 08:08:13 -0700 From: Jeremy Fitzhardinge User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Lightning/1.0b2pre Thunderbird/3.1.1 MIME-Version: 1.0 To: Avi Kivity CC: vatsa@linux.vnet.ibm.com, Marcelo Tosatti , Gleb Natapov , linux-kernel@vger.kernel.org, npiggin@suse.de, kvm@vger.kernel.org, bharata@in.ibm.com, Balbir Singh , Jan Beulich Subject: Re: [PATCH RFC 2/4] Add yield hypercall for KVM guests References: <20100726061150.GB21699@linux.vnet.ibm.com> <20100726061445.GB8402@linux.vnet.ibm.com> <4C4DC3AD.7010404@goop.org> <4C5682A3.40409@redhat.com> In-Reply-To: <4C5682A3.40409@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1311 Lines: 29 On 08/02/2010 01:32 AM, Avi Kivity wrote: > On 07/26/2010 08:19 PM, Jeremy Fitzhardinge wrote: >> On 07/25/2010 11:14 PM, Srivatsa Vaddagiri wrote: >>> Add KVM hypercall for yielding vcpu timeslice. >> >> Can you do a directed yield? >> > > A problem with directed yield is figuring out who to yield to. One > idea is to look for a random vcpu that is not running and donate some > runtime to it. In the best case, it's the lock holder and we cause it > to start running. Middle case it's not the lock holder, but we lose > enough runtime to stop running, so at least we don't waste cpu. Worst > case we continue running not having woken the lock holder. Spin > again, yield again hoping to find the right vcpu. That can help with lockholder preemption, but on unlock you need to wake up exactly the right vcpu - the next in the ticket queue - in order to avoid burning masses of cpu. If each cpu records what lock it is spinning on and what its ticket is in a percpu variable, then the unlocker can search for the next person to kick. J -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/