Commit 25e4df5b authored by Zachary Amsden's avatar Zachary Amsden Committed by Linus Torvalds
Browse files

[PATCH] paravirt: combine flush accessed dirty.patch

Remove ptep_test_and_clear_{dirty|young} from i386, and instead use the
dominating functions, ptep_clear_flush_{dirty|young}.  This allows the TLB
page flush to be contained in the same macro, and allows for an eager
optimization - if reading the PTE initially returned dirty/accessed, we can
assume the fact that no subsequent update to the PTE which cleared accessed /
dirty has occurred, as the only way A/D bits can change without holding the
page table lock is if a remote processor clears them.  This eliminates an
extra branch which came from the generic version of the code, as we know that
no other CPU could have cleared the A/D bit, so the flush will always be

We still export these two defines, even though we do not actually define
the macros in the i386 code:


The reason for this is that the only use of these functions is within the
generic clear_flush functions, and we want a strong guarantee that there
are no other users of these functions, so we want to prevent the generic
code from defining them for us.
Signed-off-by: default avatarZachary Amsden <>
Cc: Rusty Russell <>
Cc: Jeremy Fitzhardinge <>
Cc: Andi Kleen <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 6606c3e0
...@@ -262,21 +262,36 @@ do { \ ...@@ -262,21 +262,36 @@ do { \
} \ } \
} while (0) } while (0)
* We don't actually have these, but we want to advertise them so that
* we can encompass the flush here.
static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
if (!pte_dirty(*ptep))
return 0;
return test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte_low);
static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
if (!pte_young(*ptep)) #define ptep_clear_flush_dirty(vma, address, ptep) \
return 0; ({ \
return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte_low); int __dirty; \
} __dirty = pte_dirty(*(ptep)); \
if (__dirty) { \
clear_bit(_PAGE_BIT_DIRTY, &(ptep)->pte_low); \
flush_tlb_page(vma, address); \
} \
__dirty; \
#define ptep_clear_flush_young(vma, address, ptep) \
({ \
int __young; \
__young = pte_young(*(ptep)); \
if (__young) { \
clear_bit(_PAGE_BIT_ACCESSED, &(ptep)->pte_low); \
flush_tlb_page(vma, address); \
} \
__young; \
static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full) static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment