i386 mm: use pte_update() in ptep_test_and_clear_dirty()

It is not safe to use pte_update_defer() in ptep_test_and_clear_young():
its only user, /proc/<pid>/clear_refs, drops pte lock before flushing TLB.
Use the safe though less efficient pte_update() paravirtop in its place.
Likewise in ptep_test_and_clear_dirty(), though that has no current use.

These are macros (header file dependency stops them from becoming inline
functions), so be more liberal with the underscores and parentheses.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Cc: Zachary Amsden <zach@vmware.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Hugh Dickins and committed by Linus Torvalds d6f8bb13 30475cc1

+14 -12
+14 -12
include/asm-i386/pgtable.h
··· 295 295 296 296 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY 297 297 #define ptep_test_and_clear_dirty(vma, addr, ptep) ({ \ 298 - int ret = 0; \ 299 - if (pte_dirty(*ptep)) \ 300 - ret = test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte_low); \ 301 - if (ret) \ 302 - pte_update_defer(vma->vm_mm, addr, ptep); \ 303 - ret; \ 298 + int __ret = 0; \ 299 + if (pte_dirty(*(ptep))) \ 300 + __ret = test_and_clear_bit(_PAGE_BIT_DIRTY, \ 301 + &(ptep)->pte_low); \ 302 + if (__ret) \ 303 + pte_update((vma)->vm_mm, addr, ptep); \ 304 + __ret; \ 304 305 }) 305 306 306 307 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 307 308 #define ptep_test_and_clear_young(vma, addr, ptep) ({ \ 308 - int ret = 0; \ 309 - if (pte_young(*ptep)) \ 310 - ret = test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte_low); \ 311 - if (ret) \ 312 - pte_update_defer(vma->vm_mm, addr, ptep); \ 313 - ret; \ 309 + int __ret = 0; \ 310 + if (pte_young(*(ptep))) \ 311 + __ret = test_and_clear_bit(_PAGE_BIT_ACCESSED, \ 312 + &(ptep)->pte_low); \ 313 + if (__ret) \ 314 + pte_update((vma)->vm_mm, addr, ptep); \ 315 + __ret; \ 314 316 }) 315 317 316 318 /*