mm/hugetlb: allow architectures to override huge_pte_clear()
Subsystems (4)
[email protected]
maintainerPATCH 83/108 mm/hugetlb: allow architectures to override huge_pte_clear()
From: Punit Agrawal <[email protected]>
Subject: mm/hugetlb: allow architectures to override huge_pte_clear()
When unmapping a hugepage range, huge_pte_clear() is used to clear the page table entries that are marked as not present. huge_pte_clear() internally just ends up calling pte_clear() which does not correctly deal with hugepages consisting of contiguous page table entries.
Add a size argument to address this issue and allow architectures to override huge_pte_clear() by wrapping it in a #ifndef block.
Update s390 implementation with the size parameter as well.
Note that the change only affects huge_pte_clear() - the other generic hugetlb functions don't need any change.
---
arch/s390/include/asm/hugetlb.h | 2 +- include/asm-generic/hugetlb.h | 4 +++- mm/hugetlb.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-)
arch/s390/include/asm/hugetlb.h renamed from arch/s390/include/asm/hugetlb.h~mm-hugetlb-allow-architectures-to-override-huge_pte_clear +1 -1
@@ -39,7 +39,7 @@ static inline int prepare_hugepage_range#define arch_clear_hugepage_flags (page) do { } while (0)static inline void huge_pte_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) +pte_t *ptep,unsigned long sz) {if ((pte_val (*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)pte_val (*ptep) = _REGION3_ENTRY_EMPTY;
include/asm-generic/hugetlb.h renamed from include/asm-generic/hugetlb.h~mm-hugetlb-allow-architectures-to-override-huge_pte_clear +3 -1
@@ -31,10 +31,12 @@ static inline pte_t huge_pte_modify(pte_ return pte_modify(pte, newprot); } +#ifndef huge_pte_clearstatic inline void huge_pte_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) +pte_t *ptep,unsigned long sz) {pte_clear (mm, addr, ptep); } +#endif #endif /* _ASM_GENERIC_HUGETLB_H */
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-allow-architectures-to-override-huge_pte_clear +1 -1
@@ -3351,7 +3351,7 @@ void __unmap_hugepage_range(struct mmu_g* unmapped and its refcount is dropped, so just clear pte here. */ if (unlikely (!pte_present (pte))) { -huge_pte_clear (mm, address, ptep); +huge_pte_clear (mm, address, ptep, sz);spin_unlock (ptl);continue ; }
_