提交 d2782ad5 编写于 作者: L Liam Howlett 提交者: Zheng Zengkai

mmap_lock: change trace and locking order

mainline inclusion
from mainline-5.15-rc1
commit 10994316
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4RL0T
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10994316089c9682f2fbe0be0b1e82bcaf5f4e8c

-------------------------------------------------

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/20210903022041.1843024-1-Liam.Howlett@oracle.comSigned-off-by: NLiam R. Howlett <Liam.Howlett@oracle.com>
Suggested-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: NMatthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michel Lespinasse <walken.cr@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 10994316)
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
Reviewed-by: Kefeng Wang<wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 ea9e92bb
...@@ -101,14 +101,14 @@ static inline bool mmap_write_trylock(struct mm_struct *mm) ...@@ -101,14 +101,14 @@ static inline bool mmap_write_trylock(struct mm_struct *mm)
static inline void mmap_write_unlock(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); __mmap_lock_trace_released(mm, true);
up_write(&mm->mmap_lock);
} }
static inline void mmap_write_downgrade(struct mm_struct *mm) static inline void mmap_write_downgrade(struct mm_struct *mm)
{ {
downgrade_write(&mm->mmap_lock);
__mmap_lock_trace_acquire_returned(mm, false, true); __mmap_lock_trace_acquire_returned(mm, false, true);
downgrade_write(&mm->mmap_lock);
} }
static inline void mmap_read_lock(struct mm_struct *mm) static inline void mmap_read_lock(struct mm_struct *mm)
...@@ -140,8 +140,8 @@ static inline bool mmap_read_trylock(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) static inline void mmap_read_unlock(struct mm_struct *mm)
{ {
up_read(&mm->mmap_lock);
__mmap_lock_trace_released(mm, false); __mmap_lock_trace_released(mm, false);
up_read(&mm->mmap_lock);
} }
static inline bool mmap_read_trylock_non_owner(struct mm_struct *mm) 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) ...@@ -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) 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); __mmap_lock_trace_released(mm, false);
up_read_non_owner(&mm->mmap_lock);
} }
static inline void mmap_assert_locked(struct mm_struct *mm) static inline void mmap_assert_locked(struct mm_struct *mm)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册