Skip to content

Commit 907dc16

Browse files
lgebyungchulparkIngo Molnar
authored andcommitted
locking/lockdep: Fix the rollback and overwrite detection logic in crossrelease
As Boqun Feng pointed out, current->hist_id should be aligned with the latest valid xhlock->hist_id so that hist_id_save[] storing current->hist_id can be comparable with xhlock->hist_id. Fix it. Additionally, the condition for overwrite-detection should be the opposite. Fix the code and the comments as well. <- direction to visit hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh (h: history) ^^ ^ || start from here |previous entry current entry Reported-by: Boqun Feng <[email protected]> Signed-off-by: Byungchul Park <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] [ Improve the comments some more. ] Signed-off-by: Ingo Molnar <[email protected]>
1 parent a10b5c5 commit 907dc16

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/locking/lockdep.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4853,7 +4853,7 @@ static void add_xhlock(struct held_lock *hlock)
48534853

48544854
/* Initialize hist_lock's members */
48554855
xhlock->hlock = *hlock;
4856-
xhlock->hist_id = current->hist_id++;
4856+
xhlock->hist_id = ++current->hist_id;
48574857

48584858
xhlock->trace.nr_entries = 0;
48594859
xhlock->trace.max_entries = MAX_XHLOCK_TRACE_ENTRIES;
@@ -5029,12 +5029,12 @@ static void commit_xhlocks(struct cross_lock *xlock)
50295029
break;
50305030

50315031
/*
5032-
* Filter out the cases that the ring buffer was
5033-
* overwritten and the previous entry has a bigger
5034-
* hist_id than the following one, which is impossible
5035-
* otherwise.
5032+
* Filter out the cases where the ring buffer was
5033+
* overwritten and the current entry has a bigger
5034+
* hist_id than the previous one, which is impossible
5035+
* otherwise:
50365036
*/
5037-
if (unlikely(before(xhlock->hist_id, prev_hist_id)))
5037+
if (unlikely(before(prev_hist_id, xhlock->hist_id)))
50385038
break;
50395039

50405040
prev_hist_id = xhlock->hist_id;

0 commit comments

Comments
 (0)