BOOk3s 64 MMU code cleanup
Subsystems (2)
cover BOOk3s 64 MMU code cleanup
This series include changes that should help in implementing radix MMU model. Besides that, we also try to consolidate hash64 code into separate files wherever it simplifies the existing code by removing #ifdef around C code. IMHO code movement also helps in indicating supported features on different platforms better. (Changes like moving THP to hash64 indicates that for now we only have THP implemented for hash64).
The series is on top of changes posted at
http://mid.gmane.org/1456805714-21774-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com
Aneesh Kumar K.V (8):
powerp/mm: Update code comments
powerpc/mm: add _PAGE_HASHPTE similar to 4K hash powerpc/mm: Use flush_tlb_page in ptep_clear_flush_young powerpc/mm: Move hash related mmu-*.h headers to book3s/ powerpc/mm: Create a new headers for tlbflush for hash64 powerpc/mm: Move hash page table related functions to pgtable-hash64.c powerpc/mm: THP is only available on hash64 as of now powerpc/mm: Use generic version of pmdp_clear_flush_young
.../asm/{mmu-hash32.h => book3s/32/mmu-hash.h} | 0
arch/powerpc/include/asm/book3s/64/hash.h | 47 +-
.../asm/{mmu-hash64.h => book3s/64/mmu-hash.h} | 0
arch/powerpc/include/asm/book3s/64/pgtable.h | 26 +-
arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 94 ++++
arch/powerpc/include/asm/mmu.h | 4 +-
arch/powerpc/include/asm/nohash/64/pgtable.h | 3 +
arch/powerpc/include/asm/tlbflush.h | 92 +--
arch/powerpc/kernel/cpu_setup_power.S | 2 +-
arch/powerpc/kernel/idle_power7.S | 2 +-
arch/powerpc/kvm/book3s_32_mmu_host.c | 2 +-
arch/powerpc/kvm/book3s_64_mmu.c | 2 +-
arch/powerpc/kvm/book3s_64_mmu_host.c | 2 +-
arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +-
arch/powerpc/kvm/book3s_64_vio.c | 2 +-
arch/powerpc/kvm/book3s_64_vio_hv.c | 2 +-
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +-
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +-
arch/powerpc/mm/Makefile | 3 +-
arch/powerpc/mm/hash64_4k.c | 4 +-
arch/powerpc/mm/hash64_64k.c | 4 +-
arch/powerpc/mm/init_64.c | 114 +---
arch/powerpc/mm/mem.c | 29 +-
arch/powerpc/mm/mmu_decl.h | 5 -
arch/powerpc/mm/pgtable-book3e.c | 163 ++++++
arch/powerpc/mm/pgtable-hash64.c | 614 +++++++++++++++++++++
arch/powerpc/mm/pgtable.c | 9 +
arch/powerpc/mm/pgtable_64.c | 461 ----------------
arch/powerpc/mm/ppc_mmu_32.c | 30 +
29 files changed, 973 insertions(+), 749 deletions(-)
rename arch/powerpc/include/asm/{mmu-hash32.h => book3s/32/mmu-hash.h} (100%)
rename arch/powerpc/include/asm/{mmu-hash64.h => book3s/64/mmu-hash.h} (100%)
create mode 100644 arch/powerpc/include/asm/book3s/64/tlbflush-hash.h
create mode 100644 arch/powerpc/mm/pgtable-book3e.c
create mode 100644 arch/powerpc/mm/pgtable-hash64.cSignature · 1 line
2.5.0
PATCH 1/8 powerp/mm: Update code comments
We are updating pte in those functions.
--- arch/powerpc/mm/hash64_4k.c | 2 +- arch/powerpc/mm/hash64_64k.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/mm/hash64_4k.c +1 -1
@@ -106,7 +106,7 @@ repeat: } }/* -* Hypervisor failure. Restore old pmd and return -1 +* Hypervisor failure. Restore old pte and return -1 * similar to __hash_page_* */ if (unlikely (slot ==-2 )) {
arch/powerpc/mm/hash64_64k.c +2 -2
@@ -188,7 +188,7 @@ repeat: } }/* -* Hypervisor failure. Restore old pmd and return -1 +* Hypervisor failure. Restore old pte and return -1 * similar to __hash_page_* */ if (unlikely (slot ==-2 )) {
@@ -310,7 +310,7 @@ repeat: } }/* -* Hypervisor failure. Restore old pmd and return -1 +* Hypervisor failure. Restore old pte and return -1 * similar to __hash_page_* */ if (unlikely (slot ==-2 )) {
Signature · 1 line
2.5.0
Re: [1/8] powerp/mm: Update code comments
Quoted 3 lines · Aneesh Kumar K.V
We are updating pte in those functions.
Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/e9a681478ce535b4a0263a760a
cheers
PATCH 2/8 powerpc/mm: add _PAGE_HASHPTE similar to 4K hash
In reply to Aneesh Kumar K.VWe don't need to update linux page table entry with _PAGE_HASHPTE early in hash pte fault. A parallel pte update will loop via _PAGE_BUSY and look at _PAGE_HASHPTE for a required hpte flush only if _PAGE_BUSY is cleared. That ensures a pte update will wait for a parallel hpte insert to finish before looking at _PAGE_HASHPTE bit.
To avoid further confusion drop setting _PAGE_HASHPTE in cmpxchg in __hash_page_4K.
commit 41743a4e34f0 ("powerpc: Free a PTE bit on ppc64 with 64K pages") did similar change for 64K config
--- arch/powerpc/mm/hash64_4k.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/hash64_4k.c +1 -1
@@ -44,7 +44,7 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,* a write access. Since this is 4K insert of 64K page size * also add _PAGE_COMBO */ - new_pte = old_pte | _PAGE_BUSY | _PAGE_ACCESSED | _PAGE_HASHPTE; + new_pte = old_pte | _PAGE_BUSY | _PAGE_ACCESSED;if (access & _PAGE_RW) new_pte |= _PAGE_DIRTY; } while (old_pte != __cmpxchg_u64((unsigned long *)ptep,
Signature · 1 line
2.5.0
Re: [2/8] powerpc/mm: add _PAGE_HASHPTE similar to 4K hash
Quoted 6 lines · Aneesh Kumar K.V
We don't need to update linux page table entry with
_PAGE_HASHPTEearly in hash pte fault. A parallel pte update will loop via_PAGE_BUSYand look at_PAGE_HASHPTEfor a required hpte flush only if_PAGE_BUSYis cleared. That ensures a pte update will wait for a parallel hpte insert to finish before looking at_PAGE_HASHPTEbit.
Quoted 6 lines
To avoid further confusion drop setting
_PAGE_HASHPTEin cmpxchg in__hash_page_4K.commit
41743a4e34f0("powerpc: Free a PTE bit on ppc64 with 64K pages") did similar change for 64K configSigned-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/c367a44133bcd7f94fb48b58e9
cheers
PATCH 3/8 powerpc/mm: Use flush_tlb_page in ptep_clear_flush_young
In reply to Aneesh Kumar K.VThis should not have any impact for hash linux implementation. But radix would require us to flush tlb after clearing accessed bit. Also move code that is not dependent on pte bits to generic header.
We use the generic version of ptep_clear_flush_young here.
--- arch/powerpc/include/asm/book3s/64/hash.h | 45 +++++----------------------- arch/powerpc/include/asm/book3s/64/pgtable.h | 23 ++++++++++++++ 2 files changed, 31 insertions(+), 37 deletions(-)
arch/powerpc/include/asm/book3s/64/hash.h +8 -37
@@ -272,6 +272,14 @@ static inline unsigned long pte_update(struct mm_struct *mm,return old; } +/* +* We currently remove entries from the hashtable regardless of whether +* the entry was young or dirty. The generic routines only flush if the +* entry was young or dirty which is not good enough. +* +* We should be more intelligent about this but for the moment we override +* these functions and force a tlb flush unconditionally +*/ static inline int __ptep_test_and_clear_young (struct mm_struct *mm,unsigned long addr,pte_t *ptep) {
@@ -282,13 +290,6 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm, old =pte_update (mm, addr, ptep, _PAGE_ACCESSED,0 ,0 );return (old & _PAGE_ACCESSED) !=0 ; } -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -#define ptep_test_and_clear_young (__vma, __addr, __ptep) \ -({ \ - int __r; \ - __r = __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep); \ - __r; \ -})#define __HAVE_ARCH_PTEP_SET_WRPROTECT static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
@@ -310,36 +311,6 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,pte_update (mm, addr, ptep, _PAGE_RW,0 ,1 ); } -/* -* We currently remove entries from the hashtable regardless of whether -* the entry was young or dirty. The generic routines only flush if the -* entry was young or dirty which is not good enough. -* -* We should be more intelligent about this but for the moment we override -* these functions and force a tlb flush unconditionally -*/ -#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH -#define ptep_clear_flush_young (__vma, __address, __ptep) \ -({ \ - int __young = __ptep_test_and_clear_young((__vma)->vm_mm, __address, \ - __ptep); \ - __young; \ -}) - -#define __HAVE_ARCH_PTEP_GET_AND_CLEAR -static inline pte_t ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) -{ -unsigned long old =pte_update (mm, addr, ptep, ~0UL ,0 ,0 ); -return __pte (old); -} - -static inline void pte_clear (struct mm_struct *mm,unsigned long addr, -pte_t * ptep) -{ -pte_update (mm, addr, ptep, ~0UL ,0 ,0 ); -} -/* Set the dirty and/or accessed bits atomically in a linux PTE, this * function doesn't need to flush the hash entry
arch/powerpc/include/asm/book3s/64/pgtable.h +23 -0
@@ -62,6 +62,29 @@#endif /* __real_pte */ +#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG +#define ptep_test_and_clear_young (__vma, __addr, __ptep) \ +({ \ + int __r; \ + __r = __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep); \ + __r; \ +}) + +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +static inline pte_t ptep_get_and_clear (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) +{ +unsigned long old =pte_update (mm, addr, ptep, ~0UL ,0 ,0 ); + +return __pte (old); +} + +static inline void pte_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep) +{ +pte_update (mm, addr, ptep, ~0UL ,0 ,0 ); +} +static inline void pmd_set (pmd_t *pmdp,unsigned long val) { *pmdp =__pmd (val);
Signature · 1 line
2.5.0
PATCH 4/8 powerpc/mm: Move hash related mmu-*.h headers to book3s/
In reply to Aneesh Kumar K.V---
arch/powerpc/include/asm/{mmu-hash32.h => book3s/32/mmu-hash.h} | 0
arch/powerpc/include/asm/{mmu-hash64.h => book3s/64/mmu-hash.h} | 0
arch/powerpc/include/asm/mmu.h | 4 ++--
arch/powerpc/kernel/cpu_setup_power.S | 2 +-
arch/powerpc/kernel/idle_power7.S | 2 +-
arch/powerpc/kvm/book3s_32_mmu_host.c | 2 +-
arch/powerpc/kvm/book3s_64_mmu.c | 2 +-
arch/powerpc/kvm/book3s_64_mmu_host.c | 2 +-
arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +-
arch/powerpc/kvm/book3s_64_vio.c | 2 +-
arch/powerpc/kvm/book3s_64_vio_hv.c | 2 +-
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +-
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +-
13 files changed, 12 insertions(+), 12 deletions(-)
rename arch/powerpc/include/asm/{mmu-hash32.h => book3s/32/mmu-hash.h} (100%)
rename arch/powerpc/include/asm/{mmu-hash64.h => book3s/64/mmu-hash.h} (100%)arch/powerpc/include/asm/book3s/32/mmu-hash.h renamed from arch/powerpc/include/asm/mmu-hash32.h +0 -0
arch/powerpc/include/asm/book3s/64/mmu-hash.h renamed from arch/powerpc/include/asm/mmu-hash64.h +0 -0
arch/powerpc/include/asm/mmu.h +2 -2
@@ -183,10 +183,10 @@ static inline void assert_pte_locked(struct mm_struct *mm, unsigned long addr)#if defined(CONFIG_PPC_STD_MMU_64 )/* 64-bit classic hash table MMU */ -# include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> #elif defined(CONFIG_PPC_STD_MMU_32 )/* 32-bit classic hash table MMU */ -# include <asm/mmu-hash32.h> +#include <asm/book3s/32/mmu-hash.h> #elif defined(CONFIG_40x)/* 40x-style software loaded TLB */ # include <asm/mmu-40x.h>
arch/powerpc/kernel/cpu_setup_power.S +1 -1
@@ -15,7 +15,7 @@ #include <asm/ppc_asm.h> #include <asm/asm-offsets.h> #include <asm/cache.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> /* Entry: r3 = crap, r4 = ptr to cputable entry *
arch/powerpc/kernel/idle_power7.S +1 -1
@@ -19,7 +19,7 @@ #include <asm/kvm_book3s_asm.h> #include <asm/opal.h> #include <asm/cpuidle.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> #undef DEBUG
arch/powerpc/kvm/book3s_32_mmu_host.c +1 -1
@@ -22,7 +22,7 @@#include <asm/kvm_ppc.h> #include <asm/kvm_book3s.h> -#include <asm/mmu-hash32.h> +#include <asm/book3s/32/mmu-hash.h> #include <asm/machdep.h> #include <asm/mmu_context.h> #include <asm/hw_irq.h>
arch/powerpc/kvm/book3s_64_mmu.c +1 -1
@@ -26,7 +26,7 @@#include <asm/tlbflush.h> #include <asm/kvm_ppc.h> #include <asm/kvm_book3s.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> /* #define DEBUG_MMU */
arch/powerpc/kvm/book3s_64_mmu_host.c +1 -1
@@ -23,7 +23,7 @@#include <asm/kvm_ppc.h> #include <asm/kvm_book3s.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> #include <asm/machdep.h> #include <asm/mmu_context.h> #include <asm/hw_irq.h>
arch/powerpc/kvm/book3s_64_mmu_hv.c +1 -1
@@ -32,7 +32,7 @@#include <asm/tlbflush.h> #include <asm/kvm_ppc.h> #include <asm/kvm_book3s.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> #include <asm/hvcall.h> #include <asm/synch.h> #include <asm/ppc-opcode.h>
arch/powerpc/kvm/book3s_64_vio.c +1 -1
@@ -30,7 +30,7 @@#include <asm/tlbflush.h> #include <asm/kvm_ppc.h> #include <asm/kvm_book3s.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> #include <asm/hvcall.h> #include <asm/synch.h> #include <asm/ppc-opcode.h>
arch/powerpc/kvm/book3s_64_vio_hv.c +1 -1
@@ -29,7 +29,7 @@#include <asm/tlbflush.h> #include <asm/kvm_ppc.h> #include <asm/kvm_book3s.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> #include <asm/hvcall.h> #include <asm/synch.h> #include <asm/ppc-opcode.h>
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1 -1
@@ -17,7 +17,7 @@#include <asm/tlbflush.h> #include <asm/kvm_ppc.h> #include <asm/kvm_book3s.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> #include <asm/hvcall.h> #include <asm/synch.h> #include <asm/ppc-opcode.h>
arch/powerpc/kvm/book3s_hv_rmhandlers.S +1 -1
@@ -27,7 +27,7 @@ #include <asm/asm-offsets.h> #include <asm/exception-64s.h> #include <asm/kvm_book3s_asm.h> -#include <asm/mmu-hash64.h> +#include <asm/book3s/64/mmu-hash.h> #include <asm/tm.h> #define VCPU_GPRS_TM(reg) (((reg) * ULONG_SIZE) + VCPU_GPR_TM)
Signature · 1 line
2.5.0
Re: [4/8] powerpc/mm: Move hash related mmu-*.h headers to book3s/
Quoted 1 line · Aneesh Kumar K.V
Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/f64e8084c94bb0449177364856
cheers
PATCH 5/8 powerpc/mm: Create a new headers for tlbflush for hash64
In reply to Aneesh Kumar K.V--- arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 94 ++++++++++++++++++++++ arch/powerpc/include/asm/tlbflush.h | 92 +-------------------- 2 files changed, 95 insertions(+), 91 deletions(-) create mode 100644 arch/powerpc/include/asm/book3s/64/tlbflush-hash.h
arch/powerpc/include/asm/book3s/64/tlbflush-hash.h new file +94 -0
@@ -0,0 +1,94 @@ +#ifndef _ASM_POWERPC_BOOK3S_64_TLBFLUSH_HASH_H +#define _ASM_POWERPC_BOOK3S_64_TLBFLUSH_HASH_H + +#define MMU_NO_CONTEXT 0 + +/* +* TLB flushing for 64-bit hash-MMU CPUs +*/ + +#include <linux/percpu.h> +#include <asm/page.h> + +#define PPC64_TLB_BATCH_NR 192 + +struct ppc64_tlb_batch { +int active; +unsigned long index; +struct mm_struct *mm; +real_pte_t pte[PPC64_TLB_BATCH_NR ]; +unsigned long vpn[PPC64_TLB_BATCH_NR ]; +unsigned int psize; +int ssize; +}; +DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); + +extern void __flush_tlb_pending (struct ppc64_tlb_batch *batch); + +#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE + +static inline void arch_enter_lazy_mmu_mode (void ) +{ +struct ppc64_tlb_batch *batch =this_cpu_ptr (&ppc64_tlb_batch); + + batch->active =1 ; +} + +static inline void arch_leave_lazy_mmu_mode (void ) +{ +struct ppc64_tlb_batch *batch =this_cpu_ptr (&ppc64_tlb_batch); + +if (batch->index) +__flush_tlb_pending (batch); + batch->active =0 ; +} + +#define arch_flush_lazy_mmu_mode () do {} while (0) + + +extern void flush_hash_page (unsigned long vpn,real_pte_t pte,int psize, +int ssize,unsigned long flags); +extern void flush_hash_range (unsigned long number,int local); +extern void flush_hash_hugepage (unsigned long vsid,unsigned long addr, +pmd_t *pmdp,unsigned int psize,int ssize, +unsigned long flags); + +static inline void local_flush_tlb_mm (struct mm_struct *mm) +{ +} + +static inline void flush_tlb_mm (struct mm_struct *mm) +{ +} + +static inline void local_flush_tlb_page (struct vm_area_struct *vma, +unsigned long vmaddr) +{ +} + +static inline void flush_tlb_page (struct vm_area_struct *vma, +unsigned long vmaddr) +{ +} + +static inline void flush_tlb_page_nohash (struct vm_area_struct *vma, +unsigned long vmaddr) +{ +} + +static inline void flush_tlb_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end) +{ +} + +static inline void flush_tlb_kernel_range (unsigned long start, +unsigned long end) +{ +} + +/* Private function for use by PCI IO mapping code */ +extern void __flush_hash_table_range (struct mm_struct *mm,unsigned long start, +unsigned long end); +extern void flush_tlb_pmd_range (struct mm_struct *mm,pmd_t *pmd, +unsigned long addr); +#endif /* _ASM_POWERPC_BOOK3S_64_TLBFLUSH_HASH_H */
arch/powerpc/include/asm/tlbflush.h +1 -91
98 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [5/8] powerpc/mm: Create a new headers for tlbflush for hash64
Quoted 1 line · Aneesh Kumar K.V
Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/ee3b93ebfbed6279f7a3290014
cheers
PATCH 6/8 powerpc/mm: Move hash page table related functions to pgtable-hash64.c
In reply to Aneesh Kumar K.VThis moves kernel page mapping, page table cache init and vmemmap routines to hash64 file. For hash we don't create linux page table entries for linear mapping and having then in a separate file like pgtable-hash64.c helps. This also help in adding radix routines later.
--- arch/powerpc/include/asm/book3s/64/hash.h | 2 + arch/powerpc/include/asm/nohash/64/pgtable.h | 3 + arch/powerpc/mm/Makefile | 3 +- arch/powerpc/mm/init_64.c | 114 +------------ arch/powerpc/mm/mem.c | 29 +--- arch/powerpc/mm/mmu_decl.h | 5 - arch/powerpc/mm/pgtable-book3e.c | 163 ++++++++++++++++++ arch/powerpc/mm/pgtable-hash64.c | 247 +++++++++++++++++++++++++++ arch/powerpc/mm/pgtable.c | 9 + arch/powerpc/mm/pgtable_64.c | 88 ---------- arch/powerpc/mm/ppc_mmu_32.c | 30 ++++ 11 files changed, 464 insertions(+), 229 deletions(-) create mode 100644 arch/powerpc/mm/pgtable-book3e.c create mode 100644 arch/powerpc/mm/pgtable-hash64.c
arch/powerpc/include/asm/book3s/64/hash.h +2 -0
@@ -527,6 +527,8 @@ static inline void hpte_do_hugepage_flush(struct mm_struct *mm, }#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +extern int map_kernel_page (unsigned long ea,unsigned long pa, +unsigned long flags);#endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */
arch/powerpc/include/asm/nohash/64/pgtable.h +3 -0
@@ -362,6 +362,9 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)void pgtable_cache_add (unsigned shift,void (*ctor)(void *));void pgtable_cache_init (void ); +extern int map_kernel_page (unsigned long ea,unsigned long pa, +unsigned long flags); +#endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_NOHASH_64_PGTABLE_H */
arch/powerpc/mm/Makefile +2 -1
@@ -13,7 +13,8 @@ obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ tlb_nohash_low.o obj-$(CONFIG_PPC_BOOK3E) += tlb_low_$(CONFIG_WORD_SIZE)e.o hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o -obj-$(CONFIG_PPC_STD_MMU_64) += hash_utils_64.o slb_low.o slb.o $(hash64-y) +obj-$(CONFIG_PPC_BOOK3E_64) += pgtable-book3e.o +obj-$(CONFIG_PPC_STD_MMU_64) += pgtable-hash64.o hash_utils_64.o slb_low.o slb.o $(hash64-y) obj-$(CONFIG_PPC_STD_MMU_32) += ppc_mmu_32.o hash_low_32.o obj-$(CONFIG_PPC_STD_MMU) += tlb_hash$(CONFIG_WORD_SIZE).o \ mmu_context_hash$(CONFIG_WORD_SIZE).o
arch/powerpc/mm/init_64.c +6 -108
154 lines not on this page · raw message
arch/powerpc/mm/mem.c +2 -27
@@ -476,6 +476,7 @@ void flush_icache_user_range(struct vm_area_struct *vma, struct page *page, }EXPORT_SYMBOL (flush_icache_user_range); +#ifndef CONFIG_PPC_STD_MMU /* * This is called at the end of handling a user page fault, when the * fault has been handled by updating a PTE in the linux page tables.
@@ -487,39 +488,13 @@ EXPORT_SYMBOL(flush_icache_user_range);void update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep) { -#ifdef CONFIG_PPC_STD_MMU -/* -* We don't need to worry about _PAGE_PRESENT here because we are -* called with either mm->page_table_lock held or ptl lock held -*/ -unsigned long access =0 , trap; - -/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */ -if (!pte_young (*ptep) || address >=TASK_SIZE ) -return ; - -/* We try to figure out if we are coming from an instruction -* access fault and pass that down to __hash_page so we avoid -* double-faulting on execution of fresh text. We have to test -* for regs NULL since init will get here first thing at boot -* -* We also avoid filling the hash if not coming from a fault -*/ -if (current->thread.regs ==NULL ) -return ; - trap =TRAP (current->thread.regs); -if (trap ==0x400 ) - access |= _PAGE_EXEC; -else if (trap !=0x300 ) -return ; -hash_preload (vma->vm_mm, address, access, trap); -#endif /* CONFIG_PPC_STD_MMU */ #if (defined(CONFIG_PPC_BOOK3E_64 ) || defined(CONFIG_PPC_FSL_BOOK3E )) \ && defined(CONFIG_HUGETLB_PAGE )if (is_vm_hugetlb_page (vma))book3e_hugetlb_preload (vma, address, *ptep);#endif } +#endif /* !CONFIG_PPC_STD_MMU */ /* * System memory should not be in /proc/iomem but various tools expect it
arch/powerpc/mm/mmu_decl.h +0 -5
@@ -109,11 +109,6 @@ extern unsigned long Hash_size, Hash_mask;#endif /* CONFIG_PPC32 */ -#ifdef CONFIG_PPC64 -extern int map_kernel_page (unsigned long ea,unsigned long pa, -unsigned long flags); -#endif /* CONFIG_PPC64 */ -extern unsigned long ioremap_bot;extern unsigned long __max_low_memory;extern phys_addr_t __initial_memory_limit_addr;
arch/powerpc/mm/pgtable-book3e.c new file +163 -0
163 lines not on this page · raw message
arch/powerpc/mm/pgtable-hash64.c new file +247 -0
247 lines not on this page · raw message
arch/powerpc/mm/pgtable.c +9 -0
@@ -31,6 +31,8 @@#include <asm/tlbflush.h> #include <asm/tlb.h> +#ifndef CONFIG_PPC_BOOK3S_64 +/* We have alternate definition for the below in pgtable-hash64.c */ static inline int is_exec_fault (void ) {return current->thread.regs &&TRAP (current->thread.regs) ==0x400 ;
@@ -193,6 +195,13 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,/* Perform the setting of the PTE */ __set_pte_at(mm, addr, ptep, pte, 0); } +#else +static pte_t set_access_flags_filter (pte_t pte,struct vm_area_struct *vma, +int dirty) +{ +return pte; +} +#endif /* !CONFIG_PPC_BOOK3S_64 */ /* * This is called when relaxing access to a PTE. It's also called in the page
arch/powerpc/mm/pgtable_64.c +0 -88
100 lines not on this page · raw message
arch/powerpc/mm/ppc_mmu_32.c +30 -0
@@ -174,6 +174,36 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,add_hash_page (mm->context.id, ea,pmd_val (*pmd)); } +void update_mmu_cache (struct vm_area_struct *vma,unsigned long address, +pte_t *ptep) +{ +/* +* We don't need to worry about _PAGE_PRESENT here because we are +* called with either mm->page_table_lock held or ptl lock held +*/ +unsigned long access =0 , trap; + +/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */ +if (!pte_young (*ptep) || address >=TASK_SIZE ) +return ; + +/* We try to figure out if we are coming from an instruction +* access fault and pass that down to __hash_page so we avoid +* double-faulting on execution of fresh text. We have to test +* for regs NULL since init will get here first thing at boot +* +* We also avoid filling the hash if not coming from a fault +*/ +if (current->thread.regs ==NULL ) +return ; + trap =TRAP (current->thread.regs); +if (trap ==0x400 ) + access |= _PAGE_EXEC; +else if (trap !=0x300 ) +return ; +hash_preload (vma->vm_mm, address, access, trap); +} +/* * Initialize the hash table and patch the instructions in hashtable.S. */
Signature · 1 line
2.5.0
PATCH v2 1/1 powerpc/mm: Move hash page table related functions to pgtable-hash64.c
This moves kernel page mapping, page table cache init and vmemmap routines to hash64 file. For hash we don't create linux page table entries for linear mapping and having then in a separate file like pgtable-hash64.c helps. This also help in adding radix routines later.
---
Changes from V1:
* Rebase to updated next branch
arch/powerpc/include/asm/book3s/64/hash.h | 2 + arch/powerpc/include/asm/nohash/64/pgtable.h | 3 + arch/powerpc/mm/Makefile | 3 +- arch/powerpc/mm/init_64.c | 122 +------------ arch/powerpc/mm/mem.c | 29 +-- arch/powerpc/mm/mmu_decl.h | 5 - arch/powerpc/mm/pgtable-book3e.c | 165 +++++++++++++++++ arch/powerpc/mm/pgtable-hash64.c | 253 +++++++++++++++++++++++++++ arch/powerpc/mm/pgtable.c | 9 + arch/powerpc/mm/pgtable_64.c | 88 ---------- arch/powerpc/mm/ppc_mmu_32.c | 30 ++++ 11 files changed, 472 insertions(+), 237 deletions(-) create mode 100644 arch/powerpc/mm/pgtable-book3e.c create mode 100644 arch/powerpc/mm/pgtable-hash64.c
arch/powerpc/include/asm/book3s/64/hash.h +2 -0
@@ -527,6 +527,8 @@ static inline void hpte_do_hugepage_flush(struct mm_struct *mm, }#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +extern int map_kernel_page (unsigned long ea,unsigned long pa, +unsigned long flags);#endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */
arch/powerpc/include/asm/nohash/64/pgtable.h +3 -0
@@ -362,6 +362,9 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)void pgtable_cache_add (unsigned shift,void (*ctor)(void *));void pgtable_cache_init (void ); +extern int map_kernel_page (unsigned long ea,unsigned long pa, +unsigned long flags); +#endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_NOHASH_64_PGTABLE_H */
arch/powerpc/mm/Makefile +2 -1
@@ -13,7 +13,8 @@ obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ tlb_nohash_low.o obj-$(CONFIG_PPC_BOOK3E) += tlb_low_$(CONFIG_WORD_SIZE)e.o hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o -obj-$(CONFIG_PPC_STD_MMU_64) += hash_utils_64.o slb_low.o slb.o $(hash64-y) +obj-$(CONFIG_PPC_BOOK3E_64) += pgtable-book3e.o +obj-$(CONFIG_PPC_STD_MMU_64) += pgtable-hash64.o hash_utils_64.o slb_low.o slb.o $(hash64-y) obj-$(CONFIG_PPC_STD_MMU_32) += ppc_mmu_32.o hash_low_32.o obj-$(CONFIG_PPC_STD_MMU) += tlb_hash$(CONFIG_WORD_SIZE).o \ mmu_context_hash$(CONFIG_WORD_SIZE).o
arch/powerpc/mm/init_64.c +6 -116
162 lines not on this page · raw message
arch/powerpc/mm/mem.c +2 -27
@@ -482,6 +482,7 @@ void flush_icache_user_range(struct vm_area_struct *vma, struct page *page, }EXPORT_SYMBOL (flush_icache_user_range); +#ifndef CONFIG_PPC_STD_MMU /* * This is called at the end of handling a user page fault, when the * fault has been handled by updating a PTE in the linux page tables.
@@ -493,39 +494,13 @@ EXPORT_SYMBOL(flush_icache_user_range);void update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep) { -#ifdef CONFIG_PPC_STD_MMU -/* -* We don't need to worry about _PAGE_PRESENT here because we are -* called with either mm->page_table_lock held or ptl lock held -*/ -unsigned long access =0 , trap; - -/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */ -if (!pte_young (*ptep) || address >=TASK_SIZE ) -return ; - -/* We try to figure out if we are coming from an instruction -* access fault and pass that down to __hash_page so we avoid -* double-faulting on execution of fresh text. We have to test -* for regs NULL since init will get here first thing at boot -* -* We also avoid filling the hash if not coming from a fault -*/ -if (current->thread.regs ==NULL ) -return ; - trap =TRAP (current->thread.regs); -if (trap ==0x400 ) - access |= _PAGE_EXEC; -else if (trap !=0x300 ) -return ; -hash_preload (vma->vm_mm, address, access, trap); -#endif /* CONFIG_PPC_STD_MMU */ #if (defined(CONFIG_PPC_BOOK3E_64 ) || defined(CONFIG_PPC_FSL_BOOK3E )) \ && defined(CONFIG_HUGETLB_PAGE )if (is_vm_hugetlb_page (vma))book3e_hugetlb_preload (vma, address, *ptep);#endif } +#endif /* !CONFIG_PPC_STD_MMU */ /* * System memory should not be in /proc/iomem but various tools expect it
arch/powerpc/mm/mmu_decl.h +0 -5
@@ -109,11 +109,6 @@ extern unsigned long Hash_size, Hash_mask;#endif /* CONFIG_PPC32 */ -#ifdef CONFIG_PPC64 -extern int map_kernel_page (unsigned long ea,unsigned long pa, -unsigned long flags); -#endif /* CONFIG_PPC64 */ -extern unsigned long ioremap_bot;extern unsigned long __max_low_memory;extern phys_addr_t __initial_memory_limit_addr;
arch/powerpc/mm/pgtable-book3e.c new file +165 -0
165 lines not on this page · raw message
arch/powerpc/mm/pgtable-hash64.c new file +253 -0
253 lines not on this page · raw message
arch/powerpc/mm/pgtable.c +9 -0
@@ -31,6 +31,8 @@#include <asm/tlbflush.h> #include <asm/tlb.h> +#ifndef CONFIG_PPC_BOOK3S_64 +/* We have alternate definition for the below in pgtable-hash64.c */ static inline int is_exec_fault (void ) {return current->thread.regs &&TRAP (current->thread.regs) ==0x400 ;
@@ -193,6 +195,13 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,/* Perform the setting of the PTE */ __set_pte_at(mm, addr, ptep, pte, 0); } +#else +static pte_t set_access_flags_filter (pte_t pte,struct vm_area_struct *vma, +int dirty) +{ +return pte; +} +#endif /* !CONFIG_PPC_BOOK3S_64 */ /* * This is called when relaxing access to a PTE. It's also called in the page
arch/powerpc/mm/pgtable_64.c +0 -88
100 lines not on this page · raw message
arch/powerpc/mm/ppc_mmu_32.c +30 -0
@@ -174,6 +174,36 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,add_hash_page (mm->context.id, ea,pmd_val (*pmd)); } +void update_mmu_cache (struct vm_area_struct *vma,unsigned long address, +pte_t *ptep) +{ +/* +* We don't need to worry about _PAGE_PRESENT here because we are +* called with either mm->page_table_lock held or ptl lock held +*/ +unsigned long access =0 , trap; + +/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */ +if (!pte_young (*ptep) || address >=TASK_SIZE ) +return ; + +/* We try to figure out if we are coming from an instruction +* access fault and pass that down to __hash_page so we avoid +* double-faulting on execution of fresh text. We have to test +* for regs NULL since init will get here first thing at boot +* +* We also avoid filling the hash if not coming from a fault +*/ +if (current->thread.regs ==NULL ) +return ; + trap =TRAP (current->thread.regs); +if (trap ==0x400 ) + access |= _PAGE_EXEC; +else if (trap !=0x300 ) +return ; +hash_preload (vma->vm_mm, address, access, trap); +} +/* * Initialize the hash table and patch the instructions in hashtable.S. */
Signature · 1 line
2.5.0
PATCH 7/8 powerpc/mm: THP is only available on hash64 as of now
In reply to Aneesh Kumar K.V--- arch/powerpc/mm/pgtable-hash64.c | 373 +++++++++++++++++++++++++++++++++++++++ arch/powerpc/mm/pgtable_64.c | 373 --------------------------------------- 2 files changed, 373 insertions(+), 373 deletions(-)
arch/powerpc/mm/pgtable-hash64.c +373 -0
@@ -21,6 +21,9 @@#include "mmu_decl.h" +#define CREATE_TRACE_POINTS +#include <trace/events/thp.h> +#if PGTABLE_RANGE >USER_VSID_RANGE #warning Limited user VSID range means pagetable space is wasted#endif
@@ -245,3 +248,373 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,/* Perform the setting of the PTE */ __set_pte_at (mm, addr, ptep, pte,0 ); } + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + +/* +* This is called when relaxing access to a hugepage. It's also called in the page +* fault path when we don't hit any of the major fault cases, ie, a minor +* update of _PAGE_ACCESSED, _PAGE_DIRTY, etc... The generic code will have +* handled those two for us, we additionally deal with missing execute +* permission here on some processors +*/ +int pmdp_set_access_flags (struct vm_area_struct *vma,unsigned long address, +pmd_t *pmdp,pmd_t entry,int dirty) +{ +int changed; +#ifdef CONFIG_DEBUG_VM +WARN_ON (!pmd_trans_huge (*pmdp)); +assert_spin_locked (&vma->vm_mm->page_table_lock); +#endif + changed = !pmd_same (*(pmdp), entry); +if (changed) { +__ptep_set_access_flags (pmdp_ptep (pmdp),pmd_pte (entry)); +/* +* Since we are not supporting SW TLB systems, we don't +* have any thing similar to flush_tlb_page_nohash() +*/ + } +return changed; +} + +unsigned long pmd_hugepage_update (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp,unsigned long clr, +unsigned long set) +{ + +unsigned long old, tmp; + +#ifdef CONFIG_DEBUG_VM +WARN_ON (!pmd_trans_huge (*pmdp)); +assert_spin_locked (&mm->page_table_lock); +#endif + +#ifdef PTE_ATOMIC_UPDATES + __asm__ __volatile__( +"1: ldarx %0,0,%3\n\ +andi. %1,%0,%6\n\ +bne- 1b \n\ +andc %1,%0,%4 \n\ +or %1,%1,%7\n\ +stdcx. %1,0,%3 \n\ +bne- 1b" + :"=&r" (old),"=&r" (tmp),"=m" (*pmdp) + :"r" (pmdp),"r" (clr),"m" (*pmdp),"i" (_PAGE_BUSY),"r" (set) + :"cc" ); +#else + old =pmd_val (*pmdp); + *pmdp =__pmd ((old & ~clr) | set); +#endif +trace_hugepage_update (addr, old, clr, set); +if (old & _PAGE_HASHPTE) +hpte_do_hugepage_flush (mm, addr, pmdp, old); +return old; +} + +pmd_t pmdp_collapse_flush (struct vm_area_struct *vma,unsigned long address, +pmd_t *pmdp) +{ +pmd_t pmd; + +VM_BUG_ON (address & ~HPAGE_PMD_MASK ); +VM_BUG_ON (pmd_trans_huge (*pmdp)); + + pmd = *pmdp; +pmd_clear (pmdp); +/* +* Wait for all pending hash_page to finish. This is needed +* in case of subpage collapse. When we collapse normal pages +* to hugepage, we first clear the pmd, then invalidate all +* the PTE entries. The assumption here is that any low level +* page fault will see a none pmd and take the slow path that +* will wait on mmap_sem. But we could very well be in a +* hash_page with local ptep pointer value. Such a hash page +* can result in adding new HPTE entries for normal subpages. +* That means we could be modifying the page content as we +* copy them to a huge page. So wait for parallel hash_page +* to finish before invalidating HPTE entries. We can do this +* by sending an IPI to all the cpus and executing a dummy +* function there. +*/ +kick_all_cpus_sync (); +/* +* Now invalidate the hpte entries in the range +* covered by pmd. This make sure we take a +* fault and will find the pmd as none, which will +* result in a major fault which takes mmap_sem and +* hence wait for collapse to complete. Without this +* the __collapse_huge_page_copy can result in copying +* the old content. +*/ +flush_tlb_pmd_range (vma->vm_mm, &pmd, address); +return pmd; +} + +int pmdp_test_and_clear_young (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp) +{ +return __pmdp_test_and_clear_young (vma->vm_mm, address, pmdp); +} + +/* +* We currently remove entries from the hashtable regardless of whether +* the entry was young or dirty. The generic routines only flush if the +* entry was young or dirty which is not good enough. +* +* We should be more intelligent about this but for the moment we override +* these functions and force a tlb flush unconditionally +*/ +int pmdp_clear_flush_young (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp) +{ +return __pmdp_test_and_clear_young (vma->vm_mm, address, pmdp); +} + +/* +* We want to put the pgtable in pmd and use pgtable for tracking +* the base page size hptes +*/ +void pgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp, +pgtable_t pgtable) +{ +pgtable_t *pgtable_slot; +assert_spin_locked (&mm->page_table_lock); +/* +* we store the pgtable in the second half of PMD +*/ + pgtable_slot = (pgtable_t *)pmdp +PTRS_PER_PMD ; + *pgtable_slot = pgtable; +/* +* expose the deposited pgtable to other cpus. +* before we set the hugepage PTE at pmd level +* hash fault code looks at the deposted pgtable +* to store hash index values. +*/ +smp_wmb (); +} + +pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp) +{ +pgtable_t pgtable; +pgtable_t *pgtable_slot; + +assert_spin_locked (&mm->page_table_lock); + pgtable_slot = (pgtable_t *)pmdp +PTRS_PER_PMD ; + pgtable = *pgtable_slot; +/* +* Once we withdraw, mark the entry NULL. +*/ + *pgtable_slot =NULL ; +/* +* We store HPTE information in the deposited PTE fragment. +* zero out the content on withdraw. +*/ +memset (pgtable,0 ,PTE_FRAG_SIZE ); +return pgtable; +} + +void pmdp_huge_split_prepare (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp) +{ +VM_BUG_ON (address & ~HPAGE_PMD_MASK ); +VM_BUG_ON (REGION_ID (address) !=USER_REGION_ID ); + +/* +* We can't mark the pmd none here, because that will cause a race +* against exit_mmap. We need to continue mark pmd TRANS HUGE, while +* we spilt, but at the same time we wan't rest of the ppc64 code +* not to insert hash pte on this, because we will be modifying +* the deposited pgtable in the caller of this function. Hence +* clear the _PAGE_USER so that we move the fault handling to +* higher level function and that will serialize against ptl. +* We need to flush existing hash pte entries here even though, +* the translation is still valid, because we will withdraw +* pgtable_t after this. +*/ +pmd_hugepage_update (vma->vm_mm, address, pmdp, _PAGE_USER,0 ); +} + + +/* +* set a new huge pmd. We should not be called for updating +* an existing pmd entry. That should go via pmd_hugepage_update. +*/ +void set_pmd_at (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp,pmd_t pmd) +{ +#ifdef CONFIG_DEBUG_VM +WARN_ON ((pmd_val (*pmdp) & (_PAGE_PRESENT | _PAGE_USER)) == + (_PAGE_PRESENT | _PAGE_USER)); +assert_spin_locked (&mm->page_table_lock); +WARN_ON (!pmd_trans_huge (pmd)); +#endif +trace_hugepage_set_pmd (addr,pmd_val (pmd)); +return set_pte_at (mm, addr,pmdp_ptep (pmdp),pmd_pte (pmd)); +} + +/* +* We use this to invalidate a pmdp entry before switching from a +* hugepte to regular pmd entry. +*/ +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 ); + +/* +* This ensures that generic code that rely on IRQ disabling +* to prevent a parallel THP split work as expected. +*/ +kick_all_cpus_sync (); +} + +/* +* A linux hugepage PMD was changed and the corresponding hash table entries +* neesd to be flushed. +*/ +void hpte_do_hugepage_flush (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp,unsigned long old_pmd) +{ +int ssize; +unsigned int psize; +unsigned long vsid; +unsigned long flags =0 ; +const struct cpumask *tmp; + +/* get the base page size,vsid and segment size */ +#ifdef CONFIG_DEBUG_VM + psize =get_slice_psize (mm, addr); +BUG_ON (psize ==MMU_PAGE_16M ); +#endif +if (old_pmd & _PAGE_COMBO) + psize =MMU_PAGE_4K ; +else + psize =MMU_PAGE_64K ; + +if (!is_kernel_addr (addr)) { + ssize =user_segment_size (addr); + vsid =get_vsid (mm->context.id, addr, ssize); +WARN_ON (vsid ==0 ); + }else { + vsid =get_kernel_vsid (addr, mmu_kernel_ssize); + ssize = mmu_kernel_ssize; + } + + tmp =cpumask_of (smp_processor_id ()); +if (cpumask_equal (mm_cpumask (mm), tmp)) + flags |=HPTE_LOCAL_UPDATE ; + +return flush_hash_hugepage (vsid, addr, pmdp, psize, ssize, flags); +} + +static pmd_t pmd_set_protbits (pmd_t pmd,pgprot_t pgprot) +{ +return __pmd (pmd_val (pmd) |pgprot_val (pgprot)); +} + +pmd_t pfn_pmd (unsigned long pfn,pgprot_t pgprot) +{ +unsigned long pmdv; + + pmdv = (pfn <<PTE_RPN_SHIFT ) &PTE_RPN_MASK ; +return pmd_set_protbits (__pmd (pmdv), pgprot); +} + +pmd_t mk_pmd (struct page *page,pgprot_t pgprot) +{ +return pfn_pmd (page_to_pfn (page), pgprot); +} + +pmd_t pmd_modify (pmd_t pmd,pgprot_t newprot) +{ +unsigned long pmdv; + + pmdv =pmd_val (pmd); + pmdv &= _HPAGE_CHG_MASK; +return pmd_set_protbits (__pmd (pmdv), newprot); +} + +/* +* This is called at the end of handling a user page fault, when the +* fault has been handled by updating a HUGE PMD entry in the linux page tables. +* We use it to preload an HPTE into the hash table corresponding to +* the updated linux HUGE PMD entry. +*/ +void update_mmu_cache_pmd (struct vm_area_struct *vma,unsigned long addr, +pmd_t *pmd) +{ +return ; +} + +pmd_t pmdp_huge_get_and_clear (struct mm_struct *mm, +unsigned long addr,pmd_t *pmdp) +{ +pmd_t old_pmd; +pgtable_t pgtable; +unsigned long old; +pgtable_t *pgtable_slot; + + old =pmd_hugepage_update (mm, addr, pmdp, ~0UL ,0 ); + old_pmd =__pmd (old); +/* +* We have pmd == none and we are holding page_table_lock. +* So we can safely go and clear the pgtable hash +* index info. +*/ + pgtable_slot = (pgtable_t *)pmdp +PTRS_PER_PMD ; + pgtable = *pgtable_slot; +/* +* Let's zero out old valid and hash index details +* hash fault look at them. +*/ +memset (pgtable,0 ,PTE_FRAG_SIZE ); +/* +* Serialize against find_linux_pte_or_hugepte which does lock-less +* lookup in page tables with local interrupts disabled. For huge pages +* it casts pmd_t to pte_t. Since format of pte_t is different from +* pmd_t we want to prevent transit from pmd pointing to page table +* to pmd pointing to huge page (and back) while interrupts are disabled. +* We clear pmd to possibly replace it with page table pointer in +* different code paths. So make sure we wait for the parallel +* find_linux_pte_or_hugepage to finish. +*/ +kick_all_cpus_sync (); +return old_pmd; +} + +int has_transparent_hugepage (void ) +{ + +BUILD_BUG_ON_MSG ((PMD_SHIFT -PAGE_SHIFT ) >=MAX_ORDER , +"hugepages can't be allocated by the buddy allocator" ); + +BUILD_BUG_ON_MSG ((PMD_SHIFT -PAGE_SHIFT ) <2 , +"We need more than 2 pages to do deferred thp split" ); + +if (!mmu_has_feature (MMU_FTR_16M_PAGE )) +return 0 ; +/* +* We support THP only if PMD_SIZE is 16MB. +*/ +if (mmu_psize_defs[MMU_PAGE_16M ].shift !=PMD_SHIFT ) +return 0 ; +/* +* We need to make sure that we support 16MB hugepage in a segement +* with base page size 64K or 4K. We only enable THP with a PAGE_SIZE +* of 64K. +*/ +/* +* If we have 64K HPTE, we will be using that by default +*/ +if (mmu_psize_defs[MMU_PAGE_64K ].shift && + (mmu_psize_defs[MMU_PAGE_64K ].penc[MMU_PAGE_16M ] ==-1 )) +return 0 ; +/* +* Ok we only have 4K HPTE +*/ +if (mmu_psize_defs[MMU_PAGE_4K ].penc[MMU_PAGE_16M ] ==-1 ) +return 0 ; + +return 1 ; +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
arch/powerpc/mm/pgtable_64.c +0 -373
382 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 8/8 powerpc/mm: Use generic version of pmdp_clear_flush_young
In reply to Aneesh Kumar K.VThe radix variant is going to require a flush_tlb_range. We can't then have this as static inline because of the usage of HPAGE_PMD_SIZE. So we are forced to make it a function in which case we can use the generic version.
--- arch/powerpc/include/asm/book3s/64/pgtable.h | 3 --- arch/powerpc/mm/pgtable-hash64.c | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-)
arch/powerpc/include/asm/book3s/64/pgtable.h +0 -3
@@ -300,9 +300,6 @@ extern int pmdp_set_access_flags(struct vm_area_struct *vma,#define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNGextern int pmdp_test_and_clear_young (struct vm_area_struct *vma,unsigned long address,pmd_t *pmdp); -#define __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH -extern int pmdp_clear_flush_young (struct vm_area_struct *vma, -unsigned long address,pmd_t *pmdp);#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR extern pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
arch/powerpc/mm/pgtable-hash64.c +2 -8
@@ -350,12 +350,6 @@ pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address,return pmd; } -int pmdp_test_and_clear_young (struct vm_area_struct *vma, -unsigned long address,pmd_t *pmdp) -{ -return __pmdp_test_and_clear_young (vma->vm_mm, address, pmdp); -} -/* * We currently remove entries from the hashtable regardless of whether * the entry was young or dirty. The generic routines only flush if the
@@ -364,8 +358,8 @@ int pmdp_test_and_clear_young(struct vm_area_struct *vma,* We should be more intelligent about this but for the moment we override * these functions and force a tlb flush unconditionally */ -int pmdp_clear_flush_young (struct vm_area_struct *vma, -unsigned long address,pmd_t *pmdp) +int pmdp_test_and_clear_young (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp) {return __pmdp_test_and_clear_young (vma->vm_mm, address, pmdp); }
Signature · 1 line
2.5.0