Received: by 10.223.185.116 with SMTP id b49csp2059247wrg; Thu, 22 Feb 2018 07:33:40 -0800 (PST) X-Google-Smtp-Source: AH8x227Hq9KKZ9e7R44yu6Ps3C6zZeEbGtMd1JwHf+A0N87PtqrhZi/f2aUyXxGY3sW4xA/X4LRy X-Received: by 10.99.123.12 with SMTP id w12mr5776217pgc.405.1519313620081; Thu, 22 Feb 2018 07:33:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519313620; cv=none; d=google.com; s=arc-20160816; b=QdLF0KidJQP9jT+MoBN1f9Wmjk3B1vuTFpcTrq0Hw+REGlMgVzQL3AHu2VyhRLXOAd CnppusNdfAlcRYLyFHajHC0w/4E5TDuFy1L6qn/XgG+uulh0RsU8qzpQQ9V2NgSr7CSD iT2xqTuC+HrpCqEDePIR2T8ljiuYPpipe1kUPjrhRv2GClExRpFDWkVfqiiyNRNZvNOg y/ULhEmLRlG0lEs69yrjVX+qiHnlTKwsZmcyXdxyWGdajKuhQvvqkE1p5tDqKdyBFB8L MEl0MYIyDh/lzWxlBFiKgwcRHkAYtI5++3N9j0vAkD2kStuQQ0Fc5S8ZS9VQS4Uyszm3 hjcQ== 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=3IaNLk/iH3uJkSpe5z2xVGOca7TW+DMbQ+mMH6QDmZc=; b=jiTW38SOO/IWSQ78m3ZKHwIs3Ifw4bN+mvW9j/8WSV3bxy7WqGqMC3rrjLLNsBVM57 GtWlpVwVJUaoS8mGDBqiGv3VY5sp8IOX8qz8qKyrIugiuS/CUuJGFmjIOiytL+vjc2ap Yeq2ckV9Kr8LBlwkC9u98K8Kpr4N/V4W/nL+6NO8a7rkuMPPYmiiK8P+Cdo2L1dsenNr GQhucGh6kAj0j/ReIv0D5jKDyVjcj7eaHNNh4qdn3uKFkfPv8rzsbp8WwjtkbtDqq4FU gLRB65fZc6a5/kJ4O921qVr+TPWLabHQTg1azAScn678xrjDFnkDXowIHPiXXZJkpyMU KjUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=VsNPzvMt; 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 e1si147052pgs.425.2018.02.22.07.33.23; Thu, 22 Feb 2018 07:33:40 -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=bombadil.20170209 header.b=VsNPzvMt; 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 S933028AbeBVPan (ORCPT + 99 others); Thu, 22 Feb 2018 10:30:43 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:45994 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932942AbeBVPal (ORCPT ); Thu, 22 Feb 2018 10:30:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=3IaNLk/iH3uJkSpe5z2xVGOca7TW+DMbQ+mMH6QDmZc=; b=VsNPzvMt2nqg51RYDaWPFFlwB EEXDH1eDNiJP6VLg+RSy2ccYogWWKrwNbZ1SJ8QEQWsEy7OWCBJigsvOvZ6aGxMUbfuWnm/ooZfQs Zv0EChiOtplN/NlciFdJaeQHNVsVk8QlDlzhffVNS5lgjogvjLQ9MFnBbDnPhLbyQs3MTzILXrrTO B2mEkrDt628jMs6x49wtNVZmiSW4GHANdouj8wB9ggACPKA+eAIPcCIDO7jAsmQlcDmX+ay8uI5Ot fBCZVE+rHQAge+q95VNttFYb65z9KIxOCq5DAXhjkDlF3i3vgHLaAvH/HReCY1Dw3GV9zQ+WMq9Iy PBcqC3xag==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eospQ-00030J-Uh; Thu, 22 Feb 2018 15:30:37 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4328D202A062D; Thu, 22 Feb 2018 16:30:34 +0100 (CET) Date: Thu, 22 Feb 2018 16:30:34 +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: <20180222153034.GO25181@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180222151210.jwxjchywk4jfecyf@tardis> 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 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)); > > } > > > > > > > @@ -1095,11 +1179,18 @@ static enum bfs_result __bfs(struct lock_list *source_entry, > > > else > > > head = &lock->class->locks_before; > > > > > > + is_rr = lock->is_rr; > > > + > > > DEBUG_LOCKS_WARN_ON(!irqs_disabled()); > > > > > > list_for_each_entry_rcu(entry, head, entry) { > > > unsigned int cq_depth; > > > > > > + next_is_rr = pick_dep(is_rr, entry->dep); > > > + if (next_is_rr < 0) > > > + continue; > > > + entry->is_rr = next_is_rr; > > > > /* 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. 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); > > > > Which to me is a much simpler construct, hmm?