From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753439AbbBYMQd (ORCPT ); Wed, 25 Feb 2015 07:16:33 -0500 Received: from www.linutronix.de ([62.245.132.108]:42997 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752995AbbBYMQQ (ORCPT ); Wed, 25 Feb 2015 07:16:16 -0500 Message-ID: <54EDBCFD.5030307@linutronix.de> Date: Wed, 25 Feb 2015 13:15:57 +0100 From: Sebastian Andrzej Siewior User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0 MIME-Version: 1.0 To: Steven Rostedt CC: linux-kernel@vger.kernel.org, linux-rt-users , Thomas Gleixner , Carsten Emde , John Kacur , Paul Gortmaker , Peter Zijlstra , "H. Peter Anvin" Subject: Re: [PATCH RT 1/2] rwsem-rt: Do not allow readers to nest References: <20140409024700.702797305@goodmis.org> <20140409025231.998774075@goodmis.org> <20150218195710.GH28763@linutronix.de> <20150218151352.2968cf06@grimm.local.home> In-Reply-To: <20150218151352.2968cf06@grimm.local.home> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit 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 02/18/2015 09:13 PM, Steven Rostedt wrote: >> Here the same thing but without cmpxchg(). _If_ after an increment the >> value is negative then we take slowpath. Otherwise we have the lock. > > OK, so I need to make it so it can nest with trylock. I have to look at > the patch again because it has been a while. I have reverted the patch and can confirm that cpufreq works again. I did some testing on vanilla and -RT: - down_read(l) + down_read(l) this triggers a lockdep warning about a possible deadlock the lock is obtained. - down_read(l) + down_read_trylock() this passes without a warning. So I think we good now. > An RW sem must not do two down_read()s on the same lock (it's fine for > a trylock if it has a fail safe for it). The reason is, the second > down_read() will block if there's a writer waiting. Thus you are > guaranteed a deadlock if you have the lock for read, a write comes in > and waits, and you grab the RW sem again, because it will block, and > the writer is waiting for the reader to release. Thus you have a > deadlock. I fully understand. However nesting is allowed according to the code in vanilla and now again in -RT. Lockdep complains properly so we should catch people doing it wrong in both trees. > I'll have to revisit this. I also need to revisit the multi readers > (although Thomas hates it, but he even admitted there's a better way to > do it. Now only if I could remember what that was ;-) Okay. For now I keep the revert since it looks sane and simple. > > Thanks, > > -- Steve Sebastian