sparc64: update pmdp_invalidate() to return old pmd value
PATCH 67/119 sparc64: update pmdp_invalidate() to return old pmd value
From: Nitin Gupta <[email protected]>
Subject: sparc64: update pmdp_invalidate() to return old pmd value
It's required to avoid losing dirty and accessed bits.
[[email protected]: add a `do' to the do-while loop]
Signed-off-by Nitin Gupta <[email protected]>
Signed-off-by Kirill A. Shutemov <[email protected]>
Cc David Miller <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Michal Hocko <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
arch/sparc/include/asm/pgtable_64.h | 2 +- arch/sparc/mm/tlb.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-)
arch/sparc/include/asm/pgtable_64.h renamed from arch/sparc/include/asm/pgtable_64.h~sparc64-update-pmdp_invalidate-to-return-old-pmd-value +1 -1
@@ -1010,7 +1010,7 @@ void update_mmu_cache_pmd(struct vm_area pmd_t *pmd);#define __HAVE_ARCH_PMDP_INVALIDATE -extern void pmdp_invalidate (struct vm_area_struct *vma,unsigned long address, +extern pmd_t pmdp_invalidate (struct vm_area_struct *vma,unsigned long address,pmd_t *pmdp);#define __HAVE_ARCH_PGTABLE_DEPOSIT
arch/sparc/mm/tlb.c renamed from arch/sparc/mm/tlb.c~sparc64-update-pmdp_invalidate-to-return-old-pmd-value +13 -2
@@ -219,17 +219,28 @@ void set_pmd_at(struct mm_struct *mm, un } } +static inline pmd_t pmdp_establish (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp,pmd_t pmd) +{ +pmd_t old; + +do { + old = *pmdp; + }while (cmpxchg64 (&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd); + +return old; +} +/* * This routine is only called when splitting a THP */ -void pmdp_invalidate (struct vm_area_struct *vma,unsigned long address, +pmd_t pmdp_invalidate (struct vm_area_struct *vma,unsigned long address,pmd_t *pmdp) { -pmd_t entry = *pmdp;