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 Return-path: In-Reply-To: <20120718133800.5321.51446.sendpatchset@codeblue.in.ibm.com> Sender: kvm-owner@vger.kernel.org List-Archive: List-Post: To: Avi Kivity 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 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.