From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752499AbcHHR3x (ORCPT ); Mon, 8 Aug 2016 13:29:53 -0400 Received: from merlin.infradead.org ([205.233.59.134]:56678 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752313AbcHHR3v (ORCPT ); Mon, 8 Aug 2016 13:29:51 -0400 Date: Mon, 8 Aug 2016 19:29:38 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Linus Torvalds , Ding Tianhong , Jason Low , Davidlohr Bueso , "Paul E. McKenney" , Thomas Gleixner , Will Deacon , Tim Chen , Imre Deak Subject: Re: [PATCH v4 2/3] locking/mutex: Enable optimistic spinning of woken task in wait queue Message-ID: <20160808172938.GY6862@twins.programming.kicks-ass.net> References: <1468874366-56955-1-git-send-email-Waiman.Long@hpe.com> <1468874366-56955-3-git-send-email-Waiman.Long@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1468874366-56955-3-git-send-email-Waiman.Long@hpe.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 18, 2016 at 04:39:25PM -0400, Waiman Long wrote: > Ding Tianhong reported a live-lock situation where a constant stream > of incoming optimistic spinners blocked a task in the wait list from > getting the mutex. > > This patch attempts to fix this live-lock condition by enabling the > woken task in the wait queue to enter into an optimistic spinning > loop itself in parallel with the regular spinners in the OSQ. This > should prevent the live-lock condition from happening. No, two spinners are not in fact starvation proof. It makes the reported life-lock scenario much less likely, but it does not guarantee anything. > + /* > + * Optimistically spinning on the mutex without the wait lock There should either be a '.' at the end of that line, or the next line should not start with a capital. Also, I don't see how the two sentences are related, should they be in the same paragraph? > + * The state has to be set to running to avoid another waker > + * spinning on the on_cpu flag while the woken waiter is > + * spinning on the mutex. > + */ > + acquired = mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, > + true); > spin_lock_mutex(&lock->wait_lock, flags); > } > __set_task_state(task, TASK_RUNNING);