From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755396AbbINJuP (ORCPT ); Mon, 14 Sep 2015 05:50:15 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:34898 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753096AbbINJuM (ORCPT ); Mon, 14 Sep 2015 05:50:12 -0400 Date: Mon, 14 Sep 2015 11:50:08 +0200 From: Ingo Molnar To: Thomas Gleixner Cc: Steven Rostedt , linux-kernel@vger.kernel.org, linux-rt-users , Carsten Emde , Sebastian Andrzej Siewior , John Kacur , Paul Gortmaker , Peter Zijlstra , Clark Williams , Arnaldo Carvalho de Melo Subject: Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack Message-ID: <20150914095008.GA31704@gmail.com> References: <20150904011900.730816481@goodmis.org> <20150905120457.GA21338@gmail.com> <20150908073116.GA6565@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Thomas Gleixner wrote: > > And if we are into getting reference counts, why not solve it at a higher > > level and get a reference count to 'x' to make sure it's safe to use? Then we > > could do: > > > > lock(y->lock); > > retry: > > x = y->x; > > if (!trylock(x->lock)) { > > get_ref(x->count) > > unlock(y->lock); > > lock(x->lock); > > lock(y->lock); > > put_ref(x->count); > > if (y->x != x) { /* Retry if 'x' got dropped meanwhile */ > > unlock(x->lock); > > goto retry; > > } > > } > > > > Or so. > > In the case of dcache::dentry_kill() we probably do not have to take refcounts > and it might be actually counterproductive to do so. y->x, i.e. dentry->parent, > cannot vanish under us, if I understand the life time rules correctly. Ok, that's even better. > Aside of that, yes, I was thinking about a similar scheme for that. I need some > more time to grok all the rules there :) Ok, great! :-) I really don't think we need a new locking primitive - and with something like the above we could improve the code upstream as well and make it scale better in some scenarios, right? Thanks, Ingo