Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp317419yba; Thu, 16 May 2019 01:02:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZSvQ+YUnJIEms9okG9ucnXc5a+2DWG8vDrt8EwiFdHjd3Jtvp/wku0/MT0G/BU49JMRtq X-Received: by 2002:a63:1a03:: with SMTP id a3mr49266809pga.412.1557993729167; Thu, 16 May 2019 01:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557993729; cv=none; d=google.com; s=arc-20160816; b=EHv8vSOWQiTVqsERAy+EVG/aV6Vhy9aGz9pr1qDY6dPzQmPnQY+t4Jcy49QItItPp9 8OZfPZubfQe4CdZFE3o0wu7GX6tCw4C8LxuFq6adLwBXJ3hP618vsN2tFfUzF5OXXAPw y5bVDpyuAhy1VN6c/8cDh4oqh+gvXpa+3u0akfKblQQJdnyAeQr5OSa5YZuPMfoUw8HL 5Y7iiEpzNM9ECoQxKY/jWudEfIBN9+n5OQdr0HyHIAyFO818SQFdzwt8trbGmchq2fSD HJceKFnXPdUgfiMvVlZrkcYKoJlJUi87vd/mjJtvGk6fxOMfgItbWQV74tvvWerl9oPY 0QrQ== 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=+UAtuX7IYUSdxLE+OnJ9wU1lsxMLJnRltRuwKyjIkJY=; b=EBhRHaLNOOpn7ScWv+i8fEeLzVptQkqVrXXTeIiXwsfVcsGFpsc0xE2XfB2fJXFSwt yR1x4n384o3RnRwLkVLsokEBLAMcmwopxZrJqIZXqSaJKngfKzu++aTg0rEQWGfKtEp8 3KbGFaDg+cqevqSEqgpzjdiHKiW6RIJedgCIMf1hKOUfq1WXFHzIsgyrgaBMO3+xJsiG QUyHWDiUkeXVdzDsIpdkyEd4ImVK6lhat01FGe3qug1EOBiJWGpgSo9PN92hlkiZkrao OTth7HcjZTrPgoZHwhpnB124TgeD2ZzAkz7jNd0Ru8AP6OQkD88RbqqJ8Odwli8WDXA9 Xogg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=F5GdMIWv; 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 i4si4654350pfa.218.2019.05.16.01.01.52; Thu, 16 May 2019 01:02:09 -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=F5GdMIWv; 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 S1726830AbfEPIAg (ORCPT + 99 others); Thu, 16 May 2019 04:00:36 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:32897 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726363AbfEPIAe (ORCPT ); Thu, 16 May 2019 04:00:34 -0400 Received: by mail-pg1-f196.google.com with SMTP id h17so1177583pgv.0 for ; Thu, 16 May 2019 01:00:34 -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=+UAtuX7IYUSdxLE+OnJ9wU1lsxMLJnRltRuwKyjIkJY=; b=F5GdMIWvELz2KvSlbX2VcJzJzrGFFCY+75kyejm68PV/a4/YoxMMzcD9YN7WowtSjj kU6B4a4bI32FfI0fh8XNACZOLg/k6hGDi450aXQz0zvkPf7rfqWbdATdNC3jU2p9GsBm rFEPMRfzclL78iS6glJi4IE+FS6f0UOZrivNe0znCCxfzYIBcEPALUnVX7H2QCgSuXL0 gn2I2pwbHii2UKzQ1uxul+0XbYTD7Jgb/c5ZdSj0Bci/KxKN3bVGOdtrfV1lJ7BpQCyr 4NnX27AsvfEQ6A7Zhk8wsTmoqxTrNlCuYdX8Kkoke5H8MA3F7ikM6hrMvcfLc5nxKrWT gTbA== 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=+UAtuX7IYUSdxLE+OnJ9wU1lsxMLJnRltRuwKyjIkJY=; b=S9nzj+MtIszQnHaeCjza4FkEdTJj9LGjrHLGecS1DktrpgSGcrb9Vef+JcUsr/JJOc DLP4LV/Wn73wWF75yOnxWeRrVGDpu9gKDGzxnb8iW1tWpZzfeo27wsCbogKVbAPXO5DB 0JMnAuWreiCmlhh3Co9a2oJHg7y9UEs1XUk2Xl0f/XyZJcA9z797irxk/GMm4Cz/ZdNQ pBViRpCpumwJTslxBN9mtNuBDzZq22wweTaQy4t4zRaL8wgs5uqjtDEq6+i4Rm/K0+mL /nP8E7BUiCNMuQsOx38frNYGj885Bo2hT/3BBPXcdkMTghJ7mfGYHZ+4t0dPXcI+149L vcbA== X-Gm-Message-State: APjAAAVqDeqx5vw9luFGV1eUc/pIUsSgxL4msPuFbZW5N56++yHS7Hot 8RC867nHGmm3UvM/2IdZfIkiV21DflW54A== X-Received: by 2002:a63:8dc9:: with SMTP id z192mr3967654pgd.6.1557993634545; Thu, 16 May 2019 01:00:34 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id p7sm2051471pgb.92.2019.05.16.01.00.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 01:00:34 -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, boqun.feng@gmail.com, paulmck@linux.ibm.com, linux-kernel@vger.kernel.org, Yuyang Du Subject: [PATCH v2 03/17] locking/lockdep: Add helper functions to operate on the searched path Date: Thu, 16 May 2019 16:00:01 +0800 Message-Id: <20190516080015.16033-4-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190516080015.16033-1-duyuyang@gmail.com> References: <20190516080015.16033-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 e7eedbf..595dc94 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1365,6 +1365,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 (target->class == 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