Skip to content

Commit 1099431

Browse files
howletttorvalds
authored andcommitted
mmap_lock: change trace and locking order
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]>
1 parent 053cfda commit 1099431

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/linux/mmap_lock.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ static inline bool mmap_write_trylock(struct mm_struct *mm)
101101

102102
static inline void mmap_write_unlock(struct mm_struct *mm)
103103
{
104-
up_write(&mm->mmap_lock);
105104
__mmap_lock_trace_released(mm, true);
105+
up_write(&mm->mmap_lock);
106106
}
107107

108108
static inline void mmap_write_downgrade(struct mm_struct *mm)
109109
{
110-
downgrade_write(&mm->mmap_lock);
111110
__mmap_lock_trace_acquire_returned(mm, false, true);
111+
downgrade_write(&mm->mmap_lock);
112112
}
113113

114114
static inline void mmap_read_lock(struct mm_struct *mm)
@@ -140,8 +140,8 @@ static inline bool mmap_read_trylock(struct mm_struct *mm)
140140

141141
static inline void mmap_read_unlock(struct mm_struct *mm)
142142
{
143-
up_read(&mm->mmap_lock);
144143
__mmap_lock_trace_released(mm, false);
144+
up_read(&mm->mmap_lock);
145145
}
146146

147147
static inline bool mmap_read_trylock_non_owner(struct mm_struct *mm)
@@ -155,8 +155,8 @@ static inline bool mmap_read_trylock_non_owner(struct mm_struct *mm)
155155

156156
static inline void mmap_read_unlock_non_owner(struct mm_struct *mm)
157157
{
158-
up_read_non_owner(&mm->mmap_lock);
159158
__mmap_lock_trace_released(mm, false);
159+
up_read_non_owner(&mm->mmap_lock);
160160
}
161161

162162
static inline void mmap_assert_locked(struct mm_struct *mm)

0 commit comments

Comments
 (0)