LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] mmap_lock: Change trace and locking order
@ 2021-09-03  1:35 Liam Howlett
  2021-09-03  1:42 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Liam Howlett @ 2021-09-03  1:35 UTC (permalink / raw)
  To: linux-mm, linux-kernel, Andrew Morton
  Cc: Steven Rostedt, Michel Lespinasse, Vlastimil Babka

Print to the trace log before releasing the lock to avoid racing with
other trace log printers of the same lock type.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/linux/mmap_lock.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h
index 0540f0156f58..5d2b343e39e7 100644
--- a/include/linux/mmap_lock.h
+++ b/include/linux/mmap_lock.h
@@ -101,14 +101,14 @@ static inline bool mmap_write_trylock(struct mm_struct *mm)
 
 static inline void mmap_write_unlock(struct mm_struct *mm)
 {
-	up_write(&mm->mmap_lock);
 	__mmap_lock_trace_released(mm, true);
+	up_write(&mm->mmap_lock);
 }
 
 static inline void mmap_write_downgrade(struct mm_struct *mm)
 {
-	downgrade_write(&mm->mmap_lock);
 	__mmap_lock_trace_acquire_returned(mm, false, true);
+	downgrade_write(&mm->mmap_lock);
 }
 
 static inline void mmap_read_lock(struct mm_struct *mm)
@@ -140,8 +140,8 @@ static inline bool mmap_read_trylock(struct mm_struct *mm)
 
 static inline void mmap_read_unlock(struct mm_struct *mm)
 {
-	up_read(&mm->mmap_lock);
 	__mmap_lock_trace_released(mm, false);
+	up_read(&mm->mmap_lock);
 }
 
 static inline bool mmap_read_trylock_non_owner(struct mm_struct *mm)
-- 
2.30.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmap_lock: Change trace and locking order
  2021-09-03  1:35 [PATCH] mmap_lock: Change trace and locking order Liam Howlett
@ 2021-09-03  1:42 ` Matthew Wilcox
  2021-09-03  2:09   ` Liam Howlett
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2021-09-03  1:42 UTC (permalink / raw)
  To: Liam Howlett
  Cc: linux-mm, linux-kernel, Andrew Morton, Steven Rostedt,
	Michel Lespinasse, Vlastimil Babka

On Fri, Sep 03, 2021 at 01:35:31AM +0000, Liam Howlett wrote:
> Print to the trace log before releasing the lock to avoid racing with
> other trace log printers of the same lock type.

Aren't you missing mmap_read_unlock_non_owner()?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmap_lock: Change trace and locking order
  2021-09-03  1:42 ` Matthew Wilcox
@ 2021-09-03  2:09   ` Liam Howlett
  0 siblings, 0 replies; 3+ messages in thread
From: Liam Howlett @ 2021-09-03  2:09 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-mm, linux-kernel, Andrew Morton, Steven Rostedt,
	Michel Lespinasse, Vlastimil Babka

* Matthew Wilcox <willy@infradead.org> [210902 21:43]:
> On Fri, Sep 03, 2021 at 01:35:31AM +0000, Liam Howlett wrote:
> > Print to the trace log before releasing the lock to avoid racing with
> > other trace log printers of the same lock type.
> 
> Aren't you missing mmap_read_unlock_non_owner()?

Yes I am.  I'll send out v2 shortly.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-03  2:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  1:35 [PATCH] mmap_lock: Change trace and locking order Liam Howlett
2021-09-03  1:42 ` Matthew Wilcox
2021-09-03  2:09   ` Liam Howlett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).