mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
UPSTREAM: mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
Provide vm_flags_reset_once() and replace the vm_flags updates which used
WRITE_ONCE() to prevent compiler optimizations.
Link: https://lkml.kernel.org/r/20230201000116.1333160-1-surenb@google.com
Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 601c3c29db)
Bug: 161210518
Change-Id: Ied961a1bfbdc25b79268ba04515960c664052d61
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
committed by
Carlos Llamas
parent
75977e5919
commit
ef8351241d
@@ -649,6 +649,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
|
|||||||
vm_flags_init(vma, flags);
|
vm_flags_init(vma, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void vm_flags_reset_once(struct vm_area_struct *vma,
|
||||||
|
vm_flags_t flags)
|
||||||
|
{
|
||||||
|
mmap_assert_write_locked(vma->vm_mm);
|
||||||
|
WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void vm_flags_set(struct vm_area_struct *vma,
|
static inline void vm_flags_set(struct vm_area_struct *vma,
|
||||||
vm_flags_t flags)
|
vm_flags_t flags)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
|
|||||||
*/
|
*/
|
||||||
if (newflags & VM_LOCKED)
|
if (newflags & VM_LOCKED)
|
||||||
newflags |= VM_IO;
|
newflags |= VM_IO;
|
||||||
vm_flags_reset(vma, newflags);
|
vm_flags_reset_once(vma, newflags);
|
||||||
|
|
||||||
lru_add_drain();
|
lru_add_drain();
|
||||||
walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
|
walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
|
||||||
@@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
|
|||||||
|
|
||||||
if (newflags & VM_IO) {
|
if (newflags & VM_IO) {
|
||||||
newflags &= ~VM_IO;
|
newflags &= ~VM_IO;
|
||||||
vm_flags_reset(vma, newflags);
|
vm_flags_reset_once(vma, newflags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user