From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932599AbcHJWJV (ORCPT ); Wed, 10 Aug 2016 18:09:21 -0400 Received: from g1t6216.austin.hp.com ([15.73.96.123]:38876 "EHLO g1t6216.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932392AbcHJWJU (ORCPT ); Wed, 10 Aug 2016 18:09:20 -0400 Message-ID: <1470866872.17361.14.camel@j-VirtualBox> Subject: Re: [PATCH v2] locking/mutex: Prevent lock starvation when spinning is enabled From: Jason Low To: Peter Zijlstra Cc: jason.low2@hpe.com, Ingo Molnar , imre.deak@intel.com, linux-kernel@vger.kernel.org, Waiman Long , Davidlohr Bueso , Tim Chen , terry.rudd@hpe.com, "Paul E. McKenney" Date: Wed, 10 Aug 2016 15:07:52 -0700 In-Reply-To: <1470854648.17361.9.camel@j-VirtualBox> References: <1470854648.17361.9.camel@j-VirtualBox> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2016-08-10 at 11:44 -0700, Jason Low wrote: > Imre reported an issue where threads are getting starved when trying > to acquire a mutex. Threads acquiring a mutex can get arbitrarily delayed > sleeping on a mutex because other threads can continually steal the lock > in the fastpath and/or through optimistic spinning. > > Waiman has developed patches that allow waiters to return to optimistic > spinning, thus reducing the probability that starvation occurs. However, > Imre still sees this starvation problem in the workloads when optimistic > spinning is disabled. > > This patch adds an additional boolean to the mutex that gets used in > the CONFIG_SMP && !CONFIG_MUTEX_SPIN_ON_OWNER cases. The flag signifies > whether or not other threads need to yield to a waiter and gets set > when a waiter spends too much time waiting for the mutex. The threshold > is currently set to 16 wakeups, and once the wakeup threshold is exceeded, > other threads must yield to the top waiter. The flag gets cleared > immediately after the top waiter acquires the mutex. Just noticed that the patch title mentions "when spinning is enabled". The title should really be: "locking/mutex: Prevent lock starvation when spinning is disabled"