Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Cyrill Gorcunov and committed by
Linus Torvalds
c86c97ff b43790ee

+9 -5
+9 -5
fs/proc/task_mmu.c
··· 737 737 ptent = pte_file_clear_soft_dirty(ptent); 738 738 } 739 739 740 - if (vma->vm_flags & VM_SOFTDIRTY) 741 - vma->vm_flags &= ~VM_SOFTDIRTY; 742 - 743 740 set_pte_at(vma->vm_mm, addr, pte, ptent); 744 741 #endif 745 742 } ··· 804 807 805 808 if (type == CLEAR_REFS_SOFT_DIRTY) { 806 809 soft_dirty_cleared = true; 807 - pr_warn_once("The pagemap bits 55-60 has changed their meaning! " 808 - "See the linux/Documentation/vm/pagemap.txt for details.\n"); 810 + pr_warn_once("The pagemap bits 55-60 has changed their meaning!" 811 + " See the linux/Documentation/vm/pagemap.txt for " 812 + "details.\n"); 809 813 } 810 814 811 815 task = get_proc_task(file_inode(file)); ··· 837 839 * 838 840 * Writing 3 to /proc/pid/clear_refs only affects file 839 841 * mapped pages. 842 + * 843 + * Writing 4 to /proc/pid/clear_refs affects all pages. 840 844 */ 841 845 if (type == CLEAR_REFS_ANON && vma->vm_file) 842 846 continue; 843 847 if (type == CLEAR_REFS_MAPPED && !vma->vm_file) 844 848 continue; 849 + if (type == CLEAR_REFS_SOFT_DIRTY) { 850 + if (vma->vm_flags & VM_SOFTDIRTY) 851 + vma->vm_flags &= ~VM_SOFTDIRTY; 852 + } 845 853 walk_page_range(vma->vm_start, vma->vm_end, 846 854 &clear_refs_walk); 847 855 }