Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1710673 > unrolled thread
| Started by | Byungchul Park <byungchul.park@lge.com> |
|---|---|
| First post | 2017-08-14 09:10 +0200 |
| Last post | 2017-08-14 14:00 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/2] Fix a bug in crossrelease Byungchul Park <byungchul.park@lge.com> - 2017-08-14 09:10 +0200
[PATCH 1/2] lockdep: Add a comment about crossrelease_hist_end() in lockdep_sys_exit() Byungchul Park <byungchul.park@lge.com> - 2017-08-14 09:10 +0200
[tip:locking/core] locking/lockdep: Add a comment about crossrelease_hist_end() in lockdep_sys_exit() tip-bot for Byungchul Park <tipbot@zytor.com> - 2017-08-14 13:50 +0200
[PATCH 2/2] lockdep: Fix the rollback and overwrite detection in crossrelease Byungchul Park <byungchul.park@lge.com> - 2017-08-14 09:10 +0200
[tip:locking/core] locking/lockdep: Fix the rollback and overwrite detection logic in crossrelease tip-bot for Byungchul Park <tipbot@zytor.com> - 2017-08-14 14:00 +0200
| From | Byungchul Park <byungchul.park@lge.com> |
|---|---|
| Date | 2017-08-14 09:10 +0200 |
| Subject | [PATCH 0/2] Fix a bug in crossrelease |
| Message-ID | <uehFE-14m-17@gated-at.bofh.it> |
Thanks to Boqun, we found out a bug with regard to the rollback and
overwrite-detection. I like Boqun's or Peterz's suggestions more, but
please consider this fix-up first if we need time to decide which one
to choose.
https://lkml.org/lkml/2017/8/11/383
Byungchul Park (2):
lockdep: Add a comment about crossrelease_hist_end() in
lockdep_sys_exit()
lockdep: Fix the rollback and overwrite detection in crossrelease
kernel/locking/lockdep.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--
1.9.1
[toc] | [next] | [standalone]
| From | Byungchul Park <byungchul.park@lge.com> |
|---|---|
| Date | 2017-08-14 09:10 +0200 |
| Subject | [PATCH 1/2] lockdep: Add a comment about crossrelease_hist_end() in lockdep_sys_exit() |
| Message-ID | <uehFE-14m-19@gated-at.bofh.it> |
| In reply to | #1710673 |
In lockdep_sys_exit(), crossrelease_hist_end() is called unconditionally even when getting here without having started e.g. just after forked. But it's no problem since it anyway would rollback to an invalid element. A comment would be helpful to understand this situation. Signed-off-by: Byungchul Park <byungchul.park@lge.com> --- kernel/locking/lockdep.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 1114dc4..1ae4258 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -4623,6 +4623,10 @@ asmlinkage __visible void lockdep_sys_exit(void) /* * The lock history for each syscall should be independent. So wipe the * slate clean on return to userspace. + * + * crossrelease_hist_end() would work well even when getting here + * without starting just after forked, it rollbacks back the index + * to point to the last which is already invalid. */ crossrelease_hist_end(XHLOCK_PROC); crossrelease_hist_start(XHLOCK_PROC); -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Byungchul Park <tipbot@zytor.com> |
|---|---|
| Date | 2017-08-14 13:50 +0200 |
| Subject | [tip:locking/core] locking/lockdep: Add a comment about crossrelease_hist_end() in lockdep_sys_exit() |
| Message-ID | <uem2C-3DE-9@gated-at.bofh.it> |
| In reply to | #1710675 |
Commit-ID: a10b5c564741cd3b6708f085a1fa892b63c2063d Gitweb: http://git.kernel.org/tip/a10b5c564741cd3b6708f085a1fa892b63c2063d Author: Byungchul Park <byungchul.park@lge.com> AuthorDate: Mon, 14 Aug 2017 16:00:51 +0900 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Mon, 14 Aug 2017 12:52:17 +0200 locking/lockdep: Add a comment about crossrelease_hist_end() in lockdep_sys_exit() In lockdep_sys_exit(), crossrelease_hist_end() is called unconditionally even when getting here without having started e.g. just after forking. But it's no problem since it would roll back to an invalid entry anyway. Add a comment to explain this. Signed-off-by: Byungchul Park <byungchul.park@lge.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: akpm@linux-foundation.org Cc: boqun.feng@gmail.com Cc: kernel-team@lge.com Cc: kirill@shutemov.name Cc: linux-mm@kvack.org Cc: npiggin@gmail.com Cc: walken@google.com Cc: willy@infradead.org Link: http://lkml.kernel.org/r/1502694052-16085-2-git-send-email-byungchul.park@lge.com [ Improved the description and the comments. ] Signed-off-by: Ingo Molnar <mingo@kernel.org> --- kernel/locking/lockdep.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 1114dc4..257931e 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -4623,6 +4623,10 @@ asmlinkage __visible void lockdep_sys_exit(void) /* * The lock history for each syscall should be independent. So wipe the * slate clean on return to userspace. + * + * crossrelease_hist_end() works well here even when getting here + * without starting (i.e. just after forking), because it rolls back + * the index to point to the last entry, which is already invalid. */ crossrelease_hist_end(XHLOCK_PROC); crossrelease_hist_start(XHLOCK_PROC);
[toc] | [prev] | [next] | [standalone]
| From | Byungchul Park <byungchul.park@lge.com> |
|---|---|
| Date | 2017-08-14 09:10 +0200 |
| Subject | [PATCH 2/2] lockdep: Fix the rollback and overwrite detection in crossrelease |
| Message-ID | <uehFF-14m-25@gated-at.bofh.it> |
| In reply to | #1710673 |
As Boqun 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 it with modifying comment.
<- direction to visit
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh (h: history)
^^ ^
|| start from here
|previous entry
current entry
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
kernel/locking/lockdep.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 1ae4258..f0e6649 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -4853,7 +4853,7 @@ static void add_xhlock(struct held_lock *hlock)
/* Initialize hist_lock's members */
xhlock->hlock = *hlock;
- xhlock->hist_id = current->hist_id++;
+ xhlock->hist_id = ++current->hist_id;
xhlock->trace.nr_entries = 0;
xhlock->trace.max_entries = MAX_XHLOCK_TRACE_ENTRIES;
@@ -5030,11 +5030,11 @@ static void commit_xhlocks(struct cross_lock *xlock)
/*
* Filter out the cases that the ring buffer was
- * overwritten and the previous entry has a bigger
- * hist_id than the following one, which is impossible
+ * overwritten and the current entry has a bigger
+ * hist_id than the previous one, which is impossible
* otherwise.
*/
- if (unlikely(before(xhlock->hist_id, prev_hist_id)))
+ if (unlikely(before(prev_hist_id, xhlock->hist_id)))
break;
prev_hist_id = xhlock->hist_id;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Byungchul Park <tipbot@zytor.com> |
|---|---|
| Date | 2017-08-14 14:00 +0200 |
| Subject | [tip:locking/core] locking/lockdep: Fix the rollback and overwrite detection logic in crossrelease |
| Message-ID | <uemcj-3H5-15@gated-at.bofh.it> |
| In reply to | #1710677 |
Commit-ID: 907dc16d7e23ec81a126c9585435494fa1b3a4b7
Gitweb: http://git.kernel.org/tip/907dc16d7e23ec81a126c9585435494fa1b3a4b7
Author: Byungchul Park <byungchul.park@lge.com>
AuthorDate: Mon, 14 Aug 2017 16:00:52 +0900
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 14 Aug 2017 12:52:17 +0200
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 <boqun.feng@gmail.com>
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: akpm@linux-foundation.org
Cc: kernel-team@lge.com
Cc: kirill@shutemov.name
Cc: linux-mm@kvack.org
Cc: npiggin@gmail.com
Cc: walken@google.com
Cc: willy@infradead.org
Link: http://lkml.kernel.org/r/1502694052-16085-3-git-send-email-byungchul.park@lge.com
[ Improve the comments some more. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/locking/lockdep.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 257931e..66011c9 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -4853,7 +4853,7 @@ static void add_xhlock(struct held_lock *hlock)
/* Initialize hist_lock's members */
xhlock->hlock = *hlock;
- xhlock->hist_id = current->hist_id++;
+ xhlock->hist_id = ++current->hist_id;
xhlock->trace.nr_entries = 0;
xhlock->trace.max_entries = MAX_XHLOCK_TRACE_ENTRIES;
@@ -5029,12 +5029,12 @@ static void commit_xhlocks(struct cross_lock *xlock)
break;
/*
- * Filter out the cases that the ring buffer was
- * overwritten and the previous entry has a bigger
- * hist_id than the following one, which is impossible
- * otherwise.
+ * Filter out the cases where the ring buffer was
+ * overwritten and the current entry has a bigger
+ * hist_id than the previous one, which is impossible
+ * otherwise:
*/
- if (unlikely(before(xhlock->hist_id, prev_hist_id)))
+ if (unlikely(before(prev_hist_id, xhlock->hist_id)))
break;
prev_hist_id = xhlock->hist_id;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web