Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4137057ybi; Mon, 3 Jun 2019 06:19:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHKoANiQ0fKOmZHMXhgdXQI7zjWN1VpL2+CK6e13o6KyupaYxWHA/6ikvLnV55iylkHrMf X-Received: by 2002:a62:770e:: with SMTP id s14mr1542715pfc.150.1559567992355; Mon, 03 Jun 2019 06:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559567992; cv=none; d=google.com; s=arc-20160816; b=PeDYAQhl1vr2SgVglaa/2T+/jAhHSlIigvveV8+4/Gf8bjya0AxY/z79plD9S983p4 J41taf6HgXMSaXjqhdcmnN2fSHl8FICJoiSz6toF3iPVbaWWjukb19otnzozT78fFVP5 SFuV2X+6/502t/nDtu6UCk8PmoPH1AhW35ZHqceYajbQjPBIVZvCk4IGLwBaUdGmPOvB aPE6Ars+Ca1Cmiu5Fe6GWKO0nFuuWuigpBrbdLX7CzAPOkwGBqO+pPyJhy1mLmz62I+5 +7enbNGxPKn/AOHfnJyBQaQVM/SZXiswh6c+PAuY9Gc5mu5/4RqL52oqeYFER2SXSj8e pdEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=e87xoz9o91NBYY9SFCrF48s6+u3zh4Ck7aL70Yo0Hdo=; b=clTgZyaZ6AZvZEogVCXojUa3SxNnDDfbYzCeM0Jq/mZjCWTMy8On+E92eoR+wp6qVA n1oMkyzNfUCRlNbLmpq12a0GzQih6Z/kdB8qFQ9K7b9EeEWPX94gGsyqzZNN2mFBCrrU QGRPjryxBiLdgWFd5rCV4RoCkObaIl1JVr7fSVAzwYzI+ZjiFaPuPCEvc7LWlhcEg9Wo YuiZ9p0sRHCCb4a4ztAgPqPBKTERh9oXw87atSSnomB5pGoIZPGYRYfpPBJIhUF5ETEu tyXrm8eSNJGi+2/IQS1yQSX/VsnZbp0gRPDAOXRLYG80xKPnjSUepOWtm01+z+QWkcoE vORg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=HRJuBQt6; 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=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16si17398963plr.238.2019.06.03.06.19.34; Mon, 03 Jun 2019 06:19:52 -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=@zytor.com header.s=2019051801 header.b=HRJuBQt6; 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=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728361AbfFCNQq (ORCPT + 99 others); Mon, 3 Jun 2019 09:16:46 -0400 Received: from terminus.zytor.com ([198.137.202.136]:45233 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726516AbfFCNQp (ORCPT ); Mon, 3 Jun 2019 09:16:45 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x53DGZgE606158 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 3 Jun 2019 06:16:35 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x53DGZgE606158 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1559567795; bh=e87xoz9o91NBYY9SFCrF48s6+u3zh4Ck7aL70Yo0Hdo=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=HRJuBQt6CfKDwe35SzLK5MQtBbQIQeK830cFPwJ9sutQzFAEh/xA9Yf/KkVHYgKTM 7GPunpUoL9ihSESb3Xl4vz65eZizwA32eCNsvPmV/iXt/JVi5UVQoYmKKQoPtrR4f8 Mq4fNy4c07fxdc2IaVykTg0AO3bbCMr5J+Sx+aJ6IxiRmPcliUCAAHm9BfWkhWPLBz GcsmAloXpBD2TywtQgaeKRvkKFbQ7rpJPJqphvgOeQ+P5WxmVZERebx+HjrD/4Y1Yk dK2E/l8RknZRheOJXRF4p334rx2JtMFnUgcarB20rjRjxvGv4lj8FF9seeFFgLp3Jr xB0mrrcJQjL0A== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x53DGYr9606155; Mon, 3 Jun 2019 06:16:34 -0700 Date: Mon, 3 Jun 2019 06:16:34 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yuyang Du Message-ID: Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, torvalds@linux-foundation.org, duyuyang@gmail.com, mingo@kernel.org, peterz@infradead.org Reply-To: duyuyang@gmail.com, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, torvalds@linux-foundation.org In-Reply-To: <20190506081939.74287-16-duyuyang@gmail.com> References: <20190506081939.74287-16-duyuyang@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/lockdep: Update comments on dependency search Git-Commit-ID: 154f185e9c0f6c50ac8e901630e14aa5b36f9414 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.3 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 154f185e9c0f6c50ac8e901630e14aa5b36f9414 Gitweb: https://git.kernel.org/tip/154f185e9c0f6c50ac8e901630e14aa5b36f9414 Author: Yuyang Du AuthorDate: Mon, 6 May 2019 16:19:31 +0800 Committer: Ingo Molnar CommitDate: Mon, 3 Jun 2019 11:55:47 +0200 locking/lockdep: Update comments on dependency search 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: bvanassche@acm.org Cc: frederic@kernel.org Cc: ming.lei@redhat.com Cc: will.deacon@arm.com Link: https://lkml.kernel.org/r/20190506081939.74287-16-duyuyang@gmail.com Signed-off-by: Ingo Molnar --- 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 2e8ef6082f72..b2ca20aa69aa 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1381,6 +1381,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), @@ -1461,12 +1465,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; @@ -2285,7 +2283,7 @@ check_deadlock(struct task_struct *curr, struct held_lock *next, int read) /* * 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] @@ -2335,11 +2333,12 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev, /* * 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 , + * and check 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;