Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp430418img; Thu, 21 Mar 2019 00:59:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrkwwmUbTc3U6X97p9ZGY2BTHKxbDRkfijdeLTyPkZkuhkwon4KisAMKnGpTu4U/hYTevZ X-Received: by 2002:a17:902:7592:: with SMTP id j18mr2167900pll.300.1553155180350; Thu, 21 Mar 2019 00:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553155180; cv=none; d=google.com; s=arc-20160816; b=x7ZLUh782K43txHdvUTfZx5LAQnLXs2hka5Rsq/QS845eo4r+hR0cBukGqfiw4j7mk ejRWLKBpoLV5wSQW6X7UcegwuMdDQadG5phX+60+zs3TQuJ2M8I06RsnsrIPpa1UYgQl jjsxNLlM9+PZbXYMys3p+ZqxfwiVTgRj8xWUVn2ggbInUPSM/7jF2B6MWfijxMoIKqFN MEn5qNGMwy1obtsYHK8lrdu2N6zQQAPHCWFmb2+UDfEtHoi/20RvIASylL9yiPExqeNz NNHa/a1qpkWIjH1XyvBPNx9UHFe9LngzbeC3+GbzZ1WUYNKsO6IT/bRgEvDUVahI0Ytl ie5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=+o13T9DFMS0RJ6qbCf0R7iXbp/dGpnQOV33lCtkBhDM=; b=ByMid45tBfeF2JcgHgkB7mqBDrEJGpWmtYhMfVJ+Vkl2Ye0FXWu8BAnqZHVRSOMtYQ SSakouFPyUi60eMSkXGBOkF5FBaQJ/bGAAjfPP6TuUjZtNsbd757C9NmfuIno+Bulzzl DtLZe3ckQNZtH4zWuP4LP3D6UjpjWo1sMlMRjfSYS4UZvMyfJMX/K2XxMZzL8vx0WhVr 2EMnwSAggCl/wWBQ8iKV9jNmDmYG9yn7RlaDblSslMEVMBHEAkA4Tljo8HTayQ6qtzgS 4xICdDWD8RGBpjeluH0F9GHSEs6vQu8PuhDgAciEnJDnQ4gFeD5COgU7MPAJ8GeNVBTN Uimw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I3xbBO7H; 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 q11si3908094plr.379.2019.03.21.00.59.25; Thu, 21 Mar 2019 00:59: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=I3xbBO7H; 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 S1728138AbfCUH62 (ORCPT + 99 others); Thu, 21 Mar 2019 03:58:28 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39914 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728124AbfCUH6Z (ORCPT ); Thu, 21 Mar 2019 03:58:25 -0400 Received: by mail-pf1-f195.google.com with SMTP id i17so3788592pfo.6 for ; Thu, 21 Mar 2019 00:58:25 -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; bh=+o13T9DFMS0RJ6qbCf0R7iXbp/dGpnQOV33lCtkBhDM=; b=I3xbBO7HF4jMZpWll58mCPG7FYB6WWMD5dagN9PNlCcly0E76nNKAzQw7oe6womANv 8IkOgqlc9oiyeqorwEONnFVlEQE3px93V3BvlRrmktsbOg6Ed67tRWXvschCABhwnI/t ax2osdyLNAeqqoKuAz16oKMnz94/plhBuxFghzSqBhAkEkI7YBYhfVBv031gpnSyy2k/ GMaj9YagcOE+sYrfp6uJeJorD/JpjKHOUShE/jK0n1jA5M47lxj6PYIJBlrAEtg4G8sX aYMFuzYYiuRpe262d/0JDTBEhexbfV/YkHGSisqvVh+IZeQCHCsJggB/IVhBGvq3NfZZ TIGw== 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; bh=+o13T9DFMS0RJ6qbCf0R7iXbp/dGpnQOV33lCtkBhDM=; b=sEQSEIVj02cfYK3tW0jDJHSnctTCxY5oKAIxi1Zq2zSfMvZVtImD1VYuKtEllpSU86 NYd9PkdD7JOysE1TR2qRgiiCTP3Kg0B+3ucc4SmeS10XJYaKaf7j05KvQXQq4KLwQhxv ON8O/8/XQG1dJBr28EqbPDa9t7AFhOWGU0jZVy6csvBye5Spqc4Oy6AoQcuLQVrJd1nQ 1l4xhMAO4DKWZ/LymbAngKmJLedez6T1SjmTEUwAyg4jV96UiQR5b2dxcSRESJcuvwSg Tfzn4SPDbfE5DcjJLOTqgSfU3sk4l/s5+C6AaluK2sNej22peSynM+wH5FNXdFdYbT6o z6Hw== X-Gm-Message-State: APjAAAVG2yZWk6dD2dKmeLRPkM3K8GcMfnmQ8T4LbVBXd/oB8Mo/rb4N zsoI6kIa5nGN5yQJ3EZw3sI8WHinvEAMvg== X-Received: by 2002:aa7:9103:: with SMTP id 3mr1997675pfh.192.1553155104816; Thu, 21 Mar 2019 00:58:24 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id e184sm6467148pfc.143.2019.03.21.00.58.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 00:58:24 -0700 (PDT) From: Yuyang Du To: peterz@infradead.org, will.deacon@arm.com, mingo@kernel.org Cc: bvanassche@acm.org, ming.lei@redhat.com, linux-kernel@vger.kernel.org, joe@perches.com, Yuyang Du Subject: [PATCH v3 17/18] locking/lockdep: Update comments on dependency search Date: Thu, 21 Mar 2019 15:57:24 +0800 Message-Id: <20190321075725.14054-18-duyuyang@gmail.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190321075725.14054-1-duyuyang@gmail.com> References: <20190321075725.14054-1-duyuyang@gmail.com> 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 8202318..9df2b1a 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1390,6 +1390,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), @@ -1471,12 +1475,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. - */ - -/* * Print a dependency chain entry (this is only done when a deadlock * has been detected): */ @@ -2177,7 +2175,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] @@ -2227,11 +2225,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