Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2202314yba; Mon, 6 May 2019 01:23:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrjFOrrDwLNb8CO1CO52zAm5v6A1MgTMZTLDWWF/eSqosfegTZRMK486XLoyGzlZE1zroc X-Received: by 2002:a63:d713:: with SMTP id d19mr30694282pgg.145.1557131004812; Mon, 06 May 2019 01:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557131004; cv=none; d=google.com; s=arc-20160816; b=gqk3jq72NEocsGCbWQNTlMFG/zy6+HFdL5tdrCcftHB4kZC8SuYUHcAkpChz59f8lO +V0RSK4Qg+r+W7lwGFuBoZiTSAsKy8srJuwEh9Wkm9UnNKrlKTe1807sLMrxOW+LEA7W e/tpvR6kTN8oKxM1cnluu1xznxR5NCupRnftkRcce4E8+S4ImUmR6QqRej3mQyalcQPP W3zFs/UW+E8Zofp65BnqHl/jy97KH2ofWgksOWhuQvT1DWd7DwPYn5vontfDx9WsSKtb ai7vwLWJ4ElPJNY6VS1RhTRygZq7Mab9YLGFYrSy7m3hARUUy/MkeiNg4bL/erWkCXKb ANnQ== 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=jncaqXpvY9xiIvXn8Y040qvm3yjppXEdYjg++AKhNVI=; b=H5YsS52iQG0cnxPwohywJRwyvllGkbZZU6tWZ0BXB717Usa2Ro3quoNxE6+UmUnImr 9H0NXrU8li8zzOXrI26qoqkFYJBCDmi6uyVAOlJWCq6UA37zmXAVAsrMtIS3ab2ta1/o VxE7WIbJE2635RLnTRlgibJUuuR0SvtewMoOtpD+nQDOjrlU6UZZk8vUO/DRXOC7jm3x i2KEuPQk5KUHkAxs4iLOxcOdGURK1W9W8eh2APohzU5u/ALYKzkA3YISJx58ktRQhxvM ameLKvVfYqbrXWjfh3d+77iKMsRTepyrUGFzSjubLE5ib1vPdlVuw8EYwdPFLuBs9xl6 lWTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bfhbj1w3; 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 n1si13690422plp.272.2019.05.06.01.23.09; Mon, 06 May 2019 01:23:24 -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=Bfhbj1w3; 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 S1726616AbfEFIUi (ORCPT + 99 others); Mon, 6 May 2019 04:20:38 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38809 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbfEFIUh (ORCPT ); Mon, 6 May 2019 04:20:37 -0400 Received: by mail-pg1-f195.google.com with SMTP id j26so6098092pgl.5 for ; Mon, 06 May 2019 01:20:37 -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=jncaqXpvY9xiIvXn8Y040qvm3yjppXEdYjg++AKhNVI=; b=Bfhbj1w36mqYHvEtPxZ35+PNe5TwYdL2vKfcb/A07W10m/xbYsCuKyHA/yBVWzbW+L q5XJ2gjjr/1KtCPv+kqyjdvkzmXGGFp/u364fSBV2o88zyo1f/oYtCRQDe21S9Bx4pvP Z6o8vkMXnH6xBVkGka8dMdungtRKcpoQNfdtHsTi9yBI9fdMWgqbt+jqKdnfZOcYJy0D yTraIc72PmejnyX6GUwODKqqKH6b0+HlRUmeqh/yPyA4TVHZjwJrKNGQs+ZjiYkm55M5 Zs9IJlNmSsxQNuvrMRlN8NzEwnTCpzMcW5GlW0shB4vFq6FHgLHow48/VQuqpqxijeUh oUoA== 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=jncaqXpvY9xiIvXn8Y040qvm3yjppXEdYjg++AKhNVI=; b=MPuK5nN5qX5UOdC35Tjh9n/cJTSLW0LSuEr9HJJqVinQ+C1BLNnxNS0dAAxmE2Ukon o23shFsEUlExDJhjuAzZTGfFmtA39dJ9wgwxexxpyKhyIsB0iggLn6vtZuWSncdvpYMu PS9DiVu37KjaDJ3zenTPEhSVcBe62r3NIQczIfFmMsh4LNM2BG6HY78RzLF9LdgCRKNZ 9mK+ZKmGoW0Qfatk5ws/M6e6Ie/9xP3rGuYOQIpjSXxiZ2VudC2vBDvNt4vRTtGOZXGm qmG5T/dA0dlLxh9lur8nj+rF/aTv0GgBGsSJyIdxGBWEv6RG2rGS4EXFPb9R6w++AP8O G9Mg== X-Gm-Message-State: APjAAAXOA1VwcDZFLlogAVhddH9Ee893NlyGrRMjHy/ehoQ8gTqn23/E KnM37oVXNXNhI9ZPohQEdyc= X-Received: by 2002:a62:5a42:: with SMTP id o63mr33025957pfb.170.1557130837029; Mon, 06 May 2019 01:20:37 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v19sm20958013pfa.138.2019.05.06.01.20.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 01:20:36 -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 v2 15/23] locking/lockdep: Update comments on dependency search Date: Mon, 6 May 2019 16:19:31 +0800 Message-Id: <20190506081939.74287-16-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190506081939.74287-1-duyuyang@gmail.com> References: <20190506081939.74287-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 15cf2ac..7bd62e2 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1376,6 +1376,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), @@ -1456,12 +1460,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; @@ -2280,7 +2278,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] @@ -2330,11 +2328,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 , + * 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; -- 1.8.3.1