thp: transparent hugepages on System z
Subsystems (7)
cover thp: transparent hugepages on System z
This patch series adds support for transparent hugepages on System z. Small changes to common code are necessary with regard to a different pgtable_t, tlb flushing and kvm behaviour on s390, see patches 1 to 3.
--
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>
RFC PATCH 1/7 thp: remove assumptions on pgtable_t type
The thp page table pre-allocation code currently assumes that pgtable_t is of type "struct page *". This may not be true for all architectures, so this patch removes that assumption by replacing the functions prepare_pmd_huge_pte() and get_pmd_huge_pte() with two new functions that can be defined architecture-specific.
It also removes two VM_BUG_ON checks for page_count() and page_mapcount() operating on a pgtable_t. Apart from the VM_BUG_ON removal, there will be no functional change introduced by this patch.
--- include/asm-generic/pgtable.h | 6 +++++ include/linux/huge_mm.h | 1 mm/huge_memory.c | 46 +++++------------------------------------- mm/pgtable-generic.c | 39 +++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 41 deletions(-)
include/asm-generic/pgtable.h +6 -0
@@ -443,6 +443,12 @@ static inline int pmd_write(pmd_t pmd)return 0 ; }#endif /* __HAVE_ARCH_PMD_WRITE */ +#ifndef __HAVE_ARCH_PGTABLE_DEPOSIT +extern void pgtable_deposit (struct mm_struct *mm,pgtable_t pgtable); +#endif +#ifndef __HAVE_ARCH_PGTABLE_WITHDRAW +extern pgtable_t pgtable_withdraw (struct mm_struct *mm); +#endif #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #ifndef pmd_read_atomic
include/linux/huge_mm.h +0 -1
@@ -11,7 +11,6 @@ extern int copy_huge_pmd(struct mm_strucextern int do_huge_pmd_wp_page (struct mm_struct *mm,struct vm_area_struct *vma,unsigned long address,pmd_t *pmd,pmd_t orig_pmd); -extern pgtable_t get_pmd_huge_pte (struct mm_struct *mm); extern struct page *follow_trans_huge_pmd(struct mm_struct *mm, unsigned long addr, pmd_t *pmd,
mm/huge_memory.c +6 -40
100 lines not on this page · raw message
mm/pgtable-generic.c +39 -0
@@ -120,3 +120,42 @@ void pmdp_splitting_flush(struct vm_area }#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif + +#ifndef __HAVE_ARCH_PGTABLE_DEPOSIT +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +void pgtable_deposit (struct mm_struct *mm,pgtable_t pgtable) +{ +assert_spin_locked (&mm->page_table_lock); + +/* FIFO */ +if (!mm->pmd_huge_pte) +INIT_LIST_HEAD (&pgtable->lru); +else +list_add (&pgtable->lru, &mm->pmd_huge_pte->lru); + mm->pmd_huge_pte = pgtable; +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#endif + +#ifndef __HAVE_ARCH_PGTABLE_WITHDRAW +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* no "address" argument so destroys page coloring of some arch */ +pgtable_t pgtable_withdraw (struct mm_struct *mm) +{ +pgtable_t pgtable; + +assert_spin_locked (&mm->page_table_lock); + +/* FIFO */ + pgtable = mm->pmd_huge_pte; +if (list_empty (&pgtable->lru)) + mm->pmd_huge_pte =NULL ; +else { + mm->pmd_huge_pte =list_entry (pgtable->lru.next, + struct page, lru); +list_del (&pgtable->lru); + } +return pgtable; +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#endif
--
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>
RFC PATCH 2/7 thp: introduce pmdp_invalidate()
In reply to Gerald SchaeferOn System z, a valid page table entry must not be changed while it is attached to any CPU. So instead of pmd_mknotpresent() and set_pmd_at(), an IDTE operation would be necessary there. This patch introduces the pmdp_invalidate() function, to allow architecture-specific implementations.
--- include/asm-generic/pgtable.h | 11 +++++++++++ mm/huge_memory.c | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-)
include/asm-generic/pgtable.h +11 -0
@@ -93,6 +93,17 @@ static inline pmd_t pmdp_get_and_clear(s#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif +#ifndef __HAVE_ARCH_PMDP_INVALIDATE +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static inline void pmdp_invalidate (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp) +{ +set_pmd_at (vma->vm_mm, address, pmd,pmd_mknotpresent (*pmd)); +flush_tlb_range (vma, address, address +HPAGE_PMD_SIZE ); +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#endif +#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long address, pte_t *ptep,
mm/huge_memory.c +1 -2
@@ -1374,8 +1374,7 @@ static int __split_huge_page_map(struct* SMP TLB and finally we write the non-huge version * of the pmd entry with pmd_populate. */ -set_pmd_at (mm, address, pmd,pmd_mknotpresent (*pmd)); -flush_tlb_range (vma, address, address +HPAGE_PMD_SIZE ); +pmdp_invalidate (vma, address, pmd);pmd_populate (mm, pmd, pgtable); ret =1 ; }
--
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: [RFC patch 2/7] thp: introduce pmdp_invalidate()
include/asm-generic/pgtable.h static inline pmd_t pmdp_get_and_clear(s · line 101
Quoted 6 lines · Gerald Schaefer
include/asm-generic/pgtable.h +6
-0+#ifndef __HAVE_ARCH_PMDP_INVALIDATE +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static inline void pmdp_invalidate(struct vm_area_struct *vma, + unsigned long address, pmd_t *pmdp) +{ + set_pmd_at(vma->vm_mm, address, pmd, pmd_mknotpresent(*pmd));
set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(*pmdp)); yes?
include/asm-generic/pgtable.h static inline pmd_t pmdp_get_and_clear(s · line 103
Quoted 2 lines
include/asm-generic/pgtable.h +2
-0+flush_tlb_range (vma, address, address +HPAGE_PMD_SIZE ); +}
--
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: [RFC patch 2/7] thp: introduce pmdp_invalidate()
Quoted 11 lines · On Sat, 25 Aug 2012 20:36:37 +0800 Hillf Danton <[email protected]> wrote:
include/asm-generic/pgtable.h static inline pmd_t pmdp_get_and_clear(s · line 101
Quoted 6 lines · Gerald Schaefer
include/asm-generic/pgtable.h +6
-0+#ifndef __HAVE_ARCH_PMDP_INVALIDATE +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static inline void pmdp_invalidate(struct vm_area_struct *vma, + unsigned long address, pmd_t *pmdp) +{ + set_pmd_at(vma->vm_mm, address, pmd, pmd_mknotpresent(*pmd));set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(*pmdp)); yes?
Ah yes, I mixed that up, thanks.
--
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>
RFC PATCH 3/7 thp: make MADV_HUGEPAGE check for mm->def_flags
In reply to Gerald SchaeferThis adds a check to hugepage_madvise(), to refuse MADV_HUGEPAGE if VM_NOHUGEPAGE is set in mm->def_flags. On System z, the VM_NOHUGEPAGE flag will be set in mm->def_flags for kvm processes, to prevent any future thp mappings. In order to also prevent MADV_HUGEPAGE on such an mm, hugepage_madvise() should check mm->def_flags.
--- mm/huge_memory.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/huge_memory.c +4 -0
@@ -1464,6 +1464,8 @@ out:int hugepage_madvise (struct vm_area_struct *vma,unsigned long *vm_flags,int advice) { +struct mm_struct *mm = vma->vm_mm; +switch (advice) {case MADV_HUGEPAGE :/*
@@ -1471,6 +1473,8 @@ int hugepage_madvise(struct vm_area_stru*/ if (*vm_flags & (VM_HUGEPAGE |VM_NO_THP ))return -EINVAL ; +if (mm->def_flags &VM_NOHUGEPAGE ) +return -EINVAL ; *vm_flags &= ~VM_NOHUGEPAGE ; *vm_flags |=VM_HUGEPAGE ;/*
--
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: [RFC patch 3/7] thp: make MADV_HUGEPAGE check for mm->def_flags
Quoted 23 lines · Gerald Schaefer
This adds a check to
hugepage_madvise(), to refuseMADV_HUGEPAGEifVM_NOHUGEPAGEis set inmm->def_flags. On System z, theVM_NOHUGEPAGEflag will be set inmm->def_flagsfor kvm processes, to prevent any future thp mappings. In order to also preventMADV_HUGEPAGEon such an mm,hugepage_madvise()should checkmm->def_flags.Signed-off-by Gerald Schaefer <[email protected]>--- mm/huge_memory.c | 4 ++++ 1 file changed, 4 insertions(+)mm/huge_memory.c +2
-0@@ -1464,6 +1464,8 @@ out:int hugepage_madvise (struct vm_area_struct *vma,unsigned long *vm_flags,int advice) { +struct mm_struct *mm = vma->vm_mm; +switch (advice) {case MADV_HUGEPAGE :/*
mm/huge_memory.c int hugepage_madvise(struct vm_area_stru · line 1477
Quoted 5 lines
mm/huge_memory.c +2
-0@@ -1471,6 +1473,8 @@ int hugepage_madvise(struct vm_area_stru*/ if (*vm_flags & (VM_HUGEPAGE |VM_NO_THP ))return -EINVAL ; +if (mm->def_flags &VM_NOHUGEPAGE ) +return -EINVAL ;
Looks ifdefinery needed for s390 to wrap the added check, and a brief comment?
mm/huge_memory.c int hugepage_madvise(struct vm_area_stru · line 1479
Quoted 2 lines
mm/huge_memory.c +0
-0*vm_flags &= ~VM_NOHUGEPAGE ; *vm_flags |=VM_HUGEPAGE ;
--
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: [RFC patch 3/7] thp: make MADV_HUGEPAGE check for mm->def_flags
Quoted 25 lines · On Sat, 25 Aug 2012 20:47:37 +0800 Hillf Danton <[email protected]> wrote:
Quoted 23 lines · Gerald Schaefer
This adds a check to
hugepage_madvise(), to refuseMADV_HUGEPAGEifVM_NOHUGEPAGEis set inmm->def_flags. On System z, theVM_NOHUGEPAGEflag will be set inmm->def_flagsfor kvm processes, to prevent any future thp mappings. In order to also preventMADV_HUGEPAGEon such an mm,hugepage_madvise()should checkmm->def_flags.Signed-off-by Gerald Schaefer <[email protected]>--- mm/huge_memory.c | 4 ++++ 1 file changed, 4 insertions(+)mm/huge_memory.c +2
-0@@ -1464,6 +1464,8 @@ out:int hugepage_madvise (struct vm_area_struct *vma,unsigned long *vm_flags,int advice) { +struct mm_struct *mm = vma->vm_mm; +switch (advice) {case MADV_HUGEPAGE :/* @@ -1471,6 +1473,8 @@ int hugepage_madvise(struct vm_area_stru
Quoted 8 lines
mm/huge_memory.c int hugepage_madvise(struct vm_area_stru · line 1477
Quoted 5 lines
mm/huge_memory.c +2
-0*/ if (*vm_flags & (VM_HUGEPAGE |VM_NO_THP ))return -EINVAL ; +if (mm->def_flags &VM_NOHUGEPAGE ) +return -EINVAL ;Looks ifdefinery needed for s390 to wrap the added check, and a brief comment?
Hmm, architecture #ifdefs in common code are ugly. I'd rather keep the check even if it is redundant right now for other architectures than s390. It is not a performance critical path, and there may be other users of that in the future.
--
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: [RFC patch 3/7] thp: make MADV_HUGEPAGE check for mm->def_flags
Quoted 4 lines · Gerald Schaefer
Hmm, architecture #ifdefs in common code are ugly. I'd rather keep the check even if it is redundant right now for other architectures than s390. It is not a performance critical path, and there may be other users of that in the future.
Fair if no changes in semantics
--
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>
RFC PATCH 4/7 thp, s390: thp splitting backend for System z
In reply to Gerald SchaeferThis patch is part of the architecture backend for thp on System z. It provides the functions related to thp splitting, including serialization against gup. Unlike other archs, pmdp_splitting_flush() cannot use a tlb flushing operation to serialize against gup on s390, because that wouldn't be stopped by the disabled IRQs. So instead, smp_call_function() is called with an empty function, which will have the expected effect.
--- arch/s390/include/asm/pgtable.h | 13 +++++++++++++ arch/s390/mm/gup.c | 11 ++++++++++- arch/s390/mm/pgtable.c | 18 ++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-)
arch/s390/include/asm/pgtable.h +13 -0
@@ -347,6 +347,8 @@ extern struct page *vmemmap;#define _SEGMENT_ENTRY_LARGE 0x400/* STE-format control, large page */ #define _SEGMENT_ENTRY_CO 0x100/* change-recording override */ +#define _SEGMENT_ENTRY_SPLIT_BIT 0/* THP splitting bit number */ +#define _SEGMENT_ENTRY_SPLIT (1UL << _SEGMENT_ENTRY_SPLIT_BIT)/* Page status table bits for virtualization */ #define RCP_ACC_BITS 0xf000000000000000UL
@@ -506,6 +508,10 @@ static inline int pmd_bad(pmd_t pmd)return (pmd_val (pmd) & mask) != _SEGMENT_ENTRY; } +#define __HAVE_ARCH_PMDP_SPLITTING_FLUSH +extern void pmdp_splitting_flush (struct vm_area_struct *vma, +unsigned long addr,pmd_t *pmdp); +static inline int pte_none (pte_t pte) {return (pte_val (pte) & _PAGE_INVALID) && !(pte_val (pte) & _PAGE_SWT);
@@ -1159,6 +1165,13 @@ static inline pmd_t *pmd_offset(pud_t *p#define pte_offset_map (pmd, address) pte_offset_kernel(pmd, address)#define pte_unmap (pte) do { } while (0) +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static inline int pmd_trans_splitting (pmd_t pmd) +{ +return pmd_val (pmd) & _SEGMENT_ENTRY_SPLIT; +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +/* * 31 bit swap entry format: * A page-table entry has some bits we have to treat in a special way.
arch/s390/mm/gup.c +10 -1
@@ -115,7 +115,16 @@ static inline int gup_pmd_range(pud_t *p pmd = *pmdp;barrier (); next =pmd_addr_end (addr, end); -if (pmd_none (pmd)) +/* +* The pmd_trans_splitting() check below explains why +* pmdp_splitting_flush() has to serialize with +* smp_call_function() against our disabled IRQs, to stop +* this gup-fast code from running while we set the +* splitting bit in the pmd. Returning zero will take +* the slow path that will call wait_split_huge_page() +* if the pmd is still in splitting state. +*/ +if (pmd_none (pmd) ||pmd_trans_splitting (pmd))return 0 ; if (unlikely(pmd_huge(pmd))) { if (!gup_huge_pmd(pmdp, pmd, addr, next,
arch/s390/mm/pgtable.c +18 -0
@@ -866,3 +866,21 @@ bool kernel_page_present(struct page *pa return cc == 0; }#endif /* CONFIG_HIBERNATION && CONFIG_DEBUG_PAGEALLOC */ + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static void pmdp_splitting_flush_sync (void *arg) +{ +/* Simply deliver the interrupt */ +} + +void pmdp_splitting_flush (struct vm_area_struct *vma,unsigned long address, +pmd_t *pmdp) +{ +VM_BUG_ON (address & ~HPAGE_PMD_MASK ); +if (!test_and_set_bit (_SEGMENT_ENTRY_SPLIT_BIT, + (unsigned long *) pmdp)) { +/* need to serialize against gup-fast (IRQ disabled) */ +smp_call_function (pmdp_splitting_flush_sync,NULL ,1 ); + } +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
--
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>
RFC PATCH 5/7 thp, s390: thp pagetable pre-allocation for System z
In reply to Gerald SchaeferThis patch is part of the architecture backend for thp on System z. It provides the pagetable pre-allocation functions pgtable_deposit() and pgtable_withdraw(). Unlike other archs, s390 has no struct page * as pgtable_t, but rather a pointer to the page table. So instead of saving the pagetable pre-allocation list info inside the struct page, it is being saved within the pagetable itself.
--- arch/s390/include/asm/pgtable.h | 6 ++++++ arch/s390/mm/pgtable.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
arch/s390/include/asm/pgtable.h +6 -0
@@ -1166,6 +1166,12 @@ static inline pmd_t *pmd_offset(pud_t *p#define pte_unmap (pte) do { } while (0)#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define __HAVE_ARCH_PGTABLE_DEPOSIT +extern void pgtable_deposit (struct mm_struct *mm,pgtable_t pgtable); + +#define __HAVE_ARCH_PGTABLE_WITHDRAW +extern pgtable_t pgtable_withdraw (struct mm_struct *mm); +static inline int pmd_trans_splitting (pmd_t pmd) {return pmd_val (pmd) & _SEGMENT_ENTRY_SPLIT;
arch/s390/mm/pgtable.c +38 -0
@@ -883,4 +883,42 @@ void pmdp_splitting_flush(struct vm_area smp_call_function(pmdp_splitting_flush_sync, NULL, 1); } } + +void pgtable_deposit (struct mm_struct *mm,pgtable_t pgtable) +{ +struct list_head *lh = (struct list_head *) pgtable; + +assert_spin_locked (&mm->page_table_lock); + +/* FIFO */ +if (!mm->pmd_huge_pte) +INIT_LIST_HEAD (lh); +else +list_add (lh, (struct list_head *) mm->pmd_huge_pte); + mm->pmd_huge_pte = pgtable; +} + +pgtable_t pgtable_withdraw (struct mm_struct *mm) +{ +struct list_head *lh; +pgtable_t pgtable; +pte_t *ptep; + +assert_spin_locked (&mm->page_table_lock); + +/* FIFO */ + pgtable = mm->pmd_huge_pte; + lh = (struct list_head *) pgtable; +if (list_empty (lh)) + mm->pmd_huge_pte =NULL ; +else { + mm->pmd_huge_pte = (pgtable_t ) lh->next; +list_del (lh); + } + ptep = (pte_t *) pgtable; +pte_val (*ptep) = _PAGE_TYPE_EMPTY; + ptep++; +pte_val (*ptep) = _PAGE_TYPE_EMPTY; +return pgtable; +}#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
--
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>
RFC PATCH 6/7 thp, s390: disable thp for kvm host on System z
In reply to Gerald SchaeferThis patch is part of the architecture backend for thp on System z. It disables thp for kvm hosts, because there is no kvm host hugepage support so far. Existing thp mappings are split using follow_page() with FOLL_SPLIT, and future thp mappings are prevented by setting VM_NOHUGEPAGE in mm->def_flags.
--- arch/s390/mm/pgtable.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
arch/s390/mm/pgtable.c +30 -0
@@ -787,6 +787,30 @@ void tlb_remove_table(struct mmu_gathertlb_table_flush (tlb); } +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +void thp_split_vma (struct vm_area_struct *vma) +{ +unsigned long addr; +struct page *page; + +for (addr = vma->vm_start; addr < vma->vm_end; addr +=PAGE_SIZE ) { + page =follow_page (vma, addr,FOLL_SPLIT ); + } +} + +void thp_split_mm (struct mm_struct *mm) +{ +struct vm_area_struct *vma = mm->mmap; + +while (vma !=NULL ) { +thp_split_vma (vma); + vma->vm_flags &= ~VM_HUGEPAGE ; + vma->vm_flags |=VM_NOHUGEPAGE ; + vma = vma->vm_next; + } +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +/* * switch on pgstes for its userspace process (for kvm) */
@@ -824,6 +848,12 @@ int s390_enable_sie(void)if (!mm)return -ENOMEM ; +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* split thp mappings and disable thp for future mappings */ +thp_split_mm (mm); + mm->def_flags |=VM_NOHUGEPAGE ; +#endif +/* Now lets check again if something happened */ task_lock (tsk); if (!tsk->mm || atomic_read(&tsk->mm->mm_users) > 1 ||
--
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>
RFC PATCH 7/7 thp, s390: architecture backend for thp on System z
In reply to Gerald SchaeferThis implements the architecture backend for transparent hugepages on System z.
--- arch/s390/include/asm/hugetlb.h | 18 ---- arch/s390/include/asm/pgtable.h | 176 ++++++++++++++++++++++++++++++++++++++++ arch/s390/include/asm/tlb.h | 1 arch/s390/mm/pgtable.c | 22 +++++ mm/Kconfig | 2 5 files changed, 201 insertions(+), 18 deletions(-)
arch/s390/include/asm/hugetlb.h +1 -17
@@ -87,23 +87,6 @@ static inline void __pmd_csp(pmd_t *pmdp " csp %1,%3" : "=m" (*pmdp) : "d" (reg2), "d" (reg3), "d" (reg4), "m" (*pmdp) : "cc"); -pmd_val (*pmdp) = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY; -} - -static inline void __pmd_idte (unsigned long address,pmd_t *pmdp) -{ -unsigned long sto = (unsigned long ) pmdp - -pmd_index (address) *sizeof (pmd_t); - -if (!(pmd_val (*pmdp) & _SEGMENT_ENTRY_INV)) { - asmvolatile ( -" .insn rrf,0xb98e0000,%2,%3,0,0" - :"=m" (*pmdp) - :"m" (*pmdp),"a" (sto), -"a" ((address &HPAGE_MASK )) - ); - } -pmd_val (*pmdp) = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY; } static inline void huge_ptep_invalidate(struct mm_struct *mm,
@@ -115,6 +98,7 @@ static inline void huge_ptep_invalidate(__pmd_idte (address, pmdp); else__pmd_csp (pmdp ); +pmd_val (*pmdp) = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY; }#define huge_ptep_set_access_flags (__vma, __addr, __ptep, __entry, __dirty) \
arch/s390/include/asm/pgtable.h +176 -0
200 lines not on this page · raw message
arch/s390/include/asm/tlb.h +1 -0
@@ -137,6 +137,7 @@ static inline void pud_free_tlb(struct m#define tlb_start_vma (tlb, vma) do { } while (0)#define tlb_end_vma (tlb, vma) do { } while (0)#define tlb_remove_tlb_entry (tlb, ptep, addr) do { } while (0) +#define tlb_remove_pmd_tlb_entry (tlb, pmdp, addr) do { } while (0)#define tlb_migrate_finish (mm) do { } while (0)#endif /* _S390_TLB_H */
arch/s390/mm/pgtable.c +22 -0
@@ -898,6 +898,28 @@ bool kernel_page_present(struct page *pa#endif /* CONFIG_HIBERNATION && CONFIG_DEBUG_PAGEALLOC */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE +int pmdp_clear_flush_young (struct vm_area_struct *vma,unsigned long address, +pmd_t *pmdp) +{ +VM_BUG_ON (address & ~HPAGE_PMD_MASK ); +/* No need to flush TLB +* On s390 reference bits are in storage key and never in TLB */ +return pmdp_test_and_clear_young (vma, address, pmdp); +} + +int pmdp_set_access_flags (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp, +pmd_t entry,int dirty) +{ +VM_BUG_ON (address & ~HPAGE_PMD_MASK ); + +if (pmd_same (*pmdp, entry)) +return 0 ; +pmdp_invalidate (vma, address, pmdp); +set_pmd_at (vma->vm_mm, address, pmdp, entry); +return 1 ; +} +static void pmdp_splitting_flush_sync (void *arg) {/* Simply deliver the interrupt */
mm/Kconfig +1 -1
@@ -318,7 +318,7 @@ config NOMMU_INITIAL_TRIM_EXCESS config TRANSPARENT_HUGEPAGE bool "Transparent Hugepage Support" - depends on X86 && MMU + depends on (X86 || (S390 && 64BIT)) && MMU select COMPACTION help Transparent Hugepages allows the kernel to use huge pages and
--
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: [RFC patch 7/7] thp, s390: architecture backend for thp on System z
Quoted 9 lines · Gerald Schaefer
arch/s390/include/asm/pgtable.h +9
-0+#define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG +static inline int pmdp_test_and_clear_young (struct vm_area_struct *vma, +unsigned long address, +pmd_t *pmdp) +{ +int rc =0 ; +int counter =PTRS_PER_PTE ; +unsigned long pmd_addr =pmd_val (*pmdp) &HPAGE_MASK ; +
arch/s390/include/asm/pgtable.h static inline int pmd_trans_splitting(pm · line 1301
Quoted 10 lines
arch/s390/include/asm/pgtable.h +10
-0+ asmvolatile ( +"0: rrbe 0,%2\n" +" la %2,0(%3,%2)\n" +" brc 12,1f\n" +" lhi %0,1\n" +"1: brct %1,0b\n" + :"+d" (rc),"+d" (counter),"+a" (pmd_addr) + :"a" (4096UL ):"cc" ); +return rc; +}
Just a small side note: given that rrbe is very expensive you probably should extend this function so it makes use of the rrbm instruction if available.
--
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>