Received: by 10.223.185.116 with SMTP id b49csp2041574wrg; Thu, 22 Feb 2018 07:18:07 -0800 (PST) X-Google-Smtp-Source: AH8x225iG+K6DCwFozAiMK/zGK3ZEYaBsbf9nm4Mh4UjLHIq+pKTko+i5Ctynfkw8s3ntXI5sCYw X-Received: by 2002:a17:902:a585:: with SMTP id az5-v6mr6952157plb.167.1519312687231; Thu, 22 Feb 2018 07:18:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519312687; cv=none; d=google.com; s=arc-20160816; b=Z+qYl+dt0q4GUAKRTwNt+eYBxYE5CJXCxpUWSCuu+LzagrYd8hruQbHvN9WiZwOSW0 34mmHFkstK+U2RIRClgAe3GyvFK9t5NnihWmA+OVzMPDatDOslBMFDvSJmU1x3JCLH5Y Yj0M0Ai6nuIufoUBHxGq5nCVk89k5fWXZv8rWISH13GnQIvxeZnLOWRIincXQ9Jubp+g WucjdaHlzz1KrqV+pmG1TMfk5qSiAyw8X1cy2yhw5WwywRACnTdPgizOXGq5MW2AY+xc d4qC0HD6fJ4qzxzNW+g8yEvBjCU/Q+3mHxMAT+xoCMKkuPSaTObbqb5yKIScImdyxoHW tnvQ== 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=xE2brwiSTCzEg1TW5vG1u17XSx+byQuAUVMAZrYYhyY=; b=J9UdLDHFqFGzRBSR1E8UybCGj/GeSZ5Eom9QFJc95K3LD6/XprCBje2mUhtqR7uWDK 0zXZuAor/7oCGYBFN8Mo2NKEPomtcEkA+TW8soJMI/76y1DXhh4GPwC8vL7YE9pBuPmY WuXj87jzhjnA5+nElwrVEb+EtY0f6irQe4dtbPOS/v1Y/dbcT+ZCPTRqOkFYn0S0EvhK xmXNsqTS+S4n+8/t8fluB/9TsWLMEF5LxfzYNnSTVP2Ahn5fKwKV3EzRXssshBeQRm8L 1RAUQjYONxWBtt3wRmjHB903QYdjRqS0xAnhD4tIAhDWZorGoDYtVjd3qeUf4E7mdX2K Ru/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Fl8HLPdJ; 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 v22si194684pfd.22.2018.02.22.07.17.46; Thu, 22 Feb 2018 07:18:07 -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=Fl8HLPdJ; 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 S933103AbeBVPQa (ORCPT + 99 others); Thu, 22 Feb 2018 10:16:30 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:56780 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932869AbeBVPQ3 (ORCPT ); Thu, 22 Feb 2018 10:16:29 -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=xE2brwiSTCzEg1TW5vG1u17XSx+byQuAUVMAZrYYhyY=; b=Fl8HLPdJGwEjZygRPUP4YmL3k U4SWSRYWWc89M65BkMcOrx2SR3EmJTrR1Lj6/CO+7pjVdAtMVngvVgfnZ3WZV+ZiXyjrMqPN3WQsX HmePfMLtKjnHhxyPBHfHEUWNT+JU0SoC8012JAEzTpIIByzElpPIYV1gGM/1IpHw9FDdP3mGXFb2f GkdAEcGPduhOueHsbPV2Qg9y7akpM7ECSbxXS9LZIlxpOh+eBwUpdZ3WCIHnyMGQYRDVsg9Cc2N1d CgBuTjfPd8aEYnPlW97D+o2JPIHo3o6z0Iyeu97U7KSXp37E2jRkKpR3FFQA6oh7nPluPkLXR21xo K6FIuMoHA==; 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 1eosbj-0003ZO-V6; Thu, 22 Feb 2018 15:16:28 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 349772029F9F9; Thu, 22 Feb 2018 16:16:26 +0100 (CET) Date: Thu, 22 Feb 2018 16:16:26 +0100 From: Peter Zijlstra To: Boqun Feng Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Andrea Parri Subject: Re: [RFC tip/locking/lockdep v5 06/17] lockdep: Support deadlock detection for recursive read in check_noncircular() Message-ID: <20180222151626.GU25235@hirez.programming.kicks-ass.net> References: <20180222070904.548-1-boqun.feng@gmail.com> <20180222070904.548-7-boqun.feng@gmail.com> <20180222145434.GS25201@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180222145434.GS25201@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 03:54:34PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 03:08:53PM +0800, Boqun Feng wrote: > > > +static inline int hlock_conflict(struct lock_list *entry, void *data) > > +{ > > + struct held_lock *hlock = (struct held_lock *)data; > > + > > + return hlock_class(hlock) == entry->class && > > + (hlock->read != 2 || !entry->is_rr); > > +} > > Bah, brain hurts. > > So before we add prev -> this, relation, we check if there's a this -> > prev relation already in the graph -- if so that would be a problem. > > The above function has @data == @prev (__bfs_forward starts at @this, > looking for @prev), and the above patch augments the 'class_equal' test > with @prev not having read==2 or @entry not having xr; > > This is because.... (insert brain hurt) (hlock->read != 2 || !entry->have_xr) := !(hlock->read == 2 && entry->have_xr) hlock->read == 2 := prev->read == 2 entry->have_xr means the last fwd link has read==2. Together this gives that: @prev (Rx) ---> X ---> @entry (xR) does not form a cycle, because: @enrty (xR) -> @prev (Rx) is not strong and can be ignored. Did I get that right? If so, the Changelog needs serious help and code does too.