Skip to content

Commit c86c97f

Browse files
Cyrill Gorcunovtorvalds
authored andcommitted
mm: softdirty: clear VM_SOFTDIRTY flag inside clear_refs_write() instead of clear_soft_dirty()
clear_refs_write() is called earlier than clear_soft_dirty() and it is more natural to clear VM_SOFTDIRTY (which belongs to VMA entry but not PTEs) that early instead of clearing it a way deeper inside call chain. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Hugh Dickins <hughd@google.com> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b43790e commit c86c97f

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎fs/proc/task_mmu.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,6 @@ static inline void clear_soft_dirty(struct vm_area_struct *vma,
737737
ptent = pte_file_clear_soft_dirty(ptent);
738738
}
739739

740-
if (vma->vm_flags & VM_SOFTDIRTY)
741-
vma->vm_flags &= ~VM_SOFTDIRTY;
742-
743740
set_pte_at(vma->vm_mm, addr, pte, ptent);
744741
#endif
745742
}
@@ -807,8 +804,9 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
807804

808805
if (type == CLEAR_REFS_SOFT_DIRTY) {
809806
soft_dirty_cleared = true;
810-
pr_warn_once("The pagemap bits 55-60 has changed their meaning! "
811-
"See the linux/Documentation/vm/pagemap.txt for details.\n");
807+
pr_warn_once("The pagemap bits 55-60 has changed their meaning!"
808+
" See the linux/Documentation/vm/pagemap.txt for "
809+
"details.\n");
812810
}
813811

814812
task = get_proc_task(file_inode(file));
@@ -839,11 +837,17 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
839837
*
840838
* Writing 3 to /proc/pid/clear_refs only affects file
841839
* mapped pages.
840+
*
841+
* Writing 4 to /proc/pid/clear_refs affects all pages.
842842
*/
843843
if (type == CLEAR_REFS_ANON && vma->vm_file)
844844
continue;
845845
if (type == CLEAR_REFS_MAPPED && !vma->vm_file)
846846
continue;
847+
if (type == CLEAR_REFS_SOFT_DIRTY) {
848+
if (vma->vm_flags & VM_SOFTDIRTY)
849+
vma->vm_flags &= ~VM_SOFTDIRTY;
850+
}
847851
walk_page_range(vma->vm_start, vma->vm_end,
848852
&clear_refs_walk);
849853
}

0 commit comments

Comments
 (0)