From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933075AbaFJUNi (ORCPT ); Tue, 10 Jun 2014 16:13:38 -0400 Received: from www.linutronix.de ([62.245.132.108]:55140 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755359AbaFJUN1 (ORCPT ); Tue, 10 Jun 2014 16:13:27 -0400 Date: Tue, 10 Jun 2014 22:13:20 +0200 (CEST) From: Thomas Gleixner To: Steven Rostedt cc: Oleg Nesterov , Linus Torvalds , "Paul E. McKenney" , LKML , Peter Zijlstra , Andrew Morton , Ingo Molnar , Clark Williams Subject: Re: safety of *mutex_unlock() (Was: [BUG] signal: sighand unprotected when accessed by /proc) In-Reply-To: Message-ID: References: <20140603200125.GB1105@redhat.com> <20140606203350.GU4581@linux.vnet.ibm.com> <20140608130718.GA11129@redhat.com> <20140609162613.GE4581@linux.vnet.ibm.com> <20140609181553.GA13681@redhat.com> <20140609142956.3d79e9d1@gandalf.local.home> <20140609154114.20585056@gandalf.local.home> <20140610165704.GA3110@redhat.com> <20140610141306.04a4bcf3@gandalf.local.home> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Jun 2014, Thomas Gleixner wrote: > On Tue, 10 Jun 2014, Steven Rostedt wrote: > > On Tue, 10 Jun 2014 20:08:37 +0200 (CEST) > > Thomas Gleixner wrote: > > > > > > > > Perhaps it could simply do ->owner = RT_MUTEX_HAS_WAITERS to make this more > > > > clear... > > > > > > Good point. The new owner can cleanup the mess. > > > > > > > I thought about this too. It should work with the added overhead that > > every time we go into the unlock slow path, we guarantee that the next > > lock will go into the lock slowpath. > > > > As long as the new acquired lock does a fast unlock, then we get out of > > this spiral. > > The alternative solution is to document WHY this is safe. I think I > prefer that one :) And actually we keep the waiter bit set in wakeup_next_waiter() because we only dequeue the waiter from the lock owners pi waiter list, but not from the lock waiter list. rt_mutex_set_owner() sets the waiters bit if the lock has waiters. I agree with Oleg that this is not obvious from the code. So I add both a comment and open code it. Thanks, tglx