Received: by 10.223.185.116 with SMTP id b49csp2123377wrg; Thu, 22 Feb 2018 08:29:15 -0800 (PST) X-Google-Smtp-Source: AH8x226z6wTo7xnuU7OIQS04azumdI0OGhlSbIRM9yltliP2+qomDTzih5p9qX87VENA4SAm0Qd4 X-Received: by 10.98.30.67 with SMTP id e64mr5223079pfe.111.1519316955631; Thu, 22 Feb 2018 08:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519316955; cv=none; d=google.com; s=arc-20160816; b=JAXXSvcX71s8CuUO06uvV3Hh4T5LkfG2sNy3UjVE0LVRxf6V0ydgbeb/yNkqmbi5FR 6czHpBF9RlwA5oe3WQ27BDjGG2JHcDQw6uGX1xOGfq8PXmgNYMR6U15Dwu7KhE4rvrJM 2LZgCDCP7tGfopb/DEtGo7ECg/IDf5LmCsma7YN8z2vi8/Ez54TGpsAzjI4DeQf9kwz4 BYtFzvdEQkuNyXf8DpNd8xG/tbE5zDzoHvP1z8dfTkts5S/vu9tt9bpzZLbCYSP5stJ+ EpI5aAOvn9mctzQD7EmELFM+zrs6qf+8XcuTfBLmxflJGHaVdxbrIlfR1Zonh6296n+B qZDA== 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=6BBuZgRb+b7TCw7wd4CuBtwPLg7JYWK9uprGKsryyFk=; b=qOgcZJvraztfyH3oJTEMkCj0AjzcizMVhpu+n+rou0U+STne8Ig3UcZXVSqWFo/7UU vGmXAoQsOh4goXn/RYodr2+6nWlhpFQ5advAuhMuDl4euFlMeUov/fQQ5z2+BoshxUgY JFLlze8iksHz5IoSME7oWyofJIhZr0ckS/ERB2FJXnUfjm03/QIljIWkhyeSbbw3UJ72 ro4gbdn1dCJLyoqhh7+i95Lo/nyUEgEhlIDt972TXpGdy4BCcZRUxNtEyBqqjFe5qEm4 93PLz0XvuNUFa4DVxwoTefmMp+gbl57jRPHse0x/25zDlvfGaqQbpNqjEjUGALSSAll3 +zGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=auz2vgAt; 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 n7si209137pga.670.2018.02.22.08.28.59; Thu, 22 Feb 2018 08:29:15 -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=auz2vgAt; 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 S933225AbeBVQ17 (ORCPT + 99 others); Thu, 22 Feb 2018 11:27:59 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:51720 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932942AbeBVQ16 (ORCPT ); Thu, 22 Feb 2018 11:27:58 -0500 Received: by mail-wm0-f45.google.com with SMTP id h21so4999734wmd.1 for ; Thu, 22 Feb 2018 08:27:57 -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=6BBuZgRb+b7TCw7wd4CuBtwPLg7JYWK9uprGKsryyFk=; b=auz2vgAtcVoHA42SDj+Uim907vnWfYqnqygpQnUHYoedMOleomGeenvVFXPhfo9dyM 2E1gBu0XBjLmVahqZPURUdjmb0l47N996jR12gMPNFEWtOvBArnRXtuHu0udDJzAKilX YZIgVwwqn5IFiTioPtYWPOAWD5egno/Zq39ufH4RlxJu+skkBZT3SwsHrw70S7iLtA1P 1CP3/JhBUwMIJ8KLDhuKeJDeJH9PQ2A6U3R1ipT8bE/UaM1qbxhxNFIg+iH+nXiSLbAB yKw8xTRCZQmmdjhN16KEdUkOZqtWWup8BwveWH3T4L3ukmQevxA87guwEG2+lwBoT0oZ L2Fg== 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=6BBuZgRb+b7TCw7wd4CuBtwPLg7JYWK9uprGKsryyFk=; b=hUjJ5IRhVbt/PurixwR4MTXRPQYbSq9qK+EDTbd43k++YAeGXfaKcqSIp3+kAoadJW jRYM6lfGe1w8qtv79ceW4xEAqMsxguzzwh4pfR8umwL/qhx2TAYMP+k332d+ARYGtwZ1 X3oU1ghTzmg0euMdtYi0bNrHKfVXc7VGDlXMZf7B3I8h8OHjHTWVnZR/6zpeta28tg43 h3s6Pi19GtfAnyxgc+rPpjRl1xJUGb/ZV0W72JOk9mv1V8D80NZ3l37pfAU1cP60PVR+ RQhcIhT6Q1m2nAsXzTQMfooWo8OKwtrMrUjmS+a4QAj8qw9djcq44ciGHuT2iXQ9XBmb c30Q== X-Gm-Message-State: APf1xPAtuwZxYslouQfoOahV5Pms3ZFvLv6CTqp3S2Z11Wf02Uz+N5D9 H37zLx5V9gZMXceyLO9oM2A= X-Received: by 10.80.135.230 with SMTP id 35mr3342202edz.1.1519316876770; Thu, 22 Feb 2018 08:27:56 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id g59sm488786ede.19.2018.02.22.08.27.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Feb 2018 08:27:54 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 5A665209B1; Thu, 22 Feb 2018 11:27:52 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Thu, 22 Feb 2018 11:27:52 -0500 X-ME-Sender: Received: from localhost (unknown [45.32.128.109]) by mail.messagingengine.com (Postfix) with ESMTPA id C80B07E4BB; Thu, 22 Feb 2018 11:27:51 -0500 (EST) Date: Fri, 23 Feb 2018 00:31:20 +0800 From: Boqun Feng To: Peter Zijlstra 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: <20180222163120.zhytq7yezny4e7mj@tardis> 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> <20180222155143.GV25235@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6gf6kgjvgo7vnbac" Content-Disposition: inline In-Reply-To: <20180222155143.GV25235@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --6gf6kgjvgo7vnbac Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 22, 2018 at 04:51:43PM +0100, Peter Zijlstra wrote: > 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: > >=20 > > > > However, I would suggest: > > > >=20 > > > > static inline bool is_xr(u16 dep) > > > > { > > > > return !!(dep & (DEP_NR_MASK | DEP_RR_MASK)); > > > > } > > > >=20 > > > > static inline bool is_rx(u16 dep) > > > > { > > > > return !!(dep & (DEP_RN_MASK | DEP_RR_MASK)); > > > > } > > > >=20 > > > > /* Skip *R -> R* relations */ > > > > if (have_xr && is_rx(entry->dep)) > > > > continue; > > >=20 > > > 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). > >=20 > > I don't get it, afaict my suggestion is identical. > >=20 > > You skip condition: pick_dep() < 0, evaluates to: > >=20 > > is_rr && (!NN_MASK && !NR_MASK) :=3D > > is_rr && (RN_MASK | RR_MASK) > >=20 > > Which is exactly what I have. >=20 > Ooh, I think I see what I did wrong, would something like: >=20 > if (have_xr && !is_nx(entry-dep)) >=20 > work? That's a lot harder to argue about though, still much better than I think it works. Although I prefer use name "has_nx" for the fucntion. > that tri-state pick thing. >=20 Agree. > > If that is satisfied, you set entry->is_rr to pick_dep(), which his > > harder to evaluate, but is something like: > >=20 > > is_rr && NR_MASK || !(NN_MASK | RN_MASK) :=3D If is_rr is true and NN_MASK is true, pick_dep() will return 0, however, your expression will return NR_MASK. entry->have_xr =3D !(has_nn(entry->dep) || (!is_rr && has_rn(entry->dep))); :=3D !has_nn(entry->dep) && (is_rr || !has_rn(entry->dep)) Regards, Boqun > > is_rr && NR_MASK || (NR_MASK | RR_MASK) :=3D > > (NR_MASK | RR_MASK) > >=20 > > (because is_rr && RR_MASK will have been skipped) > >=20 > > > >=20 > > > > entry->have_xr =3D is_xr(entry->dep); >=20 > This one I think is still correct though. --6gf6kgjvgo7vnbac Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEj5IosQTPz8XU1wRHSXnow7UH+rgFAlqO8FUACgkQSXnow7UH +rg0xAgArZ1YjSSEWIHx4sbrnwc+0CWjavuB9wut9YkbBU0y4QPtc8tZONI55FOJ 7RZ+7HkHUb1Zk4Czz7EUVt3T9tYmJ3cLXlKJtzhUxeEzhSzy0cqlKzLQhgCgh/lN Z+bn0xyVRvK5eXgHrKWU6760em198y/5jaj/QzFp2Sl6mzdNtxHnAt6HCDEEtPED cOiX7gkDGOMyQ3Bxttya4h2aryiQ+lYXmM7dwNaqgScezKwTo4O4bbTvfY6RPaYk B+XhUNzppcyYzfb3cGpMR5xiKIrmEioMzEbC70gItXX/8nbjW0Nas74F6WprmrOG vNNT47v41hfMRaVuxir6KINVEb7t5w== =Uuyg -----END PGP SIGNATURE----- --6gf6kgjvgo7vnbac--