mm/hugetlb: Simplify hugetlb unmap
Subsystems (11)
PATCH 1/4 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.
--- mm/hugetlb.c | 54 +++++++++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 33 deletions(-)
mm/hugetlb.c +21 -33
@@ -3138,7 +3138,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;
@@ -3157,19 +3156,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
@@ -3177,7 +3179,8 @@ again:*/ if (unlikely (!pte_present (pte))) {huge_pte_clear (mm, address, ptep); - goto unlock; +spin_unlock (ptl); +continue ; } page =pte_page (pte);
@@ -3187,9 +3190,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
@@ -3205,30 +3209,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 · 7 lines
2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/4 mm: Change the interface for __tlb_remove_page
This 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.
--- arch/arm/include/asm/tlb.h | 11 +++++++---- arch/ia64/include/asm/tlb.h | 13 ++++++++----- arch/s390/include/asm/tlb.h | 4 ++-- arch/sh/include/asm/tlb.h | 2 +- arch/um/include/asm/tlb.h | 2 +- include/asm-generic/tlb.h | 18 ++++++++++++++++-- mm/memory.c | 20 ++++++++++++++------ 7 files changed, 49 insertions(+), 21 deletions(-)
arch/arm/include/asm/tlb.h +7 -4
@@ -209,17 +209,20 @@ 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 void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
arch/ia64/include/asm/tlb.h +8 -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,10 @@ 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); + } }/*
arch/s390/include/asm/tlb.h +2 -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)
arch/sh/include/asm/tlb.h +1 -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)
arch/um/include/asm/tlb.h +1 -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)
include/asm-generic/tlb.h +16 -2
@@ -107,6 +107,11 @@ struct mmu_gather {struct mmu_gather_batch local;struct page *__pages[MMU_GATHER_BUNDLE ];unsigned int batch_count; +/* +* __tlb_adjust_range will track the new addr here, +* that that we can adjust the range after the flush +*/ +unsigned long addr; };#define HAVE_GENERIC_MMU_GATHER
@@ -115,7 +120,7 @@ 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); -int __tlb_remove_page (struct mmu_gather *tlb,struct page *page); +bool __tlb_remove_page (struct mmu_gather *tlb,struct page *page);/* tlb_remove_page * Similar to __tlb_remove_page but will call tlb_flush_mmu() itself when
@@ -123,8 +128,11 @@ int __tlb_remove_page(struct mmu_gather *tlb, struct page *page);*/ 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_adjust_range (tlb, tlb->addr); +__tlb_remove_page (tlb, page); + } } static inline void __tlb_adjust_range(struct mmu_gather *tlb,
@@ -132,6 +140,12 @@ static inline void __tlb_adjust_range(struct mmu_gather *tlb, { tlb->start =min (tlb->start, address); tlb->end =max (tlb->end, address +PAGE_SIZE ); +/* +* Track the last address with which we adjusted the range. This +* will be used later to adjust again after a mmu_flush due to +* failed __tlb_remove_page +*/ + tlb->addr = address; }static inline void __tlb_reset_range (struct mmu_gather *tlb)
mm/memory.c +14 -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,12 @@ again:if (force_flush) { force_flush =0 ;tlb_flush_mmu_free (tlb); - +if (pending_page) { +/* remove the page with new size */ +__tlb_adjust_range (tlb, tlb->addr); +__tlb_remove_page (tlb, pending_page); + pending_page =NULL ; + }if (addr != end) goto again; }
Signature · 7 lines
2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/4 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
--- arch/arm/include/asm/tlb.h | 18 +++++++++++++++ arch/ia64/include/asm/tlb.h | 18 +++++++++++++++ arch/s390/include/asm/tlb.h | 18 +++++++++++++++ arch/sh/include/asm/tlb.h | 18 +++++++++++++++ arch/um/include/asm/tlb.h | 18 +++++++++++++++ include/asm-generic/tlb.h | 56 +++++++++++++++++++++++++++++++++------------ mm/huge_memory.c | 2 +- mm/hugetlb.c | 2 +- mm/memory.c | 13 ++++++++--- 9 files changed, 144 insertions(+), 19 deletions(-)
arch/arm/include/asm/tlb.h +18 -0
@@ -225,6 +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 +18 -0
@@ -242,6 +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 +18 -0
@@ -98,6 +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 +18 -0
@@ -109,6 +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 +18 -0
@@ -110,6 +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 +42 -14
79 lines not on this page · raw message
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
@@ -3211,7 +3211,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 +10 -3
@@ -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))
@@ -1207,8 +1215,7 @@ again:tlb_flush_mmu_free (tlb);if (pending_page) {/* remove the page with new size */ -__tlb_adjust_range (tlb, tlb->addr); -__tlb_remove_page (tlb, pending_page); +__tlb_remove_pte_page (tlb, pending_page); pending_page =NULL ; }if (addr != end)
Signature · 7 lines
2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/4 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.
--- arch/powerpc/mm/tlb-radix.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
arch/powerpc/mm/tlb-radix.c +27 -1
@@ -261,11 +261,37 @@ void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start, }EXPORT_SYMBOL (radix__flush_tlb_range); +static int radix_get_mmu_psize (int page_size) +{ +int psize; + +if (page_size == (1UL << mmu_psize_defs[mmu_virtual_psize].shift)) + psize = mmu_virtual_psize; +else if (page_size == (1UL << mmu_psize_defs[MMU_PAGE_2M ].shift)) + psize =MMU_PAGE_2M ; +else if (page_size == (1UL << mmu_psize_defs[MMU_PAGE_1G ].shift)) + psize =MMU_PAGE_1G ; +else +return -1 ; +return psize; +}void radix__tlb_flush (struct mmu_gather *tlb) { +int psize =0 ;struct mm_struct *mm = tlb->mm; -radix__flush_tlb_mm (mm); +int page_size = tlb->page_size; + + psize =radix_get_mmu_psize (page_size); +if (psize ==-1 ) +/* unknown page size */ + goto flush_mm; + +if (!tlb->fullmm && !tlb->need_flush_all) +radix__flush_tlb_range_psize (mm, tlb->start, tlb->end, psize); +else +flush_mm: +radix__flush_tlb_mm (mm); }/* * flush the page walk cache for the address
Signature · 7 lines
2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 4/4] powerpc/mm/radix: Implement tlb mmu gather flush efficiently
Quoted 13 lines · On Thu, 2 Jun 2016 15:09:49 +0530 "Aneesh Kumar K.V"…
Now that we track page size in
mmu_gather, we can use address based tlbie format when doing atlb_flush(). We don't do this if we are invalidating the full address space....
void
radix__tlb_flush(struct mmu_gather *tlb)
{(quoted diff) +3
-1+ int psize = 0; struct mm_struct *mm = tlb->mm; - radix__flush_tlb_mm(mm); + int page_size = tlb->page_size; +
Review
Quoted 10 lines
(quoted diff) +10
-0+ psize = radix_get_mmu_psize(page_size); + if (psize == -1) + /* unknown page size */ + goto flush_mm; + + if (!tlb->fullmm && !tlb->need_flush_all) + radix__flush_tlb_range_psize(mm, tlb->start, tlb->end, psize); + else +flush_mm: + radix__flush_tlb_mm(mm);
That's kinda ugly. What about
void radix__tlb_flush(struct mmu_gather *tlb)
{
int psize = 0;
struct mm_struct *mm = tlb->mm;
int page_size = tlb->page_size;
psize = radix_get_mmu_psize(page_size);
if (psize != -1 && !tlb->fullmm && !tlb->need_flush_all)
radix__flush_tlb_range_psize(mm, tlb->start, tlb->end, psize);
else
radix__flush_tlb_mm(mm);
}?
We lost the comment, but that can be neatly addressed by documenting radix_get_mmu_psize() (of course!). Please send along a comment to do this and I'll add it in.
arch/powerpc/mm/tlb-radix.c renamed from arch/powerpc/mm/tlb-radix.c~powerpc-mm-radix-implement-tlb-mmu-gather-flush-efficiently-fix +1 -5
@@ -265,13 +265,9 @@ void radix__tlb_flush(struct mmu_gatherint page_size = tlb->page_size; psize =radix_get_mmu_psize (page_size); -if (psize ==-1 ) -/* unknown page size */ - goto flush_mm; -if (!tlb->fullmm && !tlb->need_flush_all) +if (psize !=-1 && !tlb->fullmm && !tlb->need_flush_all)radix__flush_tlb_range_psize (mm, tlb->start, tlb->end, psize);else -flush_mm:radix__flush_tlb_mm (mm); }
_
I'll await feedback from the other PPC developers before doing anything further on this patchset.
hm, no ppc mailing lists were cc'ed. Regrettable.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] powerpc/mm/radix: Implement tlb mmu gather flush efficiently
Quoted 42 lines · Andrew Morton
Quoted 13 lines · On Thu, 2 Jun 2016 15:09:49 +0530 "Aneesh Kumar K.V"…
Now that we track page size in
mmu_gather, we can use address based tlbie format when doing atlb_flush(). We don't do this if we are invalidating the full address space....
void
radix__tlb_flush(struct mmu_gather *tlb)
{(quoted diff) +3
-1+ int psize = 0; struct mm_struct *mm = tlb->mm; - radix__flush_tlb_mm(mm); + int page_size = tlb->page_size; +Review
Quoted 10 lines
(quoted diff) +10
-0+ psize = radix_get_mmu_psize(page_size); + if (psize == -1) + /* unknown page size */ + goto flush_mm; + + if (!tlb->fullmm && !tlb->need_flush_all) + radix__flush_tlb_range_psize(mm, tlb->start, tlb->end, psize); + else +flush_mm: + radix__flush_tlb_mm(mm);That's kinda ugly. What about
void
radix__tlb_flush(struct mmu_gather *tlb){ int psize = 0; struct mm_struct *mm = tlb->mm; int page_size = tlb->page_size; psize = radix_get_mmu_psize(page_size); if (psize != -1 && !tlb->fullmm && !tlb->need_flush_all) radix__flush_tlb_range_psize(mm, tlb->start, tlb->end, psize); else radix__flush_tlb_mm(mm); }
Quoted 5 lines
?
We lost the comment, but that can be neatly addressed by documenting
radix_get_mmu_psize()(of course!). Please send along a comment to do this and I'll add it in.
I will update the patch. But this patch (Patch 4) need to go through powerpc tree because radix__flush_tlb_range_psize is not yet upstream. As I mentioned in the previous thread, if you can take patch 1 to patch 3 that will enable wider testing w.r.t other archs and ppc64 related changes can go later via powerpc tree ?
Quoted 20 lines
arch/powerpc/mm/tlb-radix.c renamed from arch/powerpc/mm/tlb-radix.c~powerpc-mm-radix-implement-tlb-mmu-gather-flush-efficiently-fix +1
-5@@ -265,13 +265,9 @@ void radix__tlb_flush(struct mmu_gatherint page_size = tlb->page_size; psize =radix_get_mmu_psize (page_size); -if (psize ==-1 ) -/* unknown page size */ - goto flush_mm; -if (!tlb->fullmm && !tlb->need_flush_all) +if (psize !=-1 && !tlb->fullmm && !tlb->need_flush_all)radix__flush_tlb_range_psize (mm, tlb->start, tlb->end, psize);else -flush_mm:radix__flush_tlb_mm (mm); }_
Quoted 4 lines
I'll await feedback from the other PPC developers before doing anything further on this patchset.
hm, no ppc mailing lists were cc'ed. Regrettable.
I missed that. I can resend the series again adding ppc-devel to cc: ?
-aneesh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>