From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raghavendra K T Subject: Re: [PATCH RFC V5 3/3] kvm: Choose better candidate for directed yield Date: Wed, 18 Jul 2012 20:09:04 +0530 Message-ID: <5006CA88.8040906@linux.vnet.ibm.com> References: <20120718133717.5321.71347.sendpatchset@codeblue.in.ibm.com> <20120718133800.5321.51446.sendpatchset@codeblue.in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Raghavendra K T , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Marcelo Tosatti , Rik van Riel , Srikar , S390 , Carsten Otte , Christian Borntraeger , KVM , chegu vinod , "Andrew M. Theurer" , LKML , X86 , Gleb Natapov , linux390@de.ibm.com, Srivatsa Vaddagiri , Joerg Roedel To: Avi Kivity Return-path: Received: from e23smtp09.au.ibm.com ([202.81.31.142]:36307 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750863Ab2GROlk (ORCPT ); Wed, 18 Jul 2012 10:41:40 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Jul 2012 15:27:52 +1000 In-Reply-To: <20120718133800.5321.51446.sendpatchset@codeblue.in.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/18/2012 07:08 PM, Raghavendra K T wrote: > From: Raghavendra K T > +bool kvm_vcpu_eligible_for_directed_yield(struct kvm_vcpu *vcpu) > +{ > + bool eligible; > + > + eligible = !vcpu->spin_loop.in_spin_loop || > + (vcpu->spin_loop.in_spin_loop&& > + vcpu->spin_loop.dy_eligible); > + > + if (vcpu->spin_loop.in_spin_loop) > + vcpu->spin_loop.dy_eligible = !vcpu->spin_loop.dy_eligible; > + > + return eligible; > +} I should have added a comment like: Since algorithm is based on heuristics, accessing another vcpu data without locking does not harm. It may result in trying to yield to same VCPU, fail and continue with next and so on.