Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp596707yba; Wed, 24 Apr 2019 06:37:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNunwd/n5sKxSvSKeZmof9movAWqR53l4MqadRgbdhNzet4iXew+JjMWdaNVxcEQIPAao7 X-Received: by 2002:a62:2a44:: with SMTP id q65mr1480407pfq.226.1556113063702; Wed, 24 Apr 2019 06:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556113063; cv=none; d=google.com; s=arc-20160816; b=Nu8QsEDOciCHDM8TybNCwrqWZveaOEJPA+RXar8qO90w1r1/jqqUgsVVG7E9uuo2C6 XadGJdlRoxwTkS77PqCciSn8qnElM3ge4YAytkq/hOhgykWTRe173KBkAfocUP2Gt5pz +Ny1YBPGgSj1QHOaSgU47AoDYY0kUjHluwngLEvKh2WczjvEIO063DXTdXv5l4/rTO93 QuVV4oF2SezV9E3JdG2GWbwmDYC2KHO7toI0Sh/d1zIKf5/B5BYhQ1DkFeRpSTX+A2RL YICMQE3pRXfuXMZDMOdLq1H59M3DS4JEWInU2hdTST+GyH2dRNuHLd2QJXWKd0pHt9pu MCOw== 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=TTSJeJChcHNZMTBu1HF95U4ErzrozbTOn8A0dkI+M1k=; b=I25iyaswF0OT2ZW3bjMUGcp6p7YUZOtJYvuAfZFUNd+njK43RC1kWYxJsbBfsOMkKr 74jLYYhkmdSKjbv+MYNHQOunN9uMfm43dujG8srLTCd0tGGG67ELfvlXUgnUP3wx8pIz /DwX0LkxW4qbPLpjLnpOII+ZiwpA03q2F8XHvdqGTaZYIyaXLm2NNnqIfcMogxuYVN8Y KnqWz5MfwBxoi6LdFAN/xAxn4llBXIeWmDA7xKENmu/5wl49FItL1kibPDmVuCGJNpTC fVxk8P/7F0tk97JjAzdSmpLZXqZVKSZETJKhggzTM2/hHcpXqDgr5AH7ne8mHBgSBWWE yjiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CiW8G5O3; 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 q5si17858299pga.498.2019.04.24.06.37.22; Wed, 24 Apr 2019 06:37:43 -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=CiW8G5O3; 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 S1729616AbfDXKVT (ORCPT + 99 others); Wed, 24 Apr 2019 06:21:19 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41422 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728513AbfDXKVO (ORCPT ); Wed, 24 Apr 2019 06:21:14 -0400 Received: by mail-pg1-f195.google.com with SMTP id f6so9152802pgs.8 for ; Wed, 24 Apr 2019 03:21:14 -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=TTSJeJChcHNZMTBu1HF95U4ErzrozbTOn8A0dkI+M1k=; b=CiW8G5O3fZy7IFTCBdCPcs+Y/sstsAe0Cv7e939CYl70R2NsN7k91Lz/CEeloQePPC GE1zm/Lm3s80fxAsbIfZeeJmyZ8+6EgmnrEkpjJc0H78pf1O7TZA/3/Uwr9+YTD34+8R u2It7Bi5qHsgN4/T/6nJPiAzHwoJz/Pis/Ra+arOKP8ba7VlfIFxVUd2dE4NLRwRdgE+ 1HaOJBYFBQ4AkELhWzGCmn+D2s2RmIAEA6TSQgMrXnqT672WgSdyWNZxr09KzTB3BoTs U4Gjx5HkK7CJfM9Dfdyd8wF9mubyuXbFa5tdx/D+dQ0hi3O70a9XVu+MSza3NEovc6Ya I4fg== 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=TTSJeJChcHNZMTBu1HF95U4ErzrozbTOn8A0dkI+M1k=; b=oFnFq2rQlvGBOqUQI/sOBpEt3ujWM+ohs1+R8bPBE0hSF/Wh9q8fAPQI6EvtgNt2f9 4Am9mtN6sXZwtBX4ixc33psz2uSBsxuWGhhSYVNhi10Vs4qUPBXDJHwfDCJjvmKrIc0T bqx81Og+lOHE2TiU6qhr+vXWra6r8JOHzkng9Mg6Iifn64hazZSyZThFq+YaVM4cFf6+ 8oVdT56QAKOef+GQLk1hjtY3zRqRc9oi7HVR8QJbbJ+gLdQwaElc552vPW/QBZXBfK9F jWB2oq8CcH04hQaKLsbSyco2Yb7FouQePGr2YyMvnrU+aaLZulJYHpY69pe1+fKHCjC+ Qhhw== X-Gm-Message-State: APjAAAVt8PD+tSjt3Xa4PdnS2CqZxn/qkQd8CLBDLQklhgubEiyE9VoL vyY/Z2LLK7VjWAIE36B1RZo= X-Received: by 2002:a63:ee15:: with SMTP id e21mr774463pgi.180.1556101273774; Wed, 24 Apr 2019 03:21:13 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v19sm25051604pfn.62.2019.04.24.03.21.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 03:21:13 -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, Yuyang Du Subject: [PATCH 15/28] locking/lockdep: Update comments on dependency search Date: Wed, 24 Apr 2019 18:19:21 +0800 Message-Id: <20190424101934.51535-16-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190424101934.51535-1-duyuyang@gmail.com> References: <20190424101934.51535-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 The breadth-first search is implemented as flat-out non-recursive now, but the comments are still describing it as recursive, update the comments in that regard. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 16f524c..d153b97 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1375,6 +1375,10 @@ static inline struct list_head *get_dep_list(struct lock_list *lock, int offset) return lock_class + offset; } +/* + * Forward- or backward-dependency search, used for both circular dependency + * checking and hardirq-unsafe/softirq-unsafe checking. + */ static int __bfs(struct lock_list *source_entry, void *data, int (*match)(struct lock_list *entry, void *data), @@ -1455,12 +1459,6 @@ static inline int __bfs_backwards(struct lock_list *src_entry, } -/* - * Recursive, forwards-direction lock-dependency checking, used for - * both noncyclic checking and for hardirq-unsafe/softirq-unsafe - * checking. - */ - static void print_lock_trace(struct lock_trace *trace, unsigned int spaces) { unsigned long *entries = stack_trace + trace->offset; @@ -2182,7 +2180,7 @@ static inline void inc_chains(void) /* * There was a chain-cache miss, and we are about to add a new dependency - * to a previous lock. We recursively validate the following rules: + * to a previous lock. We validate the following rules: * * - would the adding of the -> dependency create a * circular dependency in the graph? [== circular deadlock] @@ -2233,11 +2231,12 @@ static inline void inc_chains(void) /* * Prove that the new -> dependency would not * create a circular dependency in the graph. (We do this by - * forward-recursing into the graph starting at , and - * checking whether we can reach .) + * a breadth-first search into the graph starting at , + * which checks whether we can reach .) * - * We are using global variables to control the recursion, to - * keep the stackframe size of the recursive functions low: + * The search is limited by the size of the circular queue (i.e., + * MAX_CIRCULAR_QUEUE_SIZE) which keeps track of a breadth of nodes + * in the graph whose neighbours are to be checked. */ this.class = hlock_class(next); this.parent = NULL; -- 1.8.3.1