Received: by 10.223.185.116 with SMTP id b49csp2207469wrg; Thu, 22 Feb 2018 09:47:58 -0800 (PST) X-Google-Smtp-Source: AH8x225PEJXcXZiGirCYj2Y2cxBZHQ2xkv7xeGU+OJOkh5hVHL7FOVnGKGeHKWgqgGqZ4XhxRUm6 X-Received: by 2002:a17:902:1:: with SMTP id 1-v6mr7337080pla.187.1519321678569; Thu, 22 Feb 2018 09:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519321678; cv=none; d=google.com; s=arc-20160816; b=ZoZgz9fmJFIzUYkfPD9kP2bJrPdg0uLLmScmBCg31JPjV3DpBLdS4K/HHdRL1SRoSl L2Flbjy7dyk/WTw+ifTy0sMule7/3AqQuGKgFSH++AKu6Efap6SHVxQorOhdk86XoGnS Ikq1bz6VEq/hHjLgtv5qsawLN8XHHHeQ3OC/W+oZ0b5kSIlnSQaksySWo70stYpd8LTk Ry1SO6Nw2p0O+zEdelYc5dZhwB2fsjbI42ZPO8ijalKRT+iFxi1PLzTDLdCTZpJ/E0h0 PzP13wnDeOyPQnKl6dlgseSVP0fB5Zevphw+z+GxwjRb1px6zlrOi+Gwcn0NzQdvxdjg EjxQ== 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=ebtCXWWrLM7yv/25s/YuL1WKtZjVctWs8UyJgK5x4rU=; b=0v2GvzP3EXIS9YObXFVrmkGFHIzPqYYldKeYglU+wiX1XGmJyNQUlGfPc6IDiBPZmm I0alWijRx/5kmUClnr2HRzanfABs6Re1HezN/Pcsf5CvSU2jmUviqcRLq2E3XNwVHRYz Vhm2DURJSraRVkSoWF4mJKibP8hwrVW14oqk+t5EQHDR+6ZWbHjpQBA+aXBpX7T/HIY1 3QeasNDLsCyf918tn5aLAPe1kzLYhltL4me267U3BmQgAj0mkwFR7aXG+p2XlYXo+7Rp uiPholqfMuRavA0ePt1rI6V02Uq6bazCfOL/L6xPtpR7HX3kLASnTrEdpUa3tGIDRCGF /h6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZwXOYLdb; 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 m39-v6si332652plg.151.2018.02.22.09.47.43; Thu, 22 Feb 2018 09:47:58 -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=ZwXOYLdb; 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 S933562AbeBVRrD (ORCPT + 99 others); Thu, 22 Feb 2018 12:47:03 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:54100 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933498AbeBVRrB (ORCPT ); Thu, 22 Feb 2018 12:47:01 -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=ebtCXWWrLM7yv/25s/YuL1WKtZjVctWs8UyJgK5x4rU=; b=ZwXOYLdbMTdZoRI/LSDd3x6ig hi6BrKBh03mg1F0JrBvXh2trclmqGZ6RfTWmTGGnpDWIxdbw7fu7sgrfxfdBYvEN0jLMghvNUBBCB sBa2Pk5ainUGMLY/LHEXUGvcAtYj5OsJmkYlBFH7AVrrOBPGGbVu9n5Yqw9feq6MBU/NII5+lzusl 3aT9DQb2EwVT3BApyeOt6cjbW+HryS3YN26sk9xkxy5VMDLQsxCu4XWYnCgLl7R9xsrbDuSemiPVS yuKaFJONrUs4ITAAbZg+bxMpkgUJLStQSY6Hqd14GA7dpMph3GKb0+cR58AUznKukkKNWhc9NeRso o4GQBDwsQ==; 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 1eouxN-00067r-Ck; Thu, 22 Feb 2018 17:46:57 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E251D202A062D; Thu, 22 Feb 2018 18:46:54 +0100 (CET) Date: Thu, 22 Feb 2018 18:46:54 +0100 From: Peter Zijlstra To: Boqun Feng Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Andrea Parri Subject: Re: [RFC tip/locking/lockdep v5 08/17] lockdep: Fix recursive read lock related safe->unsafe detection Message-ID: <20180222174654.GW25201@hirez.programming.kicks-ass.net> References: <20180222070904.548-1-boqun.feng@gmail.com> <20180222070904.548-9-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180222070904.548-9-boqun.feng@gmail.com> 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:08:55PM +0800, Boqun Feng wrote: > There are four cases for recursive read lock realted deadlocks: > > (--(X..Y)--> means a strong dependency path starts with a --(X*)--> > dependency and ends with a --(*Y)-- dependency.) > > 1. An irq-safe lock L1 has a dependency --(*..*)--> to an > irq-unsafe lock L2. > > 2. An irq-read-safe lock L1 has a dependency --(N..*)--> to an > irq-unsafe lock L2. > > 3. An irq-safe lock L1 has a dependency --(*..N)--> to an > irq-read-unsafe lock L2. > > 4. An irq-read-safe lock L1 has a dependency --(N..N)--> to an > irq-read-unsafe lock L2. > > The current check_usage() only checks 1) and 2), so this patch adds > checks for 3) and 4) and makes sure when find_usage_{back,for}wards find > an irq-read-{,un}safe lock, the traverse path should ends at a > dependency --(*N)-->. Note when we search backwards, --(*N)--> indicates > a real dependency --(N*)-->. This adds 4 __bfs() searches for every new link. Can't we make the existing traversals smarter?