mm/THP changes to support THP on PPC64
Subsystems (7)
This patchset include mm/ changes needed to support THP on ppc64. Some of these patches were part of earlier posts as THP patch series and have already been reviewed. I am posting this as a separate patchset for easier merge upstream.
-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>
PATCH 1/4 mm/THP: Add pmd args to pgtable deposit and withdraw APIs
From: "Aneesh Kumar K.V" <[email protected]>
This will be later used by powerpc THP support. In powerpc we want to use pgtable for storing the hash index values. So instead of adding them to mm_context list, we would like to store them in the second half of pmd
--- arch/s390/include/asm/pgtable.h | 5 +++-- arch/s390/mm/pgtable.c | 5 +++-- arch/sparc/include/asm/pgtable_64.h | 5 +++-- arch/sparc/mm/tlb.c | 5 +++-- include/asm-generic/pgtable.h | 5 +++-- mm/huge_memory.c | 18 +++++++++--------- mm/pgtable-generic.c | 5 +++-- 7 files changed, 27 insertions(+), 21 deletions(-)
arch/s390/include/asm/pgtable.h +3 -2
@@ -1351,10 +1351,11 @@ static inline pmd_t pmd_mkwrite(pmd_t pmd)#ifdef CONFIG_TRANSPARENT_HUGEPAGE #define __HAVE_ARCH_PGTABLE_DEPOSIT -extern void pgtable_trans_huge_deposit (struct mm_struct *mm,pgtable_t pgtable); +extern void pgtable_trans_huge_deposit(struct mm_struct *mm, , pmd_t *pmdp, +pgtable_t pgtable);#define __HAVE_ARCH_PGTABLE_WITHDRAW -extern pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm); +extern pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp);static inline int pmd_trans_splitting (pmd_t pmd) {
arch/s390/mm/pgtable.c +3 -2
@@ -1118,7 +1118,8 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address, } } -void pgtable_trans_huge_deposit (struct mm_struct *mm,pgtable_t pgtable) +void pgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp, +pgtable_t pgtable) {struct list_head *lh = (struct list_head *) pgtable;
@@ -1132,7 +1133,7 @@ void pgtable_trans_huge_deposit(struct mm_struct *mm, pgtable_t pgtable) mm->pmd_huge_pte = pgtable; } -pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm) +pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp) {struct list_head *lh;pgtable_t pgtable;
arch/sparc/include/asm/pgtable_64.h +3 -2
@@ -853,10 +853,11 @@ extern void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd);#define __HAVE_ARCH_PGTABLE_DEPOSIT -extern void pgtable_trans_huge_deposit (struct mm_struct *mm,pgtable_t pgtable); +extern void pgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp, +pgtable_t pgtable);#define __HAVE_ARCH_PGTABLE_WITHDRAW -extern pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm); +extern pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp);#endif /* Encode and de-code a swap entry */
arch/sparc/mm/tlb.c +3 -2
@@ -188,7 +188,8 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr, } } -void pgtable_trans_huge_deposit (struct mm_struct *mm,pgtable_t pgtable) +void pgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp, +pgtable_t pgtable) {struct list_head *lh = (struct list_head *) pgtable;
@@ -202,7 +203,7 @@ void pgtable_trans_huge_deposit(struct mm_struct *mm, pgtable_t pgtable) mm->pmd_huge_pte = pgtable; } -pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm) +pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp) {struct list_head *lh;pgtable_t pgtable;
include/asm-generic/pgtable.h +3 -2
@@ -173,11 +173,12 @@ extern void pmdp_splitting_flush(struct vm_area_struct *vma,#endif #ifndef __HAVE_ARCH_PGTABLE_DEPOSIT -extern void pgtable_trans_huge_deposit (struct mm_struct *mm,pgtable_t pgtable); +extern void pgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp, +pgtable_t pgtable);#endif #ifndef __HAVE_ARCH_PGTABLE_WITHDRAW -extern pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm); +extern pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp);#endif #ifndef __HAVE_ARCH_PMDP_INVALIDATE
mm/huge_memory.c +9 -9
@@ -730,7 +730,7 @@ static int __do_huge_pmd_anonymous_page(struct mm_struct *mm, entry =mk_huge_pmd (page, vma);page_add_new_anon_rmap (page, vma, haddr);set_pmd_at (mm, haddr, pmd, entry); -pgtable_trans_huge_deposit (mm, pgtable); +pgtable_trans_huge_deposit (mm, pmd, pgtable);add_mm_counter (mm,MM_ANONPAGES ,HPAGE_PMD_NR ); mm->nr_ptes++;spin_unlock (&mm->page_table_lock);
@@ -772,7 +772,7 @@ static bool set_huge_zero_page(pgtable_t pgtable, struct mm_struct *mm, entry =pmd_wrprotect (entry); entry =pmd_mkhuge (entry);set_pmd_at (mm, haddr, pmd, entry); -pgtable_trans_huge_deposit (mm, pgtable); +pgtable_trans_huge_deposit (mm, pmd, pgtable); mm->nr_ptes++;return true; }
@@ -917,7 +917,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,pmdp_set_wrprotect (src_mm, addr, src_pmd); pmd =pmd_mkold (pmd_wrprotect (pmd));set_pmd_at (dst_mm, addr, dst_pmd, pmd); -pgtable_trans_huge_deposit (dst_mm, pgtable); +pgtable_trans_huge_deposit (dst_mm, dst_pmd, pgtable); dst_mm->nr_ptes++; ret =0 ;
@@ -987,7 +987,7 @@ static int do_huge_pmd_wp_zero_page_fallback(struct mm_struct *mm,pmdp_clear_flush (vma, haddr, pmd);/* leave pmd empty until pte is filled */ - pgtable =pgtable_trans_huge_withdraw (mm); + pgtable =pgtable_trans_huge_withdraw (mm, pmd);pmd_populate (mm, &_pmd, pgtable);for (i =0 ; i <HPAGE_PMD_NR ; i++, haddr +=PAGE_SIZE ) {
@@ -1085,7 +1085,7 @@ static int do_huge_pmd_wp_page_fallback(struct mm_struct *mm,pmdp_clear_flush (vma, haddr, pmd);/* leave pmd empty until pte is filled */ - pgtable =pgtable_trans_huge_withdraw (mm); + pgtable =pgtable_trans_huge_withdraw (mm, pmd);pmd_populate (mm, &_pmd, pgtable);for (i =0 ; i <HPAGE_PMD_NR ; i++, haddr +=PAGE_SIZE ) {
@@ -1360,7 +1360,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,struct page *page;pgtable_t pgtable;pmd_t orig_pmd; - pgtable =pgtable_trans_huge_withdraw (tlb->mm); + pgtable =pgtable_trans_huge_withdraw (tlb->mm, pmd); orig_pmd =pmdp_get_and_clear (tlb->mm, addr, pmd);tlb_remove_pmd_tlb_entry (tlb, pmd, addr);if (is_huge_zero_pmd (orig_pmd)) {
@@ -1693,7 +1693,7 @@ static int __split_huge_page_map(struct page *page, pmd =page_check_address_pmd (page, mm, address,PAGE_CHECK_ADDRESS_PMD_SPLITTING_FLAG );if (pmd) { - pgtable =pgtable_trans_huge_withdraw (mm); + pgtable =pgtable_trans_huge_withdraw (mm, pmd);pmd_populate (mm, &_pmd, pgtable); haddr = address;
@@ -2358,7 +2358,7 @@ static void collapse_huge_page(struct mm_struct *mm,page_add_new_anon_rmap (new_page, vma, address);set_pmd_at (mm, address, pmd, _pmd);update_mmu_cache_pmd (vma, address, pmd); -pgtable_trans_huge_deposit (mm, pgtable); +pgtable_trans_huge_deposit (mm, pmd, pgtable);spin_unlock (&mm->page_table_lock); *hpage =NULL ;
@@ -2664,7 +2664,7 @@ static void __split_huge_zero_page_pmd(struct vm_area_struct *vma,pmdp_clear_flush (vma, haddr, pmd);/* leave pmd empty until pte is filled */ - pgtable =pgtable_trans_huge_withdraw (mm); + pgtable =pgtable_trans_huge_withdraw (mm, pmd);pmd_populate (mm, &_pmd, pgtable);for (i =0 ; i <HPAGE_PMD_NR ; i++, haddr +=PAGE_SIZE ) {
mm/pgtable-generic.c +3 -2
@@ -124,7 +124,8 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address, #ifndef __HAVE_ARCH_PGTABLE_DEPOSIT #ifdef CONFIG_TRANSPARENT_HUGEPAGE -void pgtable_trans_huge_deposit(struct mm_struct *mm, pgtable_t pgtable) +void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, + pgtable_t pgtable) { assert_spin_locked(&mm->page_table_lock);
@@ -141,7 +142,7 @@ void pgtable_trans_huge_deposit(struct mm_struct *mm, pgtable_t pgtable) #ifndef __HAVE_ARCH_PGTABLE_WITHDRAW #ifdef CONFIG_TRANSPARENT_HUGEPAGE /* no "address" argument so destroys page coloring of some arch */ -pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm) +pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) { pgtable_t pgtable;
Signature · 7 lines
1.8.1.2 -- 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/THP: withdraw the pgtable after pmdp related operations
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
For architectures like ppc64 we look at deposited pgtable when calling pmdp_get_and_clear. So do the pgtable_trans_huge_withdraw after finishing pmdp related operations.
--- mm/huge_memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
mm/huge_memory.c +7 -1
@@ -1360,9 +1360,15 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,struct page *page;pgtable_t pgtable;pmd_t orig_pmd; - pgtable =pgtable_trans_huge_withdraw (tlb->mm, pmd); +/* +* For architectures like ppc64 we look at deposited pgtable +* when calling pmdp_get_and_clear. So do the +* pgtable_trans_huge_withdraw after finishing pmdp related +* operations. +*/ orig_pmd =pmdp_get_and_clear (tlb->mm, addr, pmd);tlb_remove_pmd_tlb_entry (tlb, pmd, addr); + pgtable =pgtable_trans_huge_withdraw (tlb->mm, pmd);if (is_huge_zero_pmd (orig_pmd)) { tlb->mm->nr_ptes--;spin_unlock (&tlb->mm->page_table_lock);
Signature · 7 lines
1.8.1.2 -- 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/THP: Don't use HPAGE_SHIFT in transparent hugepage code
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
For architectures like powerpc that support multiple explicit hugepage sizes, HPAGE_SHIFT indicate the default explicit hugepage shift. For THP to work the hugepage size should be same as PMD_SIZE. So use PMD_SHIFT directly. So move the define outside CONFIG_TRANSPARENT_HUGEPAGE #ifdef because we want to use these defines in generic code with if (pmd_trans_huge()) conditional.
--- include/linux/huge_mm.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
include/linux/huge_mm.h +3 -7
@@ -58,12 +58,11 @@ extern pmd_t *page_check_address_pmd(struct page *page,#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER) +#define HPAGE_PMD_SHIFT PMD_SHIFT +#define HPAGE_PMD_SIZE ((1UL) << HPAGE_PMD_SHIFT) +#define HPAGE_PMD_MASK (~(HPAGE_PMD_SIZE - 1))#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define HPAGE_PMD_SHIFT HPAGE_SHIFT -#define HPAGE_PMD_MASK HPAGE_MASK -#define HPAGE_PMD_SIZE HPAGE_SIZE -extern bool is_vma_temporary_stack (struct vm_area_struct *vma);#define transparent_hugepage_enabled (__vma) \
@@ -181,9 +180,6 @@ extern int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vm unsigned long addr, pmd_t pmd, pmd_t *pmdp);#else /* CONFIG_TRANSPARENT_HUGEPAGE */ -#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) -#define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; }) -#define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; })#define hpage_nr_pages (x) 1
Signature · 7 lines
1.8.1.2 -- 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 mm/THP: deposit the transpare huge pgtable before set_pmd
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
Architectures like powerpc use the deposited pgtable to store hash index values. We need to make the deposted pgtable is visible to other cpus before we are ready to take a hash fault.
--- mm/huge_memory.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/huge_memory.c +4 -4
@@ -729,8 +729,8 @@ static int __do_huge_pmd_anonymous_page(struct mm_struct *mm,pmd_t entry; entry =mk_huge_pmd (page, vma);page_add_new_anon_rmap (page, vma, haddr); -set_pmd_at (mm, haddr, pmd, entry);pgtable_trans_huge_deposit (mm, pmd, pgtable); +set_pmd_at (mm, haddr, pmd, entry);add_mm_counter (mm,MM_ANONPAGES ,HPAGE_PMD_NR ); mm->nr_ptes++;spin_unlock (&mm->page_table_lock);
@@ -771,8 +771,8 @@ static bool set_huge_zero_page(pgtable_t pgtable, struct mm_struct *mm, entry =mk_pmd (zero_page, vma->vm_page_prot); entry =pmd_wrprotect (entry); entry =pmd_mkhuge (entry); -set_pmd_at (mm, haddr, pmd, entry);pgtable_trans_huge_deposit (mm, pmd, pgtable); +set_pmd_at (mm, haddr, pmd, entry); mm->nr_ptes++;return true; }
@@ -916,8 +916,8 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,pmdp_set_wrprotect (src_mm, addr, src_pmd); pmd =pmd_mkold (pmd_wrprotect (pmd)); -set_pmd_at (dst_mm, addr, dst_pmd, pmd);pgtable_trans_huge_deposit (dst_mm, dst_pmd, pgtable); +set_pmd_at (dst_mm, addr, dst_pmd, pmd); dst_mm->nr_ptes++; ret =0 ;
@@ -2362,9 +2362,9 @@ static void collapse_huge_page(struct mm_struct *mm,spin_lock (&mm->page_table_lock);BUG_ON (!pmd_none (*pmd));page_add_new_anon_rmap (new_page, vma, address); +pgtable_trans_huge_deposit (mm, pmd, pgtable);set_pmd_at (mm, address, pmd, _pmd);update_mmu_cache_pmd (vma, address, pmd); -pgtable_trans_huge_deposit (mm, pmd, pgtable);spin_unlock (&mm->page_table_lock); *hpage =NULL ;
Signature · 7 lines
1.8.1.2 -- 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>