mm/thp/migration: switch from flush_tlb_range to flush_pmd_tlb_range
Subsystems (6)
PATCH v2 1/1 mm/thp/migration: switch from flush_tlb_range to flush_pmd_tlb_range
We remove one instace of flush_tlb_range here. That was added by f714f4f20e59ea6eea264a86b9a51fd51b88fc54 ("mm: numa: call MMU notifiers on THP migration"). But the pmdp_huge_clear_flush_notify should have done the require flush for us. Hence remove the extra flush.
---
Changes from V1:
* fix build error
include/asm-generic/pgtable.h | 17 +++++++++++++++++ mm/migrate.c | 8 +++++--- mm/pgtable-generic.c | 14 -------------- 3 files changed, 22 insertions(+), 17 deletions(-)
include/asm-generic/pgtable.h +17 -0
@@ -783,6 +783,23 @@ static inline int pmd_clear_huge(pmd_t *pmd) }#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ +#ifndef __HAVE_ARCH_FLUSH_PMD_TLB_RANGE +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* +* ARCHes with special requirements for evicting THP backing TLB entries can +* implement this. Otherwise also, it can help optimize normal TLB flush in +* THP regime. stock flush_tlb_range() typically has optimization to nuke the +* entire TLB TLB if flush span is greater than a threshold, which will +* likely be true for a single huge page. Thus a single thp flush will +* invalidate the entire TLB which is not desitable. +* e.g. see arch/arc: flush_pmd_tlb_range +*/ +#define flush_pmd_tlb_range (vma, addr, end) flush_tlb_range(vma, addr, end) +#else +#define flush_pmd_tlb_range (vma, addr, end) BUILD_BUG() +#endif +#endif +#endif /* !__ASSEMBLY__ */ #ifndef io_remap_pfn_range
mm/migrate.c +5 -3
@@ -1767,7 +1767,10 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,put_page (new_page); goto out_fail; } - +/* +* We are not sure a pending tlb flush here is for a huge page +* mapping or not. Hence use the tlb range variant +*/ if (mm_tlb_flush_pending (mm))flush_tlb_range (vma, mmun_start, mmun_end);
@@ -1823,12 +1826,11 @@ fail_putback:page_add_anon_rmap (new_page, vma, mmun_start, true);pmdp_huge_clear_flush_notify (vma, mmun_start, pmd);set_pmd_at (mm, mmun_start, pmd, entry); -flush_tlb_range (vma, mmun_start, mmun_end);update_mmu_cache_pmd (vma, address, &entry);if (page_count (page) !=2 ) {set_pmd_at (mm, mmun_start, pmd, orig_entry); -flush_tlb_range (vma, mmun_start, mmun_end); +flush_pmd_tlb_range (vma, mmun_start, mmun_end);mmu_notifier_invalidate_range (mm, mmun_start, mmun_end);update_mmu_cache_pmd (vma, address, &entry);page_remove_rmap (new_page, true);
mm/pgtable-generic.c +0 -14
@@ -84,20 +84,6 @@ pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address,#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#ifndef __HAVE_ARCH_FLUSH_PMD_TLB_RANGE - -/* -* ARCHes with special requirements for evicting THP backing TLB entries can -* implement this. Otherwise also, it can help optimize normal TLB flush in -* THP regime. stock flush_tlb_range() typically has optimization to nuke the -* entire TLB TLB if flush span is greater than a threshhold, which will -* likely be true for a single huge page. Thus a single thp flush will -* invalidate the entire TLB which is not desitable. -* e.g. see arch/arc: flush_pmd_tlb_range -*/ -#define flush_pmd_tlb_range (vma, addr, end) flush_tlb_range(vma, addr, end) -#endif -#ifndef __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp,
Signature · 7 lines
2.5.0 -- 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>
Quoted 49 lines · Aneesh Kumar K.V
We remove one instace of
flush_tlb_rangehere. That was added byf714f4f20e59ea6eea264a86b9a51fd51b88fc54("mm: numa: call MMU notifiers on THP migration"). But thepmdp_huge_clear_flush_notifyshould have done the require flush for us. Hence remove the extra flush.Signed-off-by Aneesh Kumar K.V <[email protected]>---
Changes from V1:
* fix build errorinclude/asm-generic/pgtable.h | 17 +++++++++++++++++ mm/migrate.c | 8 +++++--- mm/pgtable-generic.c | 14 -------------- 3 files changed, 22 insertions(+), 17 deletions(-)include/asm-generic/pgtable.h +17
-0@@ -783,6 +783,23 @@ static inline int pmd_clear_huge(pmd_t *pmd) }#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ +#ifndef __HAVE_ARCH_FLUSH_PMD_TLB_RANGE +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* +* ARCHes with special requirements for evicting THP backing TLB entries can +* implement this. Otherwise also, it can help optimize normal TLB flush in +* THP regime. stock flush_tlb_range() typically has optimization to nuke the +* entire TLB TLB if flush span is greater than a threshold, which will +* likely be true for a single huge page. Thus a single thp flush will +* invalidate the entire TLB which is not desitable. +* e.g. see arch/arc: flush_pmd_tlb_range +*/ +#define flush_pmd_tlb_range (vma, addr, end) flush_tlb_range(vma, addr, end) +#else +#define flush_pmd_tlb_range (vma, addr, end) BUILD_BUG() +#endif +#endif +#endif /* !__ASSEMBLY__ */ #ifndef io_remap_pfn_rangemm/migrate.c +0
-0@@ -1767,7 +1767,10 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,put_page (new_page);
mm/migrate.c int migrate_misplaced_transhuge_page(struct mm_struct *mm, · line 1776
Quoted 10 lines
mm/migrate.c +4
-1goto out_fail; } - +/* +* We are not sure a pending tlb flush here is for a huge page +* mapping or not. Hence use the tlb range variant +*/ if (mm_tlb_flush_pending (mm))flush_tlb_range (vma, mmun_start, mmun_end);
I was thinking we should be able to switch this flush_pmd_tlb_range. But Kirill was not sure when we discussed this last time. Can we have a pending tlb flush with PAGE_SIZE page translation, when we are parallely trying to handle a autonuma fault on that ?
Quoted 41 lines
mm/migrate.c +1
-2@@ -1823,12 +1826,11 @@ fail_putback:page_add_anon_rmap (new_page, vma, mmun_start, true);pmdp_huge_clear_flush_notify (vma, mmun_start, pmd);set_pmd_at (mm, mmun_start, pmd, entry); -flush_tlb_range (vma, mmun_start, mmun_end);update_mmu_cache_pmd (vma, address, &entry);if (page_count (page) !=2 ) {set_pmd_at (mm, mmun_start, pmd, orig_entry); -flush_tlb_range (vma, mmun_start, mmun_end); +flush_pmd_tlb_range (vma, mmun_start, mmun_end);mmu_notifier_invalidate_range (mm, mmun_start, mmun_end);update_mmu_cache_pmd (vma, address, &entry);page_remove_rmap (new_page, true);mm/pgtable-generic.c +0
-14@@ -84,20 +84,6 @@ pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address,#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#ifndef __HAVE_ARCH_FLUSH_PMD_TLB_RANGE - -/* -* ARCHes with special requirements for evicting THP backing TLB entries can -* implement this. Otherwise also, it can help optimize normal TLB flush in -* THP regime. stock flush_tlb_range() typically has optimization to nuke the -* entire TLB TLB if flush span is greater than a threshhold, which will -* likely be true for a single huge page. Thus a single thp flush will -* invalidate the entire TLB which is not desitable. -* e.g. see arch/arc: flush_pmd_tlb_range -*/ -#define flush_pmd_tlb_range (vma, addr, end) flush_tlb_range(vma, addr, end) -#endif -#ifndef __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp,Signature · 1 line
2.5.0
-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>
ARC !THP broken in linux-next (was Re: [PATCH V2] mm/thp/migration: switch from flush_tlb_range to flush_pmd_tlb_range)
In reply to Aneesh Kumar K.VHi Aneesh,
Quoted 6 lines · Aneesh Kumar K.V
We remove one instace of
flush_tlb_rangehere. That was added byf714f4f20e59ea6eea264a86b9a51fd51b88fc54("mm: numa: call MMU notifiers on THP migration"). But thepmdp_huge_clear_flush_notifyshould have done the require flush for us. Hence remove the extra flush.Signed-off-by Aneesh Kumar K.V <[email protected]>
linux-next fails for ARC with this - although this is not your fault. Back then, per your request I did verify that ARC builds fine with this for CONFIG_TRANSPARENT_HUGEPAGE worked. However I failed to check the !THP case which is broken.
@Andrew could you please add the patch below to mm tree !
Thx,
Vineet
------------>
Quoted 1 line
From
8e31856c9b154cc152486aa411ee38b4c737c7c3Mon Sep 17 00:00:00 2001
From: Vineet Gupta <[email protected]>
Date: Thu, 17 Mar 2016 15:00:59 +0530
Subject: [PATCH] ARC: thp: unbork !CONFIG_TRANSPARENT_HUGEPAGE build
linux-next for 4.6-rc1 timeline reported ARC build failures !THP
| arch/arc/include/asm/tlbflush.h:29:0: warning: "flush_pmd_tlb_range" redefined [enabled by default]
| arch/arc/include/asm/tlbflush.h:29:0: warning: "flush_pmd_tlb_range" redefined [enabled by default]
| arch/arc/include/asm/tlbflush.h:29:0: warning: "flush_pmd_tlb_range" redefined [enabled by default]
Turns out that commit ("mm/thp/migration: switch from flush_tlb_range to flush_pmd_tlb_range") triggered the issue while the problem was in ARC code where THP specific helpers were not guarded with #ifdef.
--- arch/arc/include/asm/tlbflush.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arc/include/asm/tlbflush.h +0 -0
@@ -17,8 +17,10 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned
long page);
void local_flush_tlb_kernel_range(unsigned long start, unsigned long end); void local_flush_tlb_range(struct vm_area_struct *vma,
unsigned long start, unsigned long end);
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
void local_flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end);
+#endif
#ifndef CONFIG_SMP
#define flush_tlb_range(vma, s, e) local_flush_tlb_range(vma, s, e)
@@ -26,7 +28,9 @@ void local_flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
#define flush_tlb_kernel_range(s, e) local_flush_tlb_kernel_range(s, e)
#define flush_tlb_all() local_flush_tlb_all()
#define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
#define flush_pmd_tlb_range(vma, s, e) local_flush_pmd_tlb_range(vma, s, e)
+#endif
#else
extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end);
@@ -34,7 +38,8 @@ extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long page);
extern void flush_tlb_kernel_range(unsigned long start, unsigned long end); extern void flush_tlb_all(void);
extern void flush_tlb_mm(struct mm_struct *mm);
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
extern void flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end);
-
+#endif
#endif /* CONFIG_SMP */
#endif
Signature · 7 lines
2.5.0 -- 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: ARC !THP broken in linux-next (was Re: [PATCH V2] mm/thp/migration: switch from flush_tlb_range to flush_pmd_tlb_range)
Quoted 1 line · Vineet Gupta
@Andrew could you please add the patch below to mm tree !
Never mind - I pushed it to my tree as this fix has no real dependency on original patch and seems to be the right things with or w/o it.
Thx,
-Vineet
--
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>