Skip to content

Commit 96ca183

Browse files
andy-shevIngo Molnar
authored andcommitted
locking/lockdep: Move hlock_equal() to the respective #ifdeffery
When hlock_equal() is unused, it prevents kernel builds with clang, `make W=1` and CONFIG_WERROR=y, CONFIG_LOCKDEP=y and CONFIG_LOCKDEP_SMALL=n: lockdep.c:2005:20: error: unused function 'hlock_equal' [-Werror,-Wunused-function] Fix this by moving the function to the respective existing ifdeffery for its the only user. See also: 6863f56 ("kbuild: allow Clang to find unused static inline functions for W=1 build") Fixes: 68e3056 ("lockdep: Adjust check_redundant() for recursive read change") Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Boqun Feng <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Bill Wendling <[email protected]> Cc: Justin Stitt <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Waiman Long <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 92a09c4 commit 96ca183

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

kernel/locking/lockdep.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,41 +1976,6 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth,
19761976
print_circular_bug_entry(entry, depth);
19771977
}
19781978

1979-
/*
1980-
* We are about to add A -> B into the dependency graph, and in __bfs() a
1981-
* strong dependency path A -> .. -> B is found: hlock_class equals
1982-
* entry->class.
1983-
*
1984-
* If A -> .. -> B can replace A -> B in any __bfs() search (means the former
1985-
* is _stronger_ than or equal to the latter), we consider A -> B as redundant.
1986-
* For example if A -> .. -> B is -(EN)-> (i.e. A -(E*)-> .. -(*N)-> B), and A
1987-
* -> B is -(ER)-> or -(EN)->, then we don't need to add A -> B into the
1988-
* dependency graph, as any strong path ..-> A -> B ->.. we can get with
1989-
* having dependency A -> B, we could already get a equivalent path ..-> A ->
1990-
* .. -> B -> .. with A -> .. -> B. Therefore A -> B is redundant.
1991-
*
1992-
* We need to make sure both the start and the end of A -> .. -> B is not
1993-
* weaker than A -> B. For the start part, please see the comment in
1994-
* check_redundant(). For the end part, we need:
1995-
*
1996-
* Either
1997-
*
1998-
* a) A -> B is -(*R)-> (everything is not weaker than that)
1999-
*
2000-
* or
2001-
*
2002-
* b) A -> .. -> B is -(*N)-> (nothing is stronger than this)
2003-
*
2004-
*/
2005-
static inline bool hlock_equal(struct lock_list *entry, void *data)
2006-
{
2007-
struct held_lock *hlock = (struct held_lock *)data;
2008-
2009-
return hlock_class(hlock) == entry->class && /* Found A -> .. -> B */
2010-
(hlock->read == 2 || /* A -> B is -(*R)-> */
2011-
!entry->only_xr); /* A -> .. -> B is -(*N)-> */
2012-
}
2013-
20141979
/*
20151980
* We are about to add B -> A into the dependency graph, and in __bfs() a
20161981
* strong dependency path A -> .. -> B is found: hlock_class equals
@@ -2915,6 +2880,41 @@ static inline bool usage_skip(struct lock_list *entry, void *mask)
29152880
#endif /* CONFIG_TRACE_IRQFLAGS */
29162881

29172882
#ifdef CONFIG_LOCKDEP_SMALL
2883+
/*
2884+
* We are about to add A -> B into the dependency graph, and in __bfs() a
2885+
* strong dependency path A -> .. -> B is found: hlock_class equals
2886+
* entry->class.
2887+
*
2888+
* If A -> .. -> B can replace A -> B in any __bfs() search (means the former
2889+
* is _stronger_ than or equal to the latter), we consider A -> B as redundant.
2890+
* For example if A -> .. -> B is -(EN)-> (i.e. A -(E*)-> .. -(*N)-> B), and A
2891+
* -> B is -(ER)-> or -(EN)->, then we don't need to add A -> B into the
2892+
* dependency graph, as any strong path ..-> A -> B ->.. we can get with
2893+
* having dependency A -> B, we could already get a equivalent path ..-> A ->
2894+
* .. -> B -> .. with A -> .. -> B. Therefore A -> B is redundant.
2895+
*
2896+
* We need to make sure both the start and the end of A -> .. -> B is not
2897+
* weaker than A -> B. For the start part, please see the comment in
2898+
* check_redundant(). For the end part, we need:
2899+
*
2900+
* Either
2901+
*
2902+
* a) A -> B is -(*R)-> (everything is not weaker than that)
2903+
*
2904+
* or
2905+
*
2906+
* b) A -> .. -> B is -(*N)-> (nothing is stronger than this)
2907+
*
2908+
*/
2909+
static inline bool hlock_equal(struct lock_list *entry, void *data)
2910+
{
2911+
struct held_lock *hlock = (struct held_lock *)data;
2912+
2913+
return hlock_class(hlock) == entry->class && /* Found A -> .. -> B */
2914+
(hlock->read == 2 || /* A -> B is -(*R)-> */
2915+
!entry->only_xr); /* A -> .. -> B is -(*N)-> */
2916+
}
2917+
29182918
/*
29192919
* Check that the dependency graph starting at <src> can lead to
29202920
* <target> or not. If it can, <src> -> <target> dependency is already

0 commit comments

Comments
 (0)