Skip to content

Commit

Permalink
mmap_lock: change trace and locking order
Browse files Browse the repository at this point in the history
Print to the trace log before releasing the lock to avoid racing with
other trace log printers of the same lock type.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Liam R. Howlett <[email protected]>
Suggested-by: Steven Rostedt (VMware) <[email protected]>
Reviewed-by: Matthew Wilcox (Oracle) <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
howlett authored and torvalds committed Sep 9, 2021
1 parent 053cfda commit 1099431
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/linux/mmap_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -155,8 +155,8 @@ static inline bool mmap_read_trylock_non_owner(struct mm_struct *mm)

static inline void mmap_read_unlock_non_owner(struct mm_struct *mm)
{
up_read_non_owner(&mm->mmap_lock);
__mmap_lock_trace_released(mm, false);
up_read_non_owner(&mm->mmap_lock);
}

static inline void mmap_assert_locked(struct mm_struct *mm)
Expand Down

0 comments on commit 1099431

Please sign in to comment.