From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751820AbbCGSS2 (ORCPT ); Sat, 7 Mar 2015 13:18:28 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:35703 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750802AbbCGSSZ (ORCPT ); Sat, 7 Mar 2015 13:18:25 -0500 Message-ID: <54FB40BE.1070309@oracle.com> Date: Sat, 07 Mar 2015 13:17:34 -0500 From: Sasha Levin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Jason Low , Linus Torvalds , Ingo Molnar , Peter Zijlstra CC: Davidlohr Bueso , Tim Chen , "Paul E. McKenney" , Michel Lespinasse , LKML , Dave Jones , Ming Lei Subject: Re: [PATCH] locking/rwsem: Fix lock optimistic spinning when owner is not running References: <1425714331.2475.388.camel@j-VirtualBox> In-Reply-To: <1425714331.2475.388.camel@j-VirtualBox> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/07/2015 02:45 AM, Jason Low wrote: > Fixes tip commit b3fd4f03ca0b (locking/rwsem: Avoid deceiving lock spinners). > > Ming reported soft lockups occurring when running xfstest due to > commit b3fd4f03ca0b. > > When doing optimistic spinning in rwsem, threads should stop spinning when > the lock owner is not running. While a thread is spinning on owner, if > the owner reschedules, owner->on_cpu returns false and we stop spinning. > > However, commit b3fd4f03ca0b essentially caused the check to get ignored > because when we break out of the spin loop due to !on_cpu, we continue > spinning if sem->owner != NULL. > > This patch fixes this by making sure we stop spinning if the owner is not > running. Furthermore, just like with mutexes, refactor the code such that > we don't have separate checks for owner_running(). This makes it more > straightforward in terms of why we exit the spin on owner loop and we > would also avoid needing to "guess" why we broke out of the loop to make > this more readable. That seems to solve the hangs I'm seeing as well. Thanks, Sasha