Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1975745ybl; Thu, 29 Aug 2019 01:34:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDIGVDK9xzYUJz2jcX5utrKjeg9vqsQzErAgyvKUPRDjqaIKaX3MFK4PeoyOP79Pq277Jh X-Received: by 2002:a17:902:4b:: with SMTP id 69mr8639429pla.89.1567067680681; Thu, 29 Aug 2019 01:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567067680; cv=none; d=google.com; s=arc-20160816; b=wpbCaP4tOnZ6EmIVfsF3G/gav1SGLjrhwUMyUCnGuNig/TlDle5fncuG4MAa51g/L1 k1VCN9gpGP3jacQt9dIW5GCk9aahHvVNXaP3PngeChMa25zLuTYupskEgZWY13lI/wa4 xdJl+kYse/EXOdWD8JWtH5eywlUm6thKQU4Wee4FkfRj3c4tMswLEn7op2+rMyj3iysS OIzTWCKc4fpE/rfEdBYyH5kPHYhJ05//pGZbPfK9Z2oXoRgVsxF3h+l20j62arrOL4qT BteCiLdzU2sMJeMBgyGXRMOMgwoC2JlasXF1V+DtIQm2a+lNB1vjPQBwkjv5jIkTdKX1 IH+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lNw8f3YA0DZukVEGbXPjsA/vyBkyObawvtOHlKkIee4=; b=NzBHvVe3NEUVLczMzPaxGbtVqdXyiGANtO26z126sccnRqFds6JlDD0Pz4yXaKf9AD Cubgsxn9gc0fYrzN0Cf0JFCd+SDQ9qg+BhDA2wVtAXjTm3EqG/8CqIoqMvfitTXMRkBc r4G9uAg/79K9LzAd8T2F18eVF2vVHp1Bdv0jPA8Hvv7zhODNR0tO0qIgR17Qwg54nR2i aMxiMa+rtHStt83SD84R+j/MV6QsFjaBcf+SguFdItMd3c9JBu58aCoBLpgE1XcTpuF5 GaAtgQdYmEVvlZ49IiEAnGhyDH3zk8RxVOtd1aCUtEUpHyt+7X56rgUQtd28OVgNXikh bKVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sefnPZfK; 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 t14si1296338ply.347.2019.08.29.01.34.25; Thu, 29 Aug 2019 01:34:40 -0700 (PDT) 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=sefnPZfK; 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 S1726223AbfH2IdE (ORCPT + 99 others); Thu, 29 Aug 2019 04:33:04 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36727 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727889AbfH2IdA (ORCPT ); Thu, 29 Aug 2019 04:33:00 -0400 Received: by mail-pl1-f194.google.com with SMTP id f19so1250479plr.3 for ; Thu, 29 Aug 2019 01:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lNw8f3YA0DZukVEGbXPjsA/vyBkyObawvtOHlKkIee4=; b=sefnPZfKls3P9ky+DVoLfW6A9lqoVwcGMHP4hhzS9Zg3gRmN7U+dqe/r2YrY+Uo/oy GklTNg9vOjfWuglFaWiB6sBO5uncDBKJCZvUn9rjS/CeyaoFCmljJuL00NiYu2SpNRAb KE8ay6CZ3qh0skNs+IYNLSYIkIfhvv7M1j1bKA3fXb+AEArniVQ3oI2hF6sHXF+h/w8j etWCoAKJQo7c43elviTkvpfpjSYnFgiYCQXLxqX1hD5AeTxaLncgPh4JMKxzxO5FFl0h uCHnjNNBRjxtvpozgEF3/VnwMWLgNs0SR5rx3UXtQd5x0ffwUwiyaBEq/CIi2GclDo69 ikHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lNw8f3YA0DZukVEGbXPjsA/vyBkyObawvtOHlKkIee4=; b=Xd+N9pfrIRZeveyVCtM1WTdUwjlNIlLAKK6D/k2LukIG2Uf8MG9kbiYr3pcC9L/Yvq qUqD45+/dJaZJsJUmrvlUKkGz8eFcjBQThfGCIP9/JFAxEjUb1u1jHLBm5yJljdREpjC gvKDdHjRNiJZRgHD+uat99LmP2xtUhQzv0RFzodViX64t/CzVb2VaE7ZkLYVO3kFE8Uj WePlR8KPNcWS82bbtyeQTFB+q0rbP7zIugyChkyWJZ5TxaEYWK+r0hbpH/9XLhdLGblN 45Ni8wZ2bXRjxC4zRtHZ7U3PsRABHiZMgNeAz5gt1lTwBGUhDFW4MZuGXWr/bKm7/Uhl anmg== X-Gm-Message-State: APjAAAUki6WxmLDxwgmh/vwnAj7MVqSMv2/AyaXVKHUXGm05PVaQhECP OuyTaI1i7H58FLgBL/zZyqM= X-Received: by 2002:a17:902:a404:: with SMTP id p4mr8320726plq.185.1567067579478; Thu, 29 Aug 2019 01:32:59 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v22sm1260155pgk.69.2019.08.29.01.32.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 01:32:58 -0700 (PDT) From: Yuyang Du To: peterz@infradead.org, will.deacon@arm.com, mingo@kernel.org Cc: bvanassche@acm.org, ming.lei@redhat.com, frederic@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, longman@redhat.com, paulmck@linux.vnet.ibm.com, boqun.feng@gmail.com, Yuyang Du Subject: [PATCH v4 19/30] locking/lockdep: Add helper functions to operate on the searched path Date: Thu, 29 Aug 2019 16:31:21 +0800 Message-Id: <20190829083132.22394-20-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190829083132.22394-1-duyuyang@gmail.com> References: <20190829083132.22394-1-duyuyang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - find_lock_in_path() tries to find whether a lock class is in the path. - find_next_dep_in_path() returns the next dependency after a given dependency in the path. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 18303ff..41cb735 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1535,6 +1535,37 @@ static inline int get_lock_depth(struct lock_list *child) } /* + * Return the dependency if @lock is in the path, otherwise NULL. + */ +static inline struct lock_list * +find_lock_in_path(struct lock_class *lock, struct lock_list *target) +{ + while ((target = get_lock_parent(target))) + if (fw_dep_class(target) == lock) + return target; + + return NULL; +} + +/* + * Walk back to the next dependency after @source from @target. Note + * that @source must be in the path, and @source can not be the same as + * @target, otherwise this is going to fail and reutrn NULL. + */ +static inline struct lock_list * +find_next_dep_in_path(struct lock_list *source, struct lock_list *target) +{ + while (get_lock_parent(target) != source) { + target = get_lock_parent(target); + + if (!target) + break; + } + + return target; +} + +/* * Return the forward or backward dependency list. * * @lock: the lock_list to get its class's dependency list -- 1.8.3.1