TLB flush changes
Subsystems (12)
cover TLB flush changes
Hi,
This patch series add changes to support tracking page size during tlb flush and use the same in ppc64 so that we can do a tlbie with va range. First three patches are already in -mm tree.
Aneesh Kumar K.V (13):
mm/hugetlb: Simplify hugetlb unmap
mm: Change the interface for __tlb_remove_page mm/mmu_gather: Track page size with mmu gather and force flush if page
size change
powerpc/mm/radix: Implement tlb mmu gather flush efficiently powerpc/mm: Make MMU_FTR_RADIX a MMU family feature powerpc/mm/hash: Add helper for finding SLBE LLP encoding powerpc/mm: Use hugetlb flush functions
powerpc/mm: Drop multiple definition of mm_is_core_local powerpc/mm/radix: Add tlb flush of THP ptes powerpc/mm/radix: Rename function and drop unused arg powerpc/mm/radix/hugetlb: Add helper for finding page size from hstate powerpc/mm/hugetlb: Add flush_hugetlb_tlb_range powerpc/mm: remove flush_tlb_page_nohash
arch/arm/include/asm/tlb.h | 29 ++++++- arch/ia64/include/asm/tlb.h | 31 ++++++-- arch/powerpc/include/asm/book3s/64/hugetlb-radix.h | 15 ++++ arch/powerpc/include/asm/book3s/64/mmu-hash.h | 9 +++ arch/powerpc/include/asm/book3s/64/mmu.h | 3 +- arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 5 -- .../powerpc/include/asm/book3s/64/tlbflush-radix.h | 16 ++-- arch/powerpc/include/asm/book3s/64/tlbflush.h | 27 +++++-- arch/powerpc/include/asm/hugetlb.h | 2 +- arch/powerpc/include/asm/kvm_book3s_64.h | 3 +- arch/powerpc/include/asm/mmu.h | 16 ++-- arch/powerpc/include/asm/tlb.h | 13 ++++ arch/powerpc/include/asm/tlbflush.h | 1 - arch/powerpc/kernel/entry_64.S | 2 +- arch/powerpc/kernel/exceptions-64s.S | 8 +- arch/powerpc/kernel/prom.c | 4 +- arch/powerpc/mm/hash_native_64.c | 6 +- arch/powerpc/mm/hugetlbpage-radix.c | 39 ++++------ arch/powerpc/mm/pgtable-book3s64.c | 4 +- arch/powerpc/mm/pgtable.c | 2 +- arch/powerpc/mm/tlb-radix.c | 90 ++++++++++++++++++---- arch/powerpc/mm/tlb_hash32.c | 11 --- arch/powerpc/mm/tlb_nohash.c | 6 -- arch/s390/include/asm/tlb.h | 22 +++++- arch/sh/include/asm/tlb.h | 20 ++++- arch/um/include/asm/tlb.h | 20 ++++- include/asm-generic/tlb.h | 59 +++++++++++--- mm/huge_memory.c | 2 +- mm/hugetlb.c | 64 ++++++++------- mm/memory.c | 27 +++++-- 30 files changed, 390 insertions(+), 166 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/13 mm/hugetlb: Simplify hugetlb unmap
For hugetlb like THP (and unlike regular page), we do tlb flush after dropping ptl. Because of the above, we don't need to track force_flush like we do now. Instead we can simply call tlb_remove_page() which will do the flush if needed.
No functionality change in this patch.
---
NOTE: This patch is already applied to -mm tree
mm/hugetlb.c | 54 +++++++++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 33 deletions(-)
mm/hugetlb.c +21 -33
@@ -3177,7 +3177,6 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma, unsigned long start, unsigned long end, struct page *ref_page) { - int force_flush = 0; struct mm_struct *mm = vma->vm_mm;unsigned long address;pte_t *ptep;
@@ -3196,19 +3195,22 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,tlb_start_vma (tlb, vma);mmu_notifier_invalidate_range_start (mm, mmun_start, mmun_end); address = start; -again:for (; address < end; address += sz) { ptep =huge_pte_offset (mm, address);if (!ptep)continue ; ptl =huge_pte_lock (h, mm, ptep); -if (huge_pmd_unshare (mm, &address, ptep)) - goto unlock; +if (huge_pmd_unshare (mm, &address, ptep)) { +spin_unlock (ptl); +continue ; + } pte =huge_ptep_get (ptep); -if (huge_pte_none (pte)) - goto unlock; +if (huge_pte_none (pte)) { +spin_unlock (ptl); +continue ; + }/* * Migrating hugepage or HWPoisoned hugepage is already
@@ -3216,7 +3218,8 @@ again:*/ if (unlikely (!pte_present (pte))) {huge_pte_clear (mm, address, ptep); - goto unlock; +spin_unlock (ptl); +continue ; } page =pte_page (pte);
@@ -3226,9 +3229,10 @@ again:* are about to unmap is the actual page of interest. */ if (ref_page) { -if (page != ref_page) - goto unlock; - +if (page != ref_page) { +spin_unlock (ptl); +continue ; + }/* * Mark the VMA as having unmapped its page so that * future faults in this VMA will fail rather than
@@ -3244,30 +3248,14 @@ again:hugetlb_count_sub (pages_per_huge_page (h), mm);page_remove_rmap (page, true); - force_flush = !__tlb_remove_page (tlb, page); -if (force_flush) { - address += sz; -spin_unlock (ptl); -break ; - } -/* Bail out after unmapping reference page if supplied */ -if (ref_page) { -spin_unlock (ptl); -break ; - } -unlock: +spin_unlock (ptl); - } -/* -* mmu_gather ran out of room to batch pages, we break out of -* the PTE lock to avoid doing the potential expensive TLB invalidate -* and page-free while holding it. -*/ -if (force_flush) { - force_flush =0 ; -tlb_flush_mmu (tlb); -if (address < end && !ref_page) - goto again; +tlb_remove_page (tlb, page); +/* +* Bail out after unmapping reference page if supplied +*/ +if (ref_page) +break ; }mmu_notifier_invalidate_range_end (mm, mmun_start, mmun_end);tlb_end_vma (tlb, vma);
Signature · 1 line
2.7.4
PATCH 2/13 mm: Change the interface for __tlb_remove_page
In reply to Aneesh Kumar K.VThis update the generic and arch specific implementation to return true if we need to do a tlb flush. That means if a __tlb_remove_page indicate a flush is needed, the page we try to remove need to be tracked and added again after the flush. We need to track it because we have already update the pte to none and we can't just loop back.
This changes is done to enable us to do a tlb_flush when we try to flush a range that consists of different page sizes. For architectures like ppc64, we can do a range based tlb flush and we need to track page size for that. When we try to remove a huge page, we will force a tlb flush and starts a new mmu gather.
---
NOTE: This patch is already applied to -mm tree
arch/arm/include/asm/tlb.h | 17 +++++++++++++---- arch/ia64/include/asm/tlb.h | 19 ++++++++++++++----- arch/s390/include/asm/tlb.h | 9 +++++++-- arch/sh/include/asm/tlb.h | 8 +++++++- arch/um/include/asm/tlb.h | 8 +++++++- include/asm-generic/tlb.h | 44 +++++++++++++++++++++++++++++++++----------- mm/memory.c | 19 +++++++++++++------ 7 files changed, 94 insertions(+), 30 deletions(-)
arch/arm/include/asm/tlb.h +13 -4
@@ -209,17 +209,26 @@ tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)tlb_flush (tlb); } -static inline int __tlb_remove_page (struct mmu_gather *tlb,struct page *page) +static inline bool __tlb_remove_page (struct mmu_gather *tlb,struct page *page) { +if (tlb->nr == tlb->max) +return true; tlb->pages[tlb->nr++] = page; -VM_BUG_ON (tlb->nr > tlb->max); -return tlb->max - tlb->nr; +return false; }static inline void tlb_remove_page (struct mmu_gather *tlb,struct page *page) { -if (!__tlb_remove_page (tlb, page)) +if (__tlb_remove_page (tlb, page)) {tlb_flush_mmu (tlb); +__tlb_remove_page (tlb, page); + } +} + +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb, +struct page *page) +{ +return __tlb_remove_page (tlb, page); } static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
arch/ia64/include/asm/tlb.h +14 -5
@@ -205,17 +205,18 @@ tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)* must be delayed until after the TLB has been flushed (see comments at the beginning of * this file). */ -static inline int __tlb_remove_page (struct mmu_gather *tlb,struct page *page) +static inline bool __tlb_remove_page (struct mmu_gather *tlb,struct page *page) { +if (tlb->nr == tlb->max) +return true; + tlb->need_flush =1 ;if (!tlb->nr && tlb->pages == tlb->local)__tlb_alloc_page (tlb); tlb->pages[tlb->nr++] = page; -VM_BUG_ON (tlb->nr > tlb->max); - -return tlb->max - tlb->nr; +return false; }static inline void tlb_flush_mmu_tlbonly (struct mmu_gather *tlb)
@@ -235,8 +236,16 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)static inline void tlb_remove_page (struct mmu_gather *tlb,struct page *page) { -if (!__tlb_remove_page (tlb, page)) +if (__tlb_remove_page (tlb, page)) {tlb_flush_mmu (tlb); +__tlb_remove_page (tlb, page); + } +} + +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb, +struct page *page) +{ +return __tlb_remove_page (tlb, page); }/*
arch/s390/include/asm/tlb.h +7 -2
@@ -87,10 +87,10 @@ static inline void tlb_finish_mmu(struct mmu_gather *tlb,* tlb_ptep_clear_flush. In both flush modes the tlb for a page cache page * has already been freed, so just do free_page_and_swap_cache. */ -static inline int __tlb_remove_page (struct mmu_gather *tlb,struct page *page) +static inline bool __tlb_remove_page (struct mmu_gather *tlb,struct page *page) {free_page_and_swap_cache (page); -return 1 ;/* avoid calling tlb_flush_mmu */ +return false;/* avoid calling tlb_flush_mmu */ }static inline void tlb_remove_page (struct mmu_gather *tlb,struct page *page)
@@ -98,6 +98,11 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)free_page_and_swap_cache (page); } +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb, +struct page *page) +{ +return __tlb_remove_page (tlb, page); +}/* * pte_free_tlb frees a pte table and clears the CRSTE for the * page table from the tlb.
arch/sh/include/asm/tlb.h +7 -1
@@ -101,7 +101,7 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)static inline int __tlb_remove_page (struct mmu_gather *tlb,struct page *page) {free_page_and_swap_cache (page); -return 1 ;/* avoid calling tlb_flush_mmu */ +return false;/* avoid calling tlb_flush_mmu */ }static inline void tlb_remove_page (struct mmu_gather *tlb,struct page *page)
@@ -109,6 +109,12 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)__tlb_remove_page (tlb, page); } +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb, +struct page *page) +{ +return __tlb_remove_page (tlb, page); +} +#define pte_free_tlb (tlb, ptep, addr) pte_free((tlb)->mm, ptep)#define pmd_free_tlb (tlb, pmdp, addr) pmd_free((tlb)->mm, pmdp)#define pud_free_tlb (tlb, pudp, addr) pud_free((tlb)->mm, pudp)
arch/um/include/asm/tlb.h +7 -1
@@ -102,7 +102,7 @@ static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page) { tlb->need_flush =1 ;free_page_and_swap_cache (page); -return 1 ;/* avoid calling tlb_flush_mmu */ +return false;/* avoid calling tlb_flush_mmu */ }static inline void tlb_remove_page (struct mmu_gather *tlb,struct page *page)
@@ -110,6 +110,12 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)__tlb_remove_page (tlb, page); } +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb, +struct page *page) +{ +return __tlb_remove_page (tlb, page); +} +/** * tlb_remove_tlb_entry - remember a pte unmapping for later tlb invalidation. *
include/asm-generic/tlb.h +33 -11
68 lines not on this page · raw message
mm/memory.c +13 -6
@@ -292,23 +292,24 @@ void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long e* handling the additional races in SMP caused by other CPUs caching valid * mappings in their TLBs. Returns the number of free page slots left. * When out of page slots we must call tlb_flush_mmu(). +*returns true if the caller should flush. */ -int __tlb_remove_page (struct mmu_gather *tlb,struct page *page) +bool __tlb_remove_page (struct mmu_gather *tlb,struct page *page) {struct mmu_gather_batch *batch;VM_BUG_ON (!tlb->end); batch = tlb->active; - batch->pages[batch->nr++] = page;if (batch->nr == batch->max) {if (!tlb_next_batch (tlb)) -return 0 ; +return true; batch = tlb->active; }VM_BUG_ON_PAGE (batch->nr > batch->max, page); -return batch->max - batch->nr; + batch->pages[batch->nr++] = page; +return false; }#endif /* HAVE_GENERIC_MMU_GATHER */
@@ -1109,6 +1110,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,pte_t *start_pte;pte_t *pte;swp_entry_t entry; +struct page *pending_page =NULL ; again:init_rss_vec (rss);
@@ -1160,8 +1162,9 @@ again:page_remove_rmap (page, false);if (unlikely (page_mapcount (page) <0 ))print_bad_pte (vma, addr, ptent, page); -if (unlikely (!__tlb_remove_page (tlb, page))) { +if (unlikely (__tlb_remove_page (tlb, page))) { force_flush =1 ; + pending_page = page; addr +=PAGE_SIZE ;break ; }
@@ -1202,7 +1205,11 @@ again:if (force_flush) { force_flush =0 ;tlb_flush_mmu_free (tlb); - +if (pending_page) { +/* remove the page with new size */ +__tlb_remove_pte_page (tlb, pending_page); + pending_page =NULL ; + }if (addr != end) goto again; }
Signature · 1 line
2.7.4
PATCH 3/13 mm/mmu_gather: Track page size with mmu gather and force flush if page size change
In reply to Aneesh Kumar K.VThis allows arch which need to do special handing with respect to different page size when flushing tlb to implement the same in mmu gather
---
NOTE: This patch is already applied to -mm tree
arch/arm/include/asm/tlb.h | 12 ++++++++++++ arch/ia64/include/asm/tlb.h | 12 ++++++++++++ arch/s390/include/asm/tlb.h | 13 +++++++++++++ arch/sh/include/asm/tlb.h | 12 ++++++++++++ arch/um/include/asm/tlb.h | 12 ++++++++++++ include/asm-generic/tlb.h | 27 +++++++++++++++++++++------ mm/huge_memory.c | 2 +- mm/hugetlb.c | 2 +- mm/memory.c | 10 +++++++++- 9 files changed, 93 insertions(+), 9 deletions(-)
arch/arm/include/asm/tlb.h +12 -0
@@ -225,12 +225,24 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) } } +static inline bool __tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return __tlb_remove_page (tlb, page); +} +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb,struct page *page) {return __tlb_remove_page (tlb, page); } +static inline void tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return tlb_remove_page (tlb, page); +} +static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t pte,unsigned long addr) {
arch/ia64/include/asm/tlb.h +12 -0
@@ -242,12 +242,24 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) } } +static inline bool __tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return __tlb_remove_page (tlb, page); +} +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb,struct page *page) {return __tlb_remove_page (tlb, page); } +static inline void tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return tlb_remove_page (tlb, page); +} +/* * Remove TLB entry for PTE mapped at virtual address ADDRESS. This is called for any * PTE, not just those pointing to (normal) physical memory.
arch/s390/include/asm/tlb.h +13 -0
@@ -98,11 +98,24 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)free_page_and_swap_cache (page); } +static inline bool __tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return __tlb_remove_page (tlb, page); +} +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb,struct page *page) {return __tlb_remove_page (tlb, page); } + +static inline void tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return tlb_remove_page (tlb, page); +} +/* * pte_free_tlb frees a pte table and clears the CRSTE for the * page table from the tlb.
arch/sh/include/asm/tlb.h +12 -0
@@ -109,12 +109,24 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)__tlb_remove_page (tlb, page); } +static inline bool __tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return __tlb_remove_page (tlb, page); +} +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb,struct page *page) {return __tlb_remove_page (tlb, page); } +static inline void tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return tlb_remove_page (tlb, page); +} +#define pte_free_tlb (tlb, ptep, addr) pte_free((tlb)->mm, ptep)#define pmd_free_tlb (tlb, pmdp, addr) pmd_free((tlb)->mm, pmdp)#define pud_free_tlb (tlb, pudp, addr) pud_free((tlb)->mm, pudp)
arch/um/include/asm/tlb.h +12 -0
@@ -110,12 +110,24 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)__tlb_remove_page (tlb, page); } +static inline bool __tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return __tlb_remove_page (tlb, page); +} +static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb,struct page *page) {return __tlb_remove_page (tlb, page); } +static inline void tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +return tlb_remove_page (tlb, page); +} +/** * tlb_remove_tlb_entry - remember a pte unmapping for later tlb invalidation. *
include/asm-generic/tlb.h +21 -6
@@ -112,6 +112,7 @@ struct mmu_gather {* that that we can adjust the range after the flush */ unsigned long addr; +int page_size; };#define HAVE_GENERIC_MMU_GATHER
@@ -120,7 +121,8 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned longvoid tlb_flush_mmu (struct mmu_gather *tlb);void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end); -bool __tlb_remove_page (struct mmu_gather *tlb,struct page *page); +extern bool __tlb_remove_page_size (struct mmu_gather *tlb,struct page *page, +int page_size);static inline void __tlb_adjust_range (struct mmu_gather *tlb,unsigned long address)
@@ -145,23 +147,36 @@ static inline void __tlb_reset_range(struct mmu_gather *tlb) } } +static inline void tlb_remove_page_size (struct mmu_gather *tlb, +struct page *page,int page_size) +{ +if (__tlb_remove_page_size (tlb, page, page_size)) { +tlb_flush_mmu (tlb); + tlb->page_size = page_size; +__tlb_adjust_range (tlb, tlb->addr); +__tlb_remove_page_size (tlb, page, page_size); + } +} + +static bool __tlb_remove_page (struct mmu_gather *tlb,struct page *page) +{ +return __tlb_remove_page_size (tlb, page,PAGE_SIZE ); +} +/* tlb_remove_page * Similar to __tlb_remove_page but will call tlb_flush_mmu() itself when * required. */ static inline void tlb_remove_page (struct mmu_gather *tlb,struct page *page) { -if (__tlb_remove_page (tlb, page)) { -tlb_flush_mmu (tlb); -__tlb_adjust_range (tlb, tlb->addr); -__tlb_remove_page (tlb, page); - } +return tlb_remove_page_size (tlb, page,PAGE_SIZE ); }static inline bool __tlb_remove_pte_page (struct mmu_gather *tlb,struct page *page) {/* active->nr should be zero when we call this */ VM_BUG_ON_PAGE (tlb->active->nr, page); + tlb->page_size =PAGE_SIZE ;__tlb_adjust_range (tlb, tlb->addr);return __tlb_remove_page (tlb, page); }
mm/huge_memory.c +1 -1
@@ -1694,7 +1694,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,pte_free (tlb->mm,pgtable_trans_huge_withdraw (tlb->mm, pmd));atomic_long_dec (&tlb->mm->nr_ptes);spin_unlock (ptl); -tlb_remove_page (tlb, page); +tlb_remove_page_size (tlb, page,HPAGE_PMD_SIZE ); }return 1 ; }
mm/hugetlb.c +1 -1
@@ -3250,7 +3250,7 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,page_remove_rmap (page, true);spin_unlock (ptl); -tlb_remove_page (tlb, page); +tlb_remove_page_size (tlb, page,huge_page_size (h));/* * Bail out after unmapping reference page if supplied */
mm/memory.c +9 -1
@@ -233,6 +233,7 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long#ifdef CONFIG_HAVE_RCU_TABLE_FREE tlb->batch =NULL ;#endif + tlb->page_size =0 ;__tlb_reset_range (tlb); }
@@ -294,12 +295,19 @@ void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long e* When out of page slots we must call tlb_flush_mmu(). *returns true if the caller should flush. */ -bool __tlb_remove_page (struct mmu_gather *tlb,struct page *page) +bool __tlb_remove_page_size (struct mmu_gather *tlb,struct page *page,int page_size) {struct mmu_gather_batch *batch;VM_BUG_ON (!tlb->end); +if (!tlb->page_size) + tlb->page_size = page_size; +else { +if (page_size != tlb->page_size) +return true; + } + batch = tlb->active;if (batch->nr == batch->max) {if (!tlb_next_batch (tlb))
Signature · 1 line
2.7.4
PATCH 4/13 powerpc/mm/radix: Implement tlb mmu gather flush efficiently
In reply to Aneesh Kumar K.VNow that we track page size in mmu_gather, we can use address based tlbie format when doing a tlb_flush(). We don't do this if we are invalidating the full address space.
--- .../powerpc/include/asm/book3s/64/tlbflush-radix.h | 2 + arch/powerpc/mm/tlb-radix.c | 59 +++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +2 -0
@@ -10,6 +10,8 @@ static inline int mmu_get_ap(int psize)return mmu_psize_defs[psize].ap; } +extern void radix__flush_tlb_range_psize (struct mm_struct *mm,unsigned long start, +unsigned long end,int psize);extern void radix__flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end);extern void radix__flush_tlb_kernel_range (unsigned long start,unsigned long end);
arch/powerpc/mm/tlb-radix.c +58 -1
66 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 5/13 powerpc/mm: Make MMU_FTR_RADIX a MMU family feature
In reply to Aneesh Kumar K.VMMU feature bits are defined such that we use the lower half to present MMU family features. Remove the strict split of half and also move Radix to a mmu family feature. Radix introduce a new MMU model and strictly speaking it is a new MMU family. This also free up bits which can be used for individual features later.
--- arch/powerpc/include/asm/book3s/64/mmu.h | 3 +-- arch/powerpc/include/asm/mmu.h | 16 +++++++--------- arch/powerpc/kernel/entry_64.S | 2 +- arch/powerpc/kernel/exceptions-64s.S | 8 ++++---- arch/powerpc/kernel/prom.c | 4 ++-- 5 files changed, 15 insertions(+), 18 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +1 -2
@@ -24,12 +24,11 @@ struct mmu_psize_def {extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT ];#ifdef CONFIG_PPC_RADIX_MMU -#define radix_enabled () mmu_has_feature(MMU_FTR_RADIX) +#define radix_enabled () mmu_has_feature(MMU_FTR_TYPE_RADIX)#else #define radix_enabled () (0)#endif -#endif /* __ASSEMBLY__ */ /* 64-bit classic hash table MMU */
arch/powerpc/include/asm/mmu.h +7 -9
@@ -12,7 +12,7 @@*/ /* -* First half is MMU families +* MMU families */ #define MMU_FTR_HPTE_TABLE ASM_CONST(0x00000001)#define MMU_FTR_TYPE_8xx ASM_CONST(0x00000002)
@@ -20,9 +20,12 @@#define MMU_FTR_TYPE_44x ASM_CONST(0x00000008)#define MMU_FTR_TYPE_FSL_E ASM_CONST(0x00000010)#define MMU_FTR_TYPE_47x ASM_CONST(0x00000020) -/* -* This is individual features +* Radix page table available +*/ +#define MMU_FTR_TYPE_RADIX ASM_CONST(0x00000040) +/* +* individual features */ /* * We need to clear top 16bits of va (from the remaining 64 bits )in
@@ -93,11 +96,6 @@*/ #define MMU_FTR_1T_SEGMENT ASM_CONST(0x40000000) -/* -* Radix page table available -*/ -#define MMU_FTR_RADIX ASM_CONST(0x80000000) -/* MMU feature bit sets for various CPUs */ #define MMU_FTRS_DEFAULT_HPTE_ARCH_V2 \ MMU_FTR_HPTE_TABLE | MMU_FTR_PPCAS_ARCH_V2
@@ -131,7 +129,7 @@ enum { MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA |#ifdef CONFIG_PPC_RADIX_MMU -MMU_FTR_RADIX | +MMU_FTR_TYPE_RADIX | #endif 0, };
arch/powerpc/kernel/entry_64.S +1 -1
@@ -532,7 +532,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300) #ifdef CONFIG_PPC_STD_MMU_64 BEGIN_MMU_FTR_SECTION b 2f -END_MMU_FTR_SECTION_IFSET(MMU_FTR_RADIX) +END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_RADIX) BEGIN_FTR_SECTION clrrdi r6,r8,28 /* get its ESID */ clrrdi r9,r1,28 /* get current sp ESID */
arch/powerpc/kernel/exceptions-64s.S +4 -4
@@ -945,7 +945,7 @@ BEGIN_MMU_FTR_SECTION b do_hash_page /* Try to handle as hpte fault */ MMU_FTR_SECTION_ELSE b handle_page_fault -ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_RADIX) +ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) .align 7 .globl h_data_storage_common
@@ -976,7 +976,7 @@ BEGIN_MMU_FTR_SECTION b do_hash_page /* Try to handle as hpte fault */ MMU_FTR_SECTION_ELSE b handle_page_fault -ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_RADIX) +ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) STD_EXCEPTION_COMMON(0xe20, h_instr_storage, unknown_exception)
@@ -1390,7 +1390,7 @@ slb_miss_realmode: #ifdef CONFIG_PPC_STD_MMU_64 BEGIN_MMU_FTR_SECTION bl slb_allocate_realmode -END_MMU_FTR_SECTION_IFCLR(MMU_FTR_RADIX) +END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_RADIX) #endif /* All done -- return from exception. */
@@ -1404,7 +1404,7 @@ BEGIN_MMU_FTR_SECTION beq- 2f FTR_SECTION_ELSE b 2f -ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_RADIX) +ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) .machine push .machine "power4"
arch/powerpc/kernel/prom.c +2 -2
@@ -168,7 +168,7 @@ static struct ibm_pa_feature {*/ {CPU_FTR_TM_COMP ,0 ,0 , PPC_FEATURE2_HTM_COMP|PPC_FEATURE2_HTM_NOSC_COMP, 22, 0, 0}, - {0, MMU_FTR_RADIX, 0, 0, 40, 0, 0}, + {0, MMU_FTR_TYPE_RADIX, 0, 0, 40, 0, 0}, }; static void __init scan_features(unsigned long node, const unsigned char *ftrs,
@@ -751,7 +751,7 @@ void __init early_init_devtree(void *params)* now fixup radix MMU mode based on kernel command line */ if (disable_radix) - cur_cpu_spec->mmu_features &= ~MMU_FTR_RADIX ; + cur_cpu_spec->mmu_features &= ~MMU_FTR_TYPE_RADIX ;DBG (" <- early_init_devtree()\n" ); }
Signature · 1 line
2.7.4
PATCH 6/13 powerpc/mm/hash: Add helper for finding SLBE LLP encoding
In reply to Aneesh Kumar K.VReplace opencoding of the same at multiple places with the helper. No functional change with this patch.
--- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 9 +++++++++ arch/powerpc/include/asm/kvm_book3s_64.h | 3 +-- arch/powerpc/mm/hash_native_64.c | 6 ++---- 3 files changed, 12 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu-hash.h +9 -0
@@ -151,6 +151,15 @@ static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize) BUG(); } +static inline unsigned long get_sllp_encoding (int psize) +{ +unsigned long sllp; + + sllp = ((mmu_psize_defs[psize].sllp &SLB_VSID_L ) >>6 ) | + ((mmu_psize_defs[psize].sllp &SLB_VSID_LP ) >>4 ); +return sllp; +} +#endif /* __ASSEMBLY__ */ /*
arch/powerpc/include/asm/kvm_book3s_64.h +1 -2
@@ -181,8 +181,7 @@ static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,switch (b_psize) {case MMU_PAGE_4K : - sllp = ((mmu_psize_defs[a_psize].sllp &SLB_VSID_L ) >>6 ) | - ((mmu_psize_defs[a_psize].sllp &SLB_VSID_LP ) >>4 ); + sllp =get_sllp_encoding (a_psize); rb |= sllp <<5 ;/* AP field */ rb |= (va_low &0x7ff ) <<12 ;/* remaining 11 bits of AVA */ break ;
arch/powerpc/mm/hash_native_64.c +2 -4
@@ -72,8 +72,7 @@ static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)/* clear out bits after (52) [0....52.....63] */ va &= ~((1ul << (64 -52 )) -1 ); va |= ssize <<8 ; - sllp = ((mmu_psize_defs[apsize].sllp &SLB_VSID_L ) >>6 ) | - ((mmu_psize_defs[apsize].sllp &SLB_VSID_LP ) >>4 ); + sllp =get_sllp_encoding (apsize); va |= sllp <<5 ; asm volatile(ASM_FTR_IFCLR("tlbie %0,0", PPC_TLBIE(%1,%0), %2) : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206)
@@ -122,8 +121,7 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)/* clear out bits after(52) [0....52.....63] */ va &= ~((1ul << (64 -52 )) -1 ); va |= ssize <<8 ; - sllp = ((mmu_psize_defs[apsize].sllp &SLB_VSID_L ) >>6 ) | - ((mmu_psize_defs[apsize].sllp &SLB_VSID_LP ) >>4 ); + sllp =get_sllp_encoding (apsize); va |= sllp <<5 ; asmvolatile (".long 0x7c000224 | (%0 << 11) | (0 << 21)" : :"r" (va) :"memory" );
Signature · 1 line
2.7.4
PATCH 7/13 powerpc/mm: Use hugetlb flush functions
In reply to Aneesh Kumar K.VUse flush_hugetlb_page instead of flush_tlb_page when we clear flush the pte.
--- arch/powerpc/include/asm/hugetlb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/hugetlb.h +1 -1
@@ -147,7 +147,7 @@ static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, {pte_t pte; pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); -flush_tlb_page (vma, addr); +flush_hugetlb_page (vma, addr); }static inline int huge_pte_none (pte_t pte)
Signature · 1 line
2.7.4
PATCH 8/13 powerpc/mm: Drop multiple definition of mm_is_core_local
In reply to Aneesh Kumar K.V--- arch/powerpc/include/asm/tlb.h | 13 +++++++++++++ arch/powerpc/mm/tlb-radix.c | 6 ------ arch/powerpc/mm/tlb_nohash.c | 6 ------ 3 files changed, 13 insertions(+), 12 deletions(-)
arch/powerpc/include/asm/tlb.h +13 -0
@@ -46,5 +46,18 @@ static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep,#endif } +#ifdef CONFIG_SMP +static inline int mm_is_core_local (struct mm_struct *mm) +{ +return cpumask_subset (mm_cpumask (mm), +topology_sibling_cpumask (smp_processor_id ())); +} +#else +static inline int mm_is_core_local (struct mm_struct *mm) +{ +return 1 ; +} +#endif +#endif /* __KERNEL__ */ #endif /* __ASM_POWERPC_TLB_H */
arch/powerpc/mm/tlb-radix.c +0 -6
@@ -165,12 +165,6 @@ void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddEXPORT_SYMBOL (radix__local_flush_tlb_page);#ifdef CONFIG_SMP -static int mm_is_core_local (struct mm_struct *mm) -{ -return cpumask_subset (mm_cpumask (mm), -topology_sibling_cpumask (smp_processor_id ())); -} -void radix__flush_tlb_mm (struct mm_struct *mm) {unsigned long pid;
arch/powerpc/mm/tlb_nohash.c +0 -6
@@ -215,12 +215,6 @@ EXPORT_SYMBOL(local_flush_tlb_page);static DEFINE_RAW_SPINLOCK (tlbivax_lock); -static int mm_is_core_local (struct mm_struct *mm) -{ -return cpumask_subset (mm_cpumask (mm), -topology_sibling_cpumask (smp_processor_id ())); -} -struct tlb_flush_param {unsigned long addr;unsigned int pid;
Signature · 1 line
2.7.4
PATCH 9/13 powerpc/mm/radix: Add tlb flush of THP ptes
In reply to Aneesh Kumar K.VInstead of flushing the entire mm, implement a flush_pmd_tlb_range
--- arch/powerpc/include/asm/book3s/64/tlbflush-radix.h | 2 ++ arch/powerpc/include/asm/book3s/64/tlbflush.h | 9 +++++++++ arch/powerpc/mm/pgtable-book3s64.c | 4 ++-- arch/powerpc/mm/tlb-radix.c | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +2 -0
@@ -12,6 +12,8 @@ static inline int mmu_get_ap(int psize)extern void radix__flush_tlb_range_psize (struct mm_struct *mm,unsigned long start,unsigned long end,int psize); +extern void radix__flush_pmd_tlb_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end);extern void radix__flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end);extern void radix__flush_tlb_kernel_range (unsigned long start,unsigned long end);
arch/powerpc/include/asm/book3s/64/tlbflush.h +9 -0
@@ -7,6 +7,15 @@#include <asm/book3s/64/tlbflush-hash.h> #include <asm/book3s/64/tlbflush-radix.h> +#define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE +static inline void flush_pmd_tlb_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end) +{ +if (radix_enabled ()) +return radix__flush_pmd_tlb_range (vma, start, end); +return hash__flush_tlb_range (vma, start, end); +} +static inline void flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end) {
arch/powerpc/mm/pgtable-book3s64.c +2 -2
@@ -33,7 +33,7 @@ int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, changed = !pmd_same (*(pmdp), entry);if (changed) {__ptep_set_access_flags (pmdp_ptep (pmdp),pmd_pte (entry)); -flush_tlb_range (vma, address, address +HPAGE_PMD_SIZE ); +flush_pmd_tlb_range (vma, address, address +HPAGE_PMD_SIZE ); }return changed; }
@@ -66,7 +66,7 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) {pmd_hugepage_update (vma->vm_mm, address, pmdp, _PAGE_PRESENT,0 ); -flush_tlb_range (vma, address, address +HPAGE_PMD_SIZE ); +flush_pmd_tlb_range (vma, address, address +HPAGE_PMD_SIZE );/* * This ensures that generic code that rely on IRQ disabling * to prevent a parallel THP split work as expected.
arch/powerpc/mm/tlb-radix.c +7 -0
@@ -391,3 +391,10 @@ void radix__flush_tlb_lpid(unsigned long lpid) asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); }EXPORT_SYMBOL (radix__flush_tlb_lpid); + +void radix__flush_pmd_tlb_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end) +{ +radix__flush_tlb_range_psize (vma->vm_mm, start, end,MMU_PAGE_2M ); +} +EXPORT_SYMBOL (radix__flush_pmd_tlb_range);
Signature · 1 line
2.7.4
PATCH 10/13 powerpc/mm/radix: Rename function and drop unused arg
In reply to Aneesh Kumar K.V--- arch/powerpc/include/asm/book3s/64/tlbflush-radix.h | 10 +++++----- arch/powerpc/mm/hugetlbpage-radix.c | 4 ++-- arch/powerpc/mm/tlb-radix.c | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-)
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +5 -5
@@ -20,20 +20,20 @@ extern void radix__flush_tlb_kernel_range(unsigned long start, unsigned long endextern void radix__local_flush_tlb_mm (struct mm_struct *mm);extern void radix__local_flush_tlb_page (struct vm_area_struct *vma,unsigned long vmaddr); -extern void radix___local_flush_tlb_page (struct mm_struct *mm,unsigned long vmaddr, -unsigned long ap,int nid);extern void radix__local_flush_tlb_pwc (struct mmu_gather *tlb,unsigned long addr); +extern void radix__local_flush_tlb_page_psize (struct mm_struct *mm,unsigned long vmaddr, +unsigned long ap);extern void radix__tlb_flush (struct mmu_gather *tlb);#ifdef CONFIG_SMP extern void radix__flush_tlb_mm (struct mm_struct *mm);extern void radix__flush_tlb_page (struct vm_area_struct *vma,unsigned long vmaddr); -extern void radix___flush_tlb_page (struct mm_struct *mm,unsigned long vmaddr, -unsigned long ap,int nid);extern void radix__flush_tlb_pwc (struct mmu_gather *tlb,unsigned long addr); +extern void radix__flush_tlb_page_psize (struct mm_struct *mm,unsigned long vmaddr, +unsigned long ap);#else #define radix__flush_tlb_mm (mm) radix__local_flush_tlb_mm(mm)#define radix__flush_tlb_page (vma,addr) radix__local_flush_tlb_page(vma,addr) -#define radix___flush_tlb_page (mm,addr,p,i) radix___local_flush_tlb_page(mm,addr,p,i) +#define radix__flush_tlb_page_psize (mm,addr,p) radix__local_flush_tlb_page_psize(mm,addr,p)#define radix__flush_tlb_pwc (tlb, addr) radix__local_flush_tlb_pwc(tlb, addr)#endif extern void radix__flush_tlb_lpid_va(unsigned long lpid, unsigned long gpa,
arch/powerpc/mm/hugetlbpage-radix.c +2 -2
@@ -20,7 +20,7 @@ void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr)WARN (1 ,"Wrong huge page shift\n" );return ; } -radix___flush_tlb_page (vma->vm_mm, vmaddr, ap,0 ); +radix__flush_tlb_page_psize (vma->vm_mm, vmaddr, ap); }void radix__local_flush_hugetlb_page (struct vm_area_struct *vma,unsigned long vmaddr)
@@ -37,7 +37,7 @@ void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vWARN (1 ,"Wrong huge page shift\n" );return ; } -radix___local_flush_tlb_page (vma->vm_mm, vmaddr, ap,0 ); +radix__local_flush_tlb_page_psize (vma->vm_mm, vmaddr, ap); }/*
arch/powerpc/mm/tlb-radix.c +8 -8
@@ -140,8 +140,8 @@ void radix__local_flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr) }EXPORT_SYMBOL (radix__local_flush_tlb_pwc); -void radix___local_flush_tlb_page (struct mm_struct *mm,unsigned long vmaddr, -unsigned long ap,int nid) +void radix__local_flush_tlb_page_psize (struct mm_struct *mm,unsigned long vmaddr, +unsigned long ap) {unsigned long pid;
@@ -159,8 +159,8 @@ void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddif (vma &&is_vm_hugetlb_page (vma))return __local_flush_hugetlb_page (vma, vmaddr);#endif -radix___local_flush_tlb_page (vma ? vma->vm_mm :NULL , vmaddr, -mmu_get_ap (mmu_virtual_psize),0 ); +radix__local_flush_tlb_page_psize (vma ? vma->vm_mm :NULL , vmaddr, +mmu_get_ap (mmu_virtual_psize)); }EXPORT_SYMBOL (radix__local_flush_tlb_page);
@@ -215,8 +215,8 @@ no_context: }EXPORT_SYMBOL (radix__flush_tlb_pwc); -void radix___flush_tlb_page (struct mm_struct *mm,unsigned long vmaddr, -unsigned long ap,int nid) +void radix__flush_tlb_page_psize (struct mm_struct *mm,unsigned long vmaddr, +unsigned long ap) {unsigned long pid;
@@ -244,8 +244,8 @@ void radix__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)if (vma &&is_vm_hugetlb_page (vma))return flush_hugetlb_page (vma, vmaddr);#endif -radix___flush_tlb_page (vma ? vma->vm_mm :NULL , vmaddr, -mmu_get_ap (mmu_virtual_psize),0 ); +radix__flush_tlb_page_psize (vma ? vma->vm_mm :NULL , vmaddr, +mmu_get_ap (mmu_virtual_psize)); }EXPORT_SYMBOL (radix__flush_tlb_page);
Signature · 1 line
2.7.4
PATCH 11/13 powerpc/mm/radix/hugetlb: Add helper for finding page size from hstate
In reply to Aneesh Kumar K.VUse the helper instead of open coding the same at multiple place
--- arch/powerpc/include/asm/book3s/64/hugetlb-radix.h | 15 +++++++++++ .../powerpc/include/asm/book3s/64/tlbflush-radix.h | 4 +-- arch/powerpc/mm/hugetlbpage-radix.c | 29 ++++++---------------- arch/powerpc/mm/tlb-radix.c | 10 +++++--- 4 files changed, 30 insertions(+), 28 deletions(-)
arch/powerpc/include/asm/book3s/64/hugetlb-radix.h +15 -0
@@ -11,4 +11,19 @@ extern unsigned long radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); + +static inline int hstate_get_psize (struct hstate *hstate) +{ +unsigned long shift; + + shift =huge_page_shift (hstate); +if (shift == mmu_psize_defs[MMU_PAGE_2M ].shift) +return MMU_PAGE_2M ; +else if (shift == mmu_psize_defs[MMU_PAGE_1G ].shift) +return MMU_PAGE_1G ; +else { +WARN (1 ,"Wrong huge page shift\n" ); +return mmu_virtual_psize; + } +}#endif
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +2 -2
@@ -22,14 +22,14 @@ extern void radix__local_flush_tlb_mm(struct mm_struct *mm);extern void radix__local_flush_tlb_page (struct vm_area_struct *vma,unsigned long vmaddr);extern void radix__local_flush_tlb_pwc (struct mmu_gather *tlb,unsigned long addr);extern void radix__local_flush_tlb_page_psize (struct mm_struct *mm,unsigned long vmaddr, -unsigned long ap); +int psize);extern void radix__tlb_flush (struct mmu_gather *tlb);#ifdef CONFIG_SMP extern void radix__flush_tlb_mm (struct mm_struct *mm);extern void radix__flush_tlb_page (struct vm_area_struct *vma,unsigned long vmaddr);extern void radix__flush_tlb_pwc (struct mmu_gather *tlb,unsigned long addr);extern void radix__flush_tlb_page_psize (struct mm_struct *mm,unsigned long vmaddr, -unsigned long ap); +int psize);#else #define radix__flush_tlb_mm (mm) radix__local_flush_tlb_mm(mm)#define radix__flush_tlb_page (vma,addr) radix__local_flush_tlb_page(vma,addr)
arch/powerpc/mm/hugetlbpage-radix.c +7 -22
@@ -5,39 +5,24 @@#include <asm/cacheflush.h> #include <asm/machdep.h> #include <asm/mman.h> +#include <asm/tlb.h> void radix__flush_hugetlb_page (struct vm_area_struct *vma,unsigned long vmaddr) { -unsigned long ap, shift; +int psize;struct hstate *hstate =hstate_file (vma->vm_file); - shift =huge_page_shift (hstate); -if (shift == mmu_psize_defs[MMU_PAGE_2M ].shift) - ap =mmu_get_ap (MMU_PAGE_2M ); -else if (shift == mmu_psize_defs[MMU_PAGE_1G ].shift) - ap =mmu_get_ap (MMU_PAGE_1G ); -else { -WARN (1 ,"Wrong huge page shift\n" ); -return ; - } -radix__flush_tlb_page_psize (vma->vm_mm, vmaddr, ap); + psize =hstate_get_psize (hstate); +radix__flush_tlb_page_psize (vma->vm_mm, vmaddr, psize); }void radix__local_flush_hugetlb_page (struct vm_area_struct *vma,unsigned long vmaddr) { -unsigned long ap, shift; +int psize;struct hstate *hstate =hstate_file (vma->vm_file); - shift =huge_page_shift (hstate); -if (shift == mmu_psize_defs[MMU_PAGE_2M ].shift) - ap =mmu_get_ap (MMU_PAGE_2M ); -else if (shift == mmu_psize_defs[MMU_PAGE_1G ].shift) - ap =mmu_get_ap (MMU_PAGE_1G ); -else { -WARN (1 ,"Wrong huge page shift\n" ); -return ; - } -radix__local_flush_tlb_page_psize (vma->vm_mm, vmaddr, ap); + psize =hstate_get_psize (hstate); +radix__local_flush_tlb_page_psize (vma->vm_mm, vmaddr, psize); }/*
arch/powerpc/mm/tlb-radix.c +6 -4
@@ -141,9 +141,10 @@ void radix__local_flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr)EXPORT_SYMBOL (radix__local_flush_tlb_pwc);void radix__local_flush_tlb_page_psize (struct mm_struct *mm,unsigned long vmaddr, -unsigned long ap) +int psize) {unsigned long pid; +unsigned long ap =mmu_get_ap (psize);preempt_disable (); pid = mm ? mm->context.id :0 ;
@@ -160,7 +161,7 @@ void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddreturn __local_flush_hugetlb_page (vma, vmaddr);#endif radix__local_flush_tlb_page_psize (vma ? vma->vm_mm :NULL , vmaddr, -mmu_get_ap (mmu_virtual_psize)); + mmu_virtual_psize); }EXPORT_SYMBOL (radix__local_flush_tlb_page);
@@ -216,9 +217,10 @@ no_context:EXPORT_SYMBOL (radix__flush_tlb_pwc);void radix__flush_tlb_page_psize (struct mm_struct *mm,unsigned long vmaddr, -unsigned long ap) +int psize) {unsigned long pid; +unsigned long ap =mmu_get_ap (psize);preempt_disable (); pid = mm ? mm->context.id :0 ;
@@ -245,7 +247,7 @@ void radix__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)return flush_hugetlb_page (vma, vmaddr);#endif radix__flush_tlb_page_psize (vma ? vma->vm_mm :NULL , vmaddr, -mmu_get_ap (mmu_virtual_psize)); + mmu_virtual_psize); }EXPORT_SYMBOL (radix__flush_tlb_page);
Signature · 1 line
2.7.4
PATCH 12/13 powerpc/mm/hugetlb: Add flush_hugetlb_tlb_range
In reply to Aneesh Kumar K.VSome archs like ppc64 need to do special things when flushing tlb for hugepage. Add a new helper to flush hugetlb tlb range. This helps us to avoid flushing the entire tlb mapping for the pid.
--- arch/powerpc/include/asm/book3s/64/tlbflush-radix.h | 2 ++ arch/powerpc/include/asm/book3s/64/tlbflush.h | 10 ++++++++++ arch/powerpc/mm/hugetlbpage-radix.c | 10 ++++++++++ mm/hugetlb.c | 10 +++++++++- 4 files changed, 31 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +2 -0
@@ -10,6 +10,8 @@ static inline int mmu_get_ap(int psize)return mmu_psize_defs[psize].ap; } +extern void radix__flush_hugetlb_tlb_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end);extern void radix__flush_tlb_range_psize (struct mm_struct *mm,unsigned long start,unsigned long end,int psize); extern void radix__flush_pmd_tlb_range(struct vm_area_struct *vma,
arch/powerpc/include/asm/book3s/64/tlbflush.h +10 -0
@@ -16,6 +16,16 @@ static inline void flush_pmd_tlb_range(struct vm_area_struct *vma,return hash__flush_tlb_range (vma, start, end); } +#define __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE +static inline void flush_hugetlb_tlb_range (struct vm_area_struct *vma, +unsigned long start, +unsigned long end) +{ +if (radix_enabled ()) +return radix__flush_hugetlb_tlb_range (vma, start, end); +return hash__flush_tlb_range (vma, start, end); +} +static inline void flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end) {
arch/powerpc/mm/hugetlbpage-radix.c +10 -0
@@ -25,6 +25,16 @@ void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vradix__local_flush_tlb_page_psize (vma->vm_mm, vmaddr, psize); } +void radix__flush_hugetlb_tlb_range (struct vm_area_struct *vma,unsigned long start, +unsigned long end) +{ +int psize; +struct hstate *hstate =hstate_file (vma->vm_file); + + psize =hstate_get_psize (hstate); +radix__flush_tlb_range_psize (vma->vm_mm, start, end, psize); +} +/* * A vairant of hugetlb_get_unmapped_area doing topdown search * FIXME!! should we do as x86 does or non hugetlb area does ?
mm/hugetlb.c +9 -1
@@ -3936,6 +3936,14 @@ same_page:return i ? i : -EFAULT ; } +#ifndef __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE +/* +* ARCHes with special requirements for evicting HUGETLB backing TLB entries can +* implement this. +*/ +#define flush_hugetlb_tlb_range (vma, addr, end) flush_tlb_range(vma, addr, end) +#endif +unsigned long hugetlb_change_protection (struct vm_area_struct *vma,unsigned long address,unsigned long end,pgprot_t newprot) {
@@ -3996,7 +4004,7 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma,* once we release i_mmap_rwsem, another task can do the final put_page * and that page table be reused and filled with junk. */ -flush_tlb_range (vma, start, end); +flush_hugetlb_tlb_range (vma, start, end);mmu_notifier_invalidate_range (mm, start, end);i_mmap_unlock_write (vma->vm_file->f_mapping);mmu_notifier_invalidate_range_end (mm, start, end);
Signature · 1 line
2.7.4
PATCH 13/13 powerpc/mm: remove flush_tlb_page_nohash
In reply to Aneesh Kumar K.VThis should be same as flush_tlb_page except for hash32. For hash32 I guess the existing code is wrong, because we don't seem to be flushing tlb for Hash != 0 case at all. Fix this by switching to calling flush_tlb_page() which does the right thing by flushing tlb for both hash and nohash case with hash32
--- arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 5 ----- arch/powerpc/include/asm/book3s/64/tlbflush.h | 8 -------- arch/powerpc/include/asm/tlbflush.h | 1 - arch/powerpc/mm/pgtable.c | 2 +- arch/powerpc/mm/tlb_hash32.c | 11 ----------- 5 files changed, 1 insertion(+), 26 deletions(-)
arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +0 -5
@@ -75,11 +75,6 @@ static inline void hash__flush_tlb_page(struct vm_area_struct *vma, { } -static inline void hash__flush_tlb_page_nohash (struct vm_area_struct *vma, -unsigned long vmaddr) -{ -} -static inline void hash__flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end) {
arch/powerpc/include/asm/book3s/64/tlbflush.h +0 -8
@@ -57,14 +57,6 @@ static inline void local_flush_tlb_page(struct vm_area_struct *vma,return hash__local_flush_tlb_page (vma, vmaddr); } -static inline void flush_tlb_page_nohash (struct vm_area_struct *vma, -unsigned long vmaddr) -{ -if (radix_enabled ()) -return radix__flush_tlb_page (vma, vmaddr); -return hash__flush_tlb_page_nohash (vma, vmaddr); -} -static inline void tlb_flush (struct mmu_gather *tlb) {if (radix_enabled ())
arch/powerpc/include/asm/tlbflush.h +0 -1
@@ -54,7 +54,6 @@ extern void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,#define flush_tlb_page (vma,addr) local_flush_tlb_page(vma,addr)#define __flush_tlb_page (mm,addr,p,i) __local_flush_tlb_page(mm,addr,p,i)#endif -#define flush_tlb_page_nohash (vma,addr) flush_tlb_page(vma,addr)#elif defined(CONFIG_PPC_STD_MMU_32)
arch/powerpc/mm/pgtable.c +1 -1
@@ -225,7 +225,7 @@ int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address,if (!is_vm_hugetlb_page (vma))assert_pte_locked (vma->vm_mm, address);__ptep_set_access_flags (ptep, entry); -flush_tlb_page_nohash (vma, address); +flush_tlb_page (vma, address); }return changed; }
arch/powerpc/mm/tlb_hash32.c +0 -11
@@ -49,17 +49,6 @@ void flush_hash_entry(struct mm_struct *mm, pte_t *ptep, unsigned long addr)EXPORT_SYMBOL (flush_hash_entry);/* -* Called by ptep_set_access_flags, must flush on CPUs for which the -* DSI handler can't just "fixup" the TLB on a write fault -*/ -void flush_tlb_page_nohash (struct vm_area_struct *vma,unsigned long addr) -{ -if (Hash !=0 ) -return ; -_tlbie (addr); -} - -/* * Called at the end of a mmu_gather operation to make sure the * TLB flush is completely done. */
Signature · 1 line
2.7.4