Received: by 10.223.185.116 with SMTP id b49csp437532wrg; Fri, 23 Feb 2018 00:56:08 -0800 (PST) X-Google-Smtp-Source: AH8x2255JC5tGoCBY2s9ZneMOUvpwpNDuJR1q4Jq+WR7wpDocENCIGQFOpJLswmmaDDRli8NBU9j X-Received: by 2002:a17:902:5a3:: with SMTP id f32-v6mr1053337plf.48.1519376168768; Fri, 23 Feb 2018 00:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519376168; cv=none; d=google.com; s=arc-20160816; b=kVNtan74Uu3pZdadsu6K3bNyR4+GPXGzWSPdihPLwfvz7J5IN4Md5JguNPiYDrSlNN i3z2l0KWiwXb1J2IOHaXHkofUs8Bus3m+Q29cDCPtvolY09q/3yvuoz6tAoj/IdwNx3R hRWlBRZzW2tjo0yhRoNSpIM6xLY+9mVUbTSePMm/dmcEH9iimg3bAFel/7nIPWYP4Mzv dJSVkexyXbC8QgWk3il0yhwQSC9pT59scDlQdHcwmlfIOlr2QKRKgCMYwVWvo6vnVXmr Gd8zjZK/JxYQZiSBLQvhdqxBnlCyU1NrxsP+IGFn9hce8n0HZ8qFkDWoxYzHcrZMmYIW UECQ== 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=FLCLIUQZUX+xUPFV1/VPrZL2UCmRu0fH91yP7YIrQLc=; b=clc/LFcojmXSTpFUqSECsGvjfq2grWh0uBtLvCAHtFcQ0mIGWTB3Lcbu7Mw880wGej vAGiojhQ0orrB7LG+qU5C8XQBBddZTR47xY9PbPP1TqVcYBI7HP5VN7VAaE8sS84v3nY G+/jEYnWadK/0d7FJXyDvzy2uPVjF5lopCloIXC+SJG9FDjjdJS9PFd/CT1QLox47LCn +I/HdNe9YKh2ltr8MKdVEnzv4PNOWNPKMzSe546Tx81WmJyTYR10UXRVzglBTW54FZwG QuQxluUFeeE9kzeAaKa5fJ3dlB2ouKIRw28K8uASZJZmkl7a+66OISYi+yP15bc8WolP M33Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kZjh2OZH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si1224528pgq.565.2018.02.23.00.55.53; Fri, 23 Feb 2018 00:56:08 -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=pass header.i=@gmail.com header.s=20161025 header.b=kZjh2OZH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751383AbeBWIyt (ORCPT + 99 others); Fri, 23 Feb 2018 03:54:49 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:37005 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750861AbeBWIyr (ORCPT ); Fri, 23 Feb 2018 03:54:47 -0500 Received: by mail-wm0-f42.google.com with SMTP id m207so3155986wma.2 for ; Fri, 23 Feb 2018 00:54:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FLCLIUQZUX+xUPFV1/VPrZL2UCmRu0fH91yP7YIrQLc=; b=kZjh2OZHRvwMIYigq3ri/WBPEEroviE+iCSwzRIzhl71MpczsLlLyl2GzCyhKqpU2l q9AY1r12BNOgQAg1a0UXZMAExSOU4T8c7x+OP0hgzX6bAHKC2VQPadFgUiXsjnbE3Hub 1szqKmnvrLMdWaxHV8mQbf5rrAsqJtSRaz9cQqOkjIpmj6fOE0udgoXeQJX5XMkSfnCV sNUQTA4A8M8w953Oa+2McqTEnipHKfwj5aRToqdyNMYvAmpjCMmX+GKDIr1f2rzZzDm8 PkpHNIu1QoDyA+b0/lPi4bdKR37FwnndG50QL3UEhgwh8UubzLlJCmgVciRizkZcrM+N AVvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FLCLIUQZUX+xUPFV1/VPrZL2UCmRu0fH91yP7YIrQLc=; b=tlkTUViqmhFSMx3Ksmp25y16Ar5wzbtOaZP/qpW8rjVUQrSCe6Ah4ZRnO39kpOVG7i lHJ10xG1mnbZ4fH/iL8nPya6Unq07APVTyz8gjZE5qEsvfuOpeJMAhZ8BsIuxa0NsqfL T3Y2EsKHgHeONnXYnwkCzI4ZMheTJuri659x7gwMsuaKGOIAri4o8x+RbP82cPdRjVfs dHthtHhx5UX0VAkNHvB6ycePeyLX961nxdXDUgkZOrWX5yarkjYjazoUK2Rc8OzN8cMh 4Z7oAAtlUW7ZG54KZSjVfhfLtXFULwhd/jD7l3xONXm52Yld7ec+49AU8RrCTP98DQLJ J6YA== X-Gm-Message-State: APf1xPD4t25utt8OGOG+lAI5r5Bwlse5zW2BYdfuuI5B66y7zDpBXYip nlyAjT5QZnkb24Yv63RRg1U= X-Received: by 10.80.141.77 with SMTP id t13mr1839847edt.238.1519376086533; Fri, 23 Feb 2018 00:54:46 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id w41sm1775569edd.32.2018.02.23.00.54.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 00:54:45 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id CBDEF20DCA; Fri, 23 Feb 2018 03:54:43 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Fri, 23 Feb 2018 03:54:43 -0500 X-ME-Sender: Received: from localhost (unknown [45.32.128.109]) by mail.messagingengine.com (Postfix) with ESMTPA id 2B6617E1F4; Fri, 23 Feb 2018 03:54:43 -0500 (EST) Date: Fri, 23 Feb 2018 16:58:12 +0800 From: Boqun Feng To: Peter Zijlstra 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: <20180223085812.22u7o6z2gcg272jn@tardis> References: <20180222070904.548-1-boqun.feng@gmail.com> <20180222070904.548-9-boqun.feng@gmail.com> <20180222174654.GW25201@hirez.programming.kicks-ass.net> <20180223082134.ykkbzqj2h7glxrqn@tardis> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zwqd4op5xu7ger2e" Content-Disposition: inline In-Reply-To: <20180223082134.ykkbzqj2h7glxrqn@tardis> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --zwqd4op5xu7ger2e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 23, 2018 at 04:21:34PM +0800, Boqun Feng wrote: > On Thu, Feb 22, 2018 at 06:46:54PM +0100, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 03:08:55PM +0800, Boqun Feng wrote: > > > There are four cases for recursive read lock realted deadlocks: > > >=20 > > > (--(X..Y)--> means a strong dependency path starts with a --(X*)--> > > > dependency and ends with a --(*Y)-- dependency.) > > >=20 > > > 1. An irq-safe lock L1 has a dependency --(*..*)--> to an > > > irq-unsafe lock L2. > > >=20 > > > 2. An irq-read-safe lock L1 has a dependency --(N..*)--> to an > > > irq-unsafe lock L2. > > >=20 > > > 3. An irq-safe lock L1 has a dependency --(*..N)--> to an > > > irq-read-unsafe lock L2. > > >=20 > > > 4. An irq-read-safe lock L1 has a dependency --(N..N)--> to an > > > irq-read-unsafe lock L2. > > >=20 > > > 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 f= ind > > > an irq-read-{,un}safe lock, the traverse path should ends at a > > > dependency --(*N)-->. Note when we search backwards, --(*N)--> indica= tes > > > a real dependency --(N*)-->. > >=20 > > This adds 4 __bfs() searches for every new link. > >=20 > > Can't we make the existing traversals smarter? >=20 > Haven't really thought this one through, I will try. But as you said, we Hmm... think again, maybe I can combine case 1 with 3, and case 2 with 4, because each of them could share the same find_usage_backwards(), and find_usage_forwards() uses a usage_match_forwards() as follow for the match function: static inline int usage_match_forwards(struct lock_list *entry, void *bit) { enum lock_usage_bit ub =3D (enum lock_usage_bit)bit; unsigned long mask; unsigned long read_mask; /* mask out the read bit */ ub &=3D ~1; mask =3D 1ULL << ub; read_mask =3D 1ULL << (ub + 1); return (entry->class->usage_mask & mask) || // *-> L2 and L2 is an irq-u= nsafe lock ((entry->class->usage_mask & read_mask) && !entry->is_rr); // N-> = L2 and L2 is an irq-read-unsafe lock } Got a bus to catch, I can explain this later, if you need ;-) Regards, Boqun > only need to do more searchs for _new_ links, so I think it's the slow > path, would the performance matter that much? >=20 > Regards, > Boqun --zwqd4op5xu7ger2e Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEj5IosQTPz8XU1wRHSXnow7UH+rgFAlqP16AACgkQSXnow7UH +rgmSwf/XlM7/ph/GuiOIou6v7OpVJW1VKgy3OEdPPXQcIIDcMtrgjJOL7FAmoQw /hPnLmmubkbj6hAfbgf3bayhDyBPRJOWMw2mVEVrGwpQ7S+byOI/VXfU2hkfwBP9 FvoSPZBC0CRqlEDMbl9apDskseE3XkqCko/nSSaom19mILY1wWyM8HnfT3sb3yXL QVG6bMfLkWR6YhXKcVsL8jQfPrUaih7u55Opxw3RBENc+mSC+7AucXC0Ci2lVQdI 9wjkgHsjstqMPlnvPh90Hagi2YPqrK7mO5AbYBvpPht0dV4tEdeUyNpStAY7iCze VDDlqbkBfKeCBtacd3vuwR24u/Gj2Q== =sWM2 -----END PGP SIGNATURE----- --zwqd4op5xu7ger2e--