From mboxrd@z Thu Jan 1 00:00:00 1970 From: Waiman Long Subject: Re: [PATCH RFC v5 4/8] pvqspinlock, x86: Allow unfair spinlock in a real PV environment Date: Thu, 27 Feb 2014 14:40:13 -0500 Message-ID: <530F949D.6050609@hp.com> References: <1393427668-60228-1-git-send-email-Waiman.Long@hp.com> <1393427668-60228-5-git-send-email-Waiman.Long@hp.com> <530F2F7B.40500@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <530F2F7B.40500@citrix.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: David Vrabel Cc: Jeremy Fitzhardinge , Raghavendra K T , Peter Zijlstra , virtualization@lists.linux-foundation.org, Andi Kleen , "H. Peter Anvin" , Michel Lespinasse , Alok Kataria , linux-arch@vger.kernel.org, x86@kernel.org, Ingo Molnar , Scott J Norton , xen-devel@lists.xenproject.org, "Paul E. McKenney" , Alexander Fyodorov , Rik van Riel , Arnd Bergmann , Konrad Rzeszutek Wilk , Daniel J Blueman , Oleg Nesterov , Steven Rostedt , Chris Wright , George Spelvin , Thomas Gleixner List-Id: linux-arch.vger.kernel.org On 02/27/2014 07:28 AM, David Vrabel wrote: > On 26/02/14 15:14, Waiman Long wrote: >> Locking is always an issue in a virtualized environment as the virtual >> CPU that is waiting on a lock may get scheduled out and hence block >> any progress in lock acquisition even when the lock has been freed. >> >> One solution to this problem is to allow unfair lock in a >> para-virtualized environment. In this case, a new lock acquirer can >> come and steal the lock if the next-in-line CPU to get the lock is >> scheduled out. Unfair lock in a native environment is generally not a >> good idea as there is a possibility of lock starvation for a heavily >> contended lock. > I'm not sure I'm keen on losing the fairness in PV environment. I'm > concerned that on an over-committed host, the lock starvation problem > will be particularly bad. > > But I'll have to revist this once a non-broken PV qspinlock > implementation exists (or someone explains how the proposed one works). > > David On second thought, the unfair qspinlock may not be as bad as other unfair locks. Basically, a task gets one chance to steal the lock. If it can't, it will go to the back of the queue and wait for its turn. So unless a single CPU can monopolize a lock by acquiring it again immediately after release, all the tasks queuing up will eventually has its chance of getting the lock. -Longman