Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp430408img; Thu, 21 Mar 2019 00:59:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyR298xCCF3bLa5BVB5k23WSxRkVom468JY2UnfUhI0cgj8yyDflJC1fRL/dwoghyNKv+94 X-Received: by 2002:a62:b415:: with SMTP id h21mr2074380pfn.26.1553155179243; Thu, 21 Mar 2019 00:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553155179; cv=none; d=google.com; s=arc-20160816; b=kPOmdiYadxLF/aab5OSt7XpirMBdVfNx5wYXPbbdv4HSzOmhefWKx7OAX4kHqi38pV SEdjHFVexnm5JnEqD2jAHz9w2OCPGnKMdVnOLQtxKhcWQ9n/f2aQDgL2z3bllPU8lIoI XHQYLw6ksgJlN8YLd4NAzfHtKgIe/nFUhpy7jqRB5tJVizQwaIFR4JBpJ9JXTNx0Q1NR IUW2OziSYo9tt/9JS80DwVzLdUgTFLSqW+dIy562gcxgFZZ1isWnkEK9xFg2bkduPhnw 6K3smjGHw3c16sD4Wlq+X/Vf1e7Nd1Iof0L5xmm+Frx3YsoMC1fDDD02hb5hQaYiOM7p 1PFw== 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=HaYMXNuuKlOKGTu/I8pMrDGtm6cT2FsnJYHwPUacK/Y=; b=ds5qK5ticDdm3qnxPcC84eRf175ixlLqWLgGCWZbvVmRbr7dvX+ZRb0e51PuJlQ9Xc RkMltSTTVA+HAd9vcCzbqJOKO/xtDA+NZLw+V5PVH7X2ya8wMSjWo3F5ECuqrlf1rb6g 1Nm8aGH38YCtecmFt9z69dRHwUHcRTwG3upLjsr9VvnjdpgmeoJEP4YY88TopAM+gt8V zd/zBbuOrVH18k9R00oerFW2m5VzpgpHDXa7bO4Oxn9dMdHc7H/NSiPVOFppuCMEXXPk eaeX9ocR0bIRvDD32cZIynjjPpwZNgpjmPum9ou3D38GSR92nMenLeP1FHMzJu0E4uqW GY1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cnJL+pPZ; 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 3si4045818plb.138.2019.03.21.00.59.24; Thu, 21 Mar 2019 00:59:39 -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=cnJL+pPZ; 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 S1728123AbfCUH6Z (ORCPT + 99 others); Thu, 21 Mar 2019 03:58:25 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43754 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbfCUH6W (ORCPT ); Thu, 21 Mar 2019 03:58:22 -0400 Received: by mail-pg1-f195.google.com with SMTP id l11so3656405pgq.10 for ; Thu, 21 Mar 2019 00:58:21 -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=HaYMXNuuKlOKGTu/I8pMrDGtm6cT2FsnJYHwPUacK/Y=; b=cnJL+pPZnEmNlTQs78ttYDf3qA1kFiCRHjuMaD7m6s81btGOzwgHsFqHOwE5M1f7QW lVKAgMv6FFZVsfJIhOJ+3dlgcpx/GAz0AI0ekdCz+hKBCHHEnoSCILfL8reQTrbYyz0f imH9ayjiUXszZfOMv3tYA6RD9OUffdWVk6DK+5kKSMI4qUXKCNaI8NvXWK+ICLW0b5aC kYVTEj7mPK4Ju9+owBfM+5AtL2rjzDRZOtp3aHu+xyjNlV+Ymj+fab+zxXmxUzllpvo2 0rRehDJr7Nd5u5R1FtUWh5X5NvGbwDIgd6VFo/Q8kDuy6QuiMDt5Jff9siTRNjw1curn coRQ== 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=HaYMXNuuKlOKGTu/I8pMrDGtm6cT2FsnJYHwPUacK/Y=; b=N3InSRNsE6ODMP7OEv1S/SqASlWA0I5MiaQSZBA436BePCWg/UJbUgutbYc7SBbHv+ ZzHprc9Ra6sIi66GsNSgHP9vY4zhPj8OABJ+3LFFAWKLaLFTXdzVIRu56i9uchfujurq 28bwjXn9DfTKgB1s1pEJbqztbZ9dQJRJE+Eid4ae0WBt+ajwhZIMX7UBsI1IalR5qYnS LGeDkmeVF8todMLgQ+lO6TUl5q+a0Rk3CVGAJeN8i8KZnaQOgHLMqv8k1NAcKytI9pYG BIXxSkqBYvYVCYxH5/TmiK9g6fLKQJAFLijYiI8/sQyZjlbP6PksClSO2SY9J+O7XCSt klBg== X-Gm-Message-State: APjAAAUx+NKAJ8WujiM+Pj5E9F5Y+cnuZDgNqwIu/YABi12S7uxLaYVl WDYb5LZsjMR8Bj/PmWYU8a4= X-Received: by 2002:a17:902:1123:: with SMTP id d32mr2173059pla.16.1553155101383; Thu, 21 Mar 2019 00:58:21 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id e184sm6467148pfc.143.2019.03.21.00.58.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 00:58:20 -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 16/18] locking/lockdep: Combine check_noncircular and check_redundant Date: Thu, 21 Mar 2019 15:57:23 +0800 Message-Id: <20190321075725.14054-17-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 These two functions are essentially duplicates, combine them into check_nonexistent(). Also update the comment on it. No functional change. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index cd6792c..8202318 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1688,29 +1688,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, - struct lock_list **target_entry) +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); @@ -2246,7 +2235,8 @@ static inline void inc_chains(void) */ 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) { /* @@ -2298,7 +2288,8 @@ static inline void inc_chains(void) */ 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