Received: by 10.223.185.116 with SMTP id b49csp2079886wrg; Thu, 22 Feb 2018 07:52:47 -0800 (PST) X-Google-Smtp-Source: AH8x225OXHftPwEjUFxmJeriJdQ5/RFtCsY+gyPf0bdn+EY0v7mKRBmMGfb0qeZQeMBPqUzN2tdv X-Received: by 10.99.114.86 with SMTP id c22mr1361450pgn.162.1519314767501; Thu, 22 Feb 2018 07:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519314767; cv=none; d=google.com; s=arc-20160816; b=HHHKU2cK1t5KHbSW8DoXdp/EoZgPBKVhhO375LG77d7xPtlQrwpoLGei2MxXVmO3gD gM00ljsBhrnQiMdKoBMToVg2q1aQGsgl2Lg4U4YBugWYKN1CyHVOMsvRIrt4mKbX8gv4 YCfLAyk8xmcLrAhVIlf10U+IzfrV1zOxzG9wdn/A4zu6FCdFzqiXSu5cLU2ynkHkgXM/ ZuWhRnAYGIV+kpcsXYo0eXP3KkRe+Y8C6g9xl5XAwRpzWQZ9xLscTgaMTAcOHaSFYuj3 Oumjd7a59wEWXZaVfEC5wwJY6yavNCUSu7BeUdt1dC15KAXFt6JtpX6n8kj6+mkuOlfG 3afw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=ClA3YBr7ec31bDGdv49GZ5vDzon0d94YweJkiNk2lZ4=; b=yJ8NZj84nLELMjwGPBGigCJN10t/pcgSR/sHQqlHlcpSUcGxFw4OJCyUy569V0kHR3 3dPe3inPhjti7mZeAgcQb/dXIy8E6bLdQUTecNSZIamgpDBd8ksudITpaslszqx8D2s5 ULV9bxQakyFpnu0lBTyD72iR1q6zw9j1r+rVOD8wkTabc7r3ghV93VW1jw1zvTDGE/ZF UOG8O0UNNHwzmSGmGzg0e3F3dbbJ6dujmL/lffvBQLSjHPLysZXxM9a3HbQnH8/D7gyD xC4yGssFz+RXhtuOjpDcIMSvuADC/xu9/KZHG1X1xk/98htwBESD35bTbh1x/TR6AqJw GdRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Df6JTjmE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10si158745pgd.302.2018.02.22.07.52.31; Thu, 22 Feb 2018 07:52:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Df6JTjmE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933085AbeBVPvs (ORCPT + 99 others); Thu, 22 Feb 2018 10:51:48 -0500 Received: from merlin.infradead.org ([205.233.59.134]:54796 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933002AbeBVPvr (ORCPT ); Thu, 22 Feb 2018 10:51:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ClA3YBr7ec31bDGdv49GZ5vDzon0d94YweJkiNk2lZ4=; b=Df6JTjmEwSQom9z35K94nGvst H2LQR1FByrWDNuMZfhMDB9Lp27kMXbJabWxqk8NvMUpUTapraXE9P2vG+Ronwc9SQLrcT3cNiQkkD KpohThJ0kqDDST2fgsAwN1hdAGsLTxGerEFIRPH5emco0S80o6yu76R2tW/uMpH/174Waw6N7H4Yq ldn11UrXSayAJmho3uQhpImY2qvU1C3YWRmgY0GvEYwCzkiOTCwZtdhkwCMZ/JQM9SHJy5fx/f6Cc aoGIHLXjA8hM19UG4xwJjNWcCPVfdEFeL4NwPFmQ29ba4sGPVasM/JeAJdRiDKFN04GOfcMkxvbUD ecMzCK9qw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eot9t-00077v-KZ; Thu, 22 Feb 2018 15:51:45 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1DB742029F9F9; Thu, 22 Feb 2018 16:51:43 +0100 (CET) Date: Thu, 22 Feb 2018 16:51:43 +0100 From: Peter Zijlstra To: Boqun Feng Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Andrea Parri Subject: Re: [RFC tip/locking/lockdep v5 05/17] lockdep: Extend __bfs() to work with multiple kinds of dependencies Message-ID: <20180222155143.GV25235@hirez.programming.kicks-ass.net> References: <20180222070904.548-1-boqun.feng@gmail.com> <20180222070904.548-6-boqun.feng@gmail.com> <20180222142614.GR25201@hirez.programming.kicks-ass.net> <20180222151210.jwxjchywk4jfecyf@tardis> <20180222153034.GO25181@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180222153034.GO25181@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 22, 2018 at 04:30:34PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 11:12:10PM +0800, Boqun Feng wrote: > > On Thu, Feb 22, 2018 at 03:26:14PM +0100, Peter Zijlstra wrote: > > > > However, I would suggest: > > > > > > static inline bool is_xr(u16 dep) > > > { > > > return !!(dep & (DEP_NR_MASK | DEP_RR_MASK)); > > > } > > > > > > static inline bool is_rx(u16 dep) > > > { > > > return !!(dep & (DEP_RN_MASK | DEP_RR_MASK)); > > > } > > > > > > /* Skip *R -> R* relations */ > > > if (have_xr && is_rx(entry->dep)) > > > continue; > > > > I don't think this works, if we pick a *R for previous entry, and for > > current entry, we have RR, NN and NR, your approach will skip the > > current entry, but actually we can pick NN or NR (of course, in __bfs(), > > we can greedily pick NN, because if NR causes a deadlock, so does NN). > > I don't get it, afaict my suggestion is identical. > > You skip condition: pick_dep() < 0, evaluates to: > > is_rr && (!NN_MASK && !NR_MASK) := > is_rr && (RN_MASK | RR_MASK) > > Which is exactly what I have. Ooh, I think I see what I did wrong, would something like: if (have_xr && !is_nx(entry-dep)) work? That's a lot harder to argue about though, still much better than that tri-state pick thing. > If that is satisfied, you set entry->is_rr to pick_dep(), which his > harder to evaluate, but is something like: > > is_rr && NR_MASK || !(NN_MASK | RN_MASK) := > is_rr && NR_MASK || (NR_MASK | RR_MASK) := > (NR_MASK | RR_MASK) > > (because is_rr && RR_MASK will have been skipped) > > > > > > > entry->have_xr = is_xr(entry->dep); This one I think is still correct though.