Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1727234
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC tip/locking v2 06/13] lockdep: Adjust check_redundant() for recursive read change |
| Date | 2017-09-06 10:40 +0200 |
| Message-ID | <umE2n-7tt-29@gated-at.bofh.it> (permalink) |
| References | <umDSG-7ph-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
As we have four kinds of dependencies now, check_redundant() should only
report redundant if we have a dependency path which is equal or
_stronger_ than the current dependency. For example if check_prev_add()
we have:
prev->read == 2 && next->read != 2
, we should only report redundant if we find a path like:
prev--(RN)-->....--(*N)-->next
and if we have:
prev->read == 2 && next->read == 2
, we could report redundant if we find a path like:
prev--(RN)-->....--(*N)-->next
or
prev--(RN)-->....--(*R)-->next
To do so, we need to pass the recursive-read status of next into
check_redundant(). This patch changes the parameter of check_redundant()
and the match function to achieve this.
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/locking/lockdep.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 3c43af353ea0..d9959f25247a 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1337,9 +1337,12 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth,
return 0;
}
-static inline int class_equal(struct lock_list *entry, void *data)
+static inline int hlock_equal(struct lock_list *entry, void *data)
{
- return entry->class == data;
+ struct held_lock *hlock = (struct held_lock *)data;
+
+ return hlock_class(hlock) == entry->class &&
+ (hlock->read == 2 || !entry->is_rr);
}
static noinline int print_circular_bug(struct lock_list *this,
@@ -1473,14 +1476,14 @@ check_noncircular(struct lock_list *root, struct lock_class *target,
}
static noinline enum bfs_result
-check_redundant(struct lock_list *root, struct lock_class *target,
+check_redundant(struct lock_list *root, struct held_lock *target,
struct lock_list **target_entry)
{
enum bfs_result result;
debug_atomic_inc(nr_redundant_checks);
- result = __bfs_forwards(root, target, class_equal, target_entry);
+ result = __bfs_forwards(root, target, hlock_equal, target_entry);
return result;
}
@@ -2047,7 +2050,7 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
* Is the <prev> -> <next> link redundant?
*/
bfs_init_root(&this, prev);
- ret = check_redundant(&this, hlock_class(next), &target_entry);
+ ret = check_redundant(&this, next, &target_entry);
if (ret == BFS_RMATCH) {
debug_atomic_inc(nr_redundant);
return 2;
--
2.14.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC tip/locking v2 00/13] lockdep: Support deadlock detection for recursive read locks Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:30 +0200
[RFC tip/locking v2 01/13] lockdep: Demagic the return value of BFS Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:30 +0200
[RFC tip/locking v2 08/13] lockdep: Fix recursive read lock related safe->unsafe detection Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 12/13] lockdep/selftest: Unleash irq_read_recursion2 and add more Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 07/13] lockdep: Support deadlock detection for recursive read in check_noncircular() Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 13/13] lockdep/selftest: Add more recursive read related test cases Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 03/13] lockdep: Change the meanings of LOCK_{USED_IN, ENABLED}_*_{READ} Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 04/13] lockdep: Introduce lock_list::dep Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 05/13] lockdep: Extend __bfs() to work with multiple kinds of dependencies Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 09/13] lockdep: Add recursive read locks into dependency graph Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 11/13] lockdep: Take read/write status in consideration when generate chainkey Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 02/13] lockdep: Make __bfs() visit every dependency rather than every class until a match Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 06/13] lockdep: Adjust check_redundant() for recursive read change Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
[RFC tip/locking v2 10/13] lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:40 +0200
Re: [RFC tip/locking v2 00/13] lockdep: Support deadlock detection for recursive read locks Boqun Feng <boqun.feng@gmail.com> - 2017-09-06 10:50 +0200
csiph-web