[PATCH v3 16/18] locking/lockdep: Combine check_noncircular and check_redundant

From: Yuyang Du
Date: Thu Mar 21 2019 - 03:58:27 EST


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 <duyuyang@xxxxxxxxx>
---
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 <entry> can not
- * lead to <target>. Print an error and return 0 if it does.
+ * Prove that the dependency graph starting at <root> can not
+ * lead to <target>. If existent, there is a circle when adding
+ * a <target> -> <root> 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