Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp240372img; Mon, 18 Mar 2019 02:00:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqx83/Q5E6/ycI+ko1fk3gAscuSNpfkzVHIPBcsPxOHWPu75taA5GXuztf2+DBoRxtEuJA/Z X-Received: by 2002:a62:4743:: with SMTP id u64mr17678700pfa.95.1552899602812; Mon, 18 Mar 2019 02:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552899602; cv=none; d=google.com; s=arc-20160816; b=ZAanXqyFb3NvVV/+i4WEv0S+ZpdUTKI/qHJJ8MK5sO/Yes0FsnS3bDUSOwc0TtjAai ythDtExfrkZ/lbnwTuhR0FcDC3GyI7n7qeHK8Y5o2cAhOM/AcP1EfRPEPXT0jM2c+7Ek nEY/IrMgQ94FbQZEfgi4UKlt0infdzHyDjIs0TlCJZmxqD5RggexfGt+Kv3wo3LOM5Uo PBHhsNfEbPC+hNLFHP3w+/lg4WmyNY/M7eKfgoJw6vmqiDq79aSz/33sPxMStcOM+/Na WlaFkwC6tf6dIRHCGfTboaYBiEuxDLkTd+95zZPcO0vS9vQ5mtkpEdyGzPaTYUu06YBG IImQ== 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=7J1PZEGPvTyxhKQufXDc4OOFjcFwzJJjt2oPZMN+8zw=; b=S53spjPHlbYBsFIBbq/SeLGH/QcF9Rk5h8AbuKRPla7TwWi7bKX04E1AVf+vy0Fl+Q W41qzUgq+Ng1SLnQIvv8MVrBatrFh4xMJ76/lOhK7tV6HolRrF5eNlq1Uk9qBbvIX6sR hES+4+iickfVrPJNv51Z7izeoeuNK3MB0lIcgfKnVMisl82Hz8DGQGRWvb5X9I2uDmcz dwAHG7H269z/y+/0YqxTWStB9VZ6Bsbp+5Dc6QNlnUllf8NUEglaa5R3YPa5CvqU69AU Yu33ROAsNvOfKOQAwfE1tEsL/zyfYgyFpqV6Z8mdKSXr+u6SN8AmLSL17cHsR7I6bVOv lajA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MKX0+n1c; 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 w4si8245630pgp.171.2019.03.18.01.59.47; Mon, 18 Mar 2019 02:00:02 -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=MKX0+n1c; 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 S1727517AbfCRI6d (ORCPT + 99 others); Mon, 18 Mar 2019 04:58:33 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46458 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727493AbfCRI6b (ORCPT ); Mon, 18 Mar 2019 04:58:31 -0400 Received: by mail-pg1-f196.google.com with SMTP id a22so10888061pgg.13 for ; Mon, 18 Mar 2019 01:58:31 -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=7J1PZEGPvTyxhKQufXDc4OOFjcFwzJJjt2oPZMN+8zw=; b=MKX0+n1cnXI/mvWtB6mvfNuZRobmSOhXqvnT2+3WHLf+b952KI0WqTRmmXcRhk+WWO m9b3/DUXLrZbxPx+dNUigJicgwSOLnmkmIBggmyrvEmCKy9doHcdfCxH8LnQw7fyXa4G fpqMOKsKiCEav5qpIk6SwNEtY7clF3aJtf3i3lBj8PKxCGwHH62zCK5Wu87q3OwvkHlH BQ0id/yvX24UBrE6PKaM0DM/cIjjF1ecYGhQk2+CE5v8vsEu7KS0vUVA9FWRiDrr0UQ+ GYBR35LBUfM/9soRevWGxDcLinbT/fvYsp0KxGrrujidyi/xXiptlAEctLmE6onJgvWh n0JA== 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=7J1PZEGPvTyxhKQufXDc4OOFjcFwzJJjt2oPZMN+8zw=; b=FEOdPvMF3BqwLwtb/8vL68now+Y0N54m1yHcMQG675BpuDx0WEJj5QV4nwIDur0soO oHRWopMqlQwOgHMtCgmfcKgvV/WkeskJ7yVb41O+FFkckZY9RBdWdRc3nRikI/AxaetG +GHIlp5vnQSnzQ+vCKaRW2repKBzgWGgor24QsJJCfjlFBkgI68TCjHV1d4SGsv8m3Nb FE8Yd8nAkLqN89J0ocuIxvo7ZZehb0aP7dPOHIAv24F+x+2iiXaVFiR9w1jJulNM6ROG dfFLNs2qbZ+qRPNjj03CuOJeRd6SCHjFtQd2ypfWinW6GmCIF+6TQV0B++2RbV8uXLb1 i3fQ== X-Gm-Message-State: APjAAAXPFbCf8fd8fIcneIL3+wUL+LKWOKWAthkvOT/BLEMgnu5yK4zu aO0FO3N/Ys8rtZDJgpLp32M= X-Received: by 2002:a63:c04e:: with SMTP id z14mr16394262pgi.20.1552899510939; Mon, 18 Mar 2019 01:58:30 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id k8sm11147024pgq.37.2019.03.18.01.58.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 01:58:30 -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, Yuyang Du Subject: [PATCH v2 17/19] locking/lockdep: Combine check_noncircular and check_redundant Date: Mon, 18 Mar 2019 16:57:31 +0800 Message-Id: <20190318085733.3143-18-duyuyang@gmail.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190318085733.3143-1-duyuyang@gmail.com> References: <20190318085733.3143-1-duyuyang@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These two functions are essentially duplicates, combine them. No functional change. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 3dbb4d0..90d58cc 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1677,29 +1677,18 @@ unsigned long lockdep_count_backward_deps(struct lock_class *class) } /* - * Prove that the dependency graph starting at can not - * lead to . Print an error and return 0 if it does. + * Prove that the dependency graph starting at can not + * lead to . If existent, there is a circle when adding + * a -> dependency. + * + * Print an error and return 0 if it does exist. */ static noinline int -check_noncircular(struct lock_list *root, struct lock_class *target, +check_nonexistent(struct lock_list *root, struct lock_class *target, struct lock_list **target_entry) { int result; - debug_atomic_inc(nr_cyclic_checks); - - result = __bfs_forwards(root, target, class_equal, target_entry); - - return result; -} - -static noinline int -check_redundant(struct lock_list *root, struct lock_class *target, - struct lock_list **target_entry) -{ - int result; - - debug_atomic_inc(nr_redundant_checks); result = __bfs_forwards(root, target, class_equal, target_entry); @@ -2235,7 +2224,8 @@ static void print_deadlock_scenario(struct held_lock *nxt, */ this.class = hlock_class(next); this.parent = NULL; - ret = check_noncircular(&this, hlock_class(prev), &target_entry); + debug_atomic_inc(nr_cyclic_checks); + ret = check_nonexistent(&this, hlock_class(prev), &target_entry); if (unlikely(!ret)) { if (!trace->entries) { /* @@ -2287,7 +2277,8 @@ static void print_deadlock_scenario(struct held_lock *nxt, */ this.class = hlock_class(prev); this.parent = NULL; - ret = check_redundant(&this, hlock_class(next), &target_entry); + debug_atomic_inc(nr_redundant_checks); + ret = check_nonexistent(&this, hlock_class(next), &target_entry); if (!ret) { debug_atomic_inc(nr_redundant); return 2; -- 1.8.3.1