powerpc: mm: Move ppc64 page table range definitions to separate header
Subsystems (4)
PATCH 1/2 powerpc: mm: Move ppc64 page table range definitions to separate header
From: "Aneesh Kumar K.V" <[email protected]>
This avoid mmu-hash64.h including pagetable-ppc64.h. That inclusion cause issues like
CC arch/powerpc/kernel/asm-offsets.s
In file included from /home/aneesh/linus/arch/powerpc/include/asm/mmu-hash64.h:23:0,
from /home/aneesh/linus/arch/powerpc/include/asm/mmu.h:196,
from /home/aneesh/linus/arch/powerpc/include/asm/lppaca.h:36,
from /home/aneesh/linus/arch/powerpc/include/asm/paca.h:21,
from /home/aneesh/linus/arch/powerpc/include/asm/hw_irq.h:41,
from /home/aneesh/linus/arch/powerpc/include/asm/irqflags.h:11,
from include/linux/irqflags.h:15,
from include/linux/spinlock.h:53,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/uapi/linux/timex.h:56,
from include/linux/timex.h:56,
from include/linux/sched.h:17,
from arch/powerpc/kernel/asm-offsets.c:17:/home/aneesh/linus/arch/powerpc/include/asm/pgtable-ppc64.h:563:42: error: unknown type name ‘spinlock_t’
static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
---
NOTE: We can either do this or stuck a typdef struct spinlock spinlock_t; in pgtable-ppc64.h
arch/powerpc/include/asm/mmu-hash64.h | 2 +- arch/powerpc/include/asm/pgtable-ppc64-range.h | 101 +++++++++++++++++++++++++ arch/powerpc/include/asm/pgtable-ppc64.h | 101 +------------------------ 3 files changed, 103 insertions(+), 101 deletions(-) create mode 100644 arch/powerpc/include/asm/pgtable-ppc64-range.h
arch/powerpc/include/asm/mmu-hash64.h +1 -1
@@ -20,7 +20,7 @@* need for various slices related matters. Note that this isn't the * complete pgtable.h but only a portion of it. */ -#include <asm/pgtable-ppc64.h> +#include <asm/pgtable-ppc64-range.h> #include <asm/bug.h> /*
arch/powerpc/include/asm/pgtable-ppc64-range.h new file +101 -0
101 lines not on this page · raw message
arch/powerpc/include/asm/pgtable-ppc64.h +1 -100
114 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 2/2 powerpc: thp: Fix crash on mremap
From: "Aneesh Kumar K.V" <[email protected]>
This patch fix the below crash
NIP [c00000000004cee4] .__hash_page_thp+0x2a4/0x440 LR [c0000000000439ac] .hash_page+0x18c/0x5e0
...
Call Trace: [c000000736103c40] [00001ffffb000000] 0x1ffffb000000(unreliable) [437908.479693] [c000000736103d50] [c0000000000439ac] .hash_page+0x18c/0x5e0 [437908.479699] [c000000736103e30] [c00000000000924c] .do_hash_page+0x4c/0x58
On ppc64 we use the pgtable for storing the hpte slot information and store address to the pgtable at a constant offset (PTRS_PER_PMD) from pmd. On mremap, when we switch the pmd, we need to withdraw and deposit the pgtable again, so that we find the pgtable at PTRS_PER_PMD offset from new pmd.
We also want to move the withdraw and deposit before the set_pmd so that, when page fault find the pmd as trans huge we can be sure that pgtable can be located at the offset.
--- arch/powerpc/include/asm/pgtable-ppc64.h | 14 ++++++++++++++ include/asm-generic/pgtable.h | 12 ++++++++++++ mm/huge_memory.c | 14 +++++--------- 3 files changed, 31 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/pgtable-ppc64.h +14 -0
@@ -12,6 +12,7 @@#ifndef __ASSEMBLY__ +#include <linux/spinlock.h> /* * This is the default implementation of various PTE accessors, it's * used in all cases except Book3S with 64K pages where we have a
@@ -459,5 +460,18 @@ extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);#define __HAVE_ARCH_PMDP_INVALIDATEextern void pmdp_invalidate (struct vm_area_struct *vma,unsigned long address,pmd_t *pmdp); + +#define pmd_move_must_withdraw pmd_move_must_withdraw +static inline int pmd_move_must_withdraw (spinlock_t *new_pmd_ptl, +spinlock_t *old_pmd_ptl) +{ +/* +* Archs like ppc64 use pgtable to store per pmd +* specific information. So when we switch the pmd, +* we should also withdraw and deposit the pgtable +*/ +return true; +} +#endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_PPC64_H_ */
include/asm-generic/pgtable.h +12 -0
@@ -558,6 +558,18 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp) }#endif +#ifndef pmd_move_must_withdraw +static inline int pmd_move_must_withdraw (spinlock_t *new_pmd_ptl, +spinlock_t *old_pmd_ptl) +{ +/* +* With split pmd lock we also need to move preallocated +* PTE page table if new_pmd is on different PMD page table. +*/ +return new_pmd_ptl != old_pmd_ptl; +} +#endif +/* * This function is meant to be used by sites walking pagetables with * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
mm/huge_memory.c +5 -9
@@ -1502,19 +1502,15 @@ int move_huge_pmd(struct vm_area_struct *vma, struct vm_area_struct *new_vma,spin_lock_nested (new_ptl,SINGLE_DEPTH_NESTING ); pmd =pmdp_get_and_clear (mm, old_addr, old_pmd);VM_BUG_ON (!pmd_none (*new_pmd)); -set_pmd_at (mm, new_addr, new_pmd,pmd_mksoft_dirty (pmd)); -if (new_ptl != old_ptl) { -pgtable_t pgtable; -/* -* Move preallocated PTE page table if new_pmd is on -* different PMD page table. -*/ +if (pmd_move_must_withdraw (new_ptl, old_ptl)) { +pgtable_t pgtable; pgtable =pgtable_trans_huge_withdraw (mm, old_pmd);pgtable_trans_huge_deposit (mm, new_pmd, pgtable); - -spin_unlock (new_ptl); } +set_pmd_at (mm, new_addr, new_pmd,pmd_mksoft_dirty (pmd)); +if (new_ptl != old_ptl) +spin_unlock (new_ptl);spin_unlock (old_ptl); } out:
Signature · 1 line
1.8.3.2
Quoted 4 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
This avoid
mmu-hash64.hincludingpagetable-ppc64.h. That inclusion cause issues like
I don't like this. We have that stuff split into too many includes already it's a mess.
Why do we need to include it from mmu*.h ?
Cheers,
Ben.
Quoted 259 lines
CC
arch/powerpc/kernel/asm-offsets.s
In file included from/home/aneesh/linus/arch/powerpc/include/asm/mmu-hash64.h:23:0,
from/home/aneesh/linus/arch/powerpc/include/asm/mmu.h:196,
from/home/aneesh/linus/arch/powerpc/include/asm/lppaca.h:36,
from/home/aneesh/linus/arch/powerpc/include/asm/paca.h:21,
from/home/aneesh/linus/arch/powerpc/include/asm/hw_irq.h:41,
from/home/aneesh/linus/arch/powerpc/include/asm/irqflags.h:11,
frominclude/linux/irqflags.h:15,
frominclude/linux/spinlock.h:53,
frominclude/linux/seqlock.h:35,
frominclude/linux/time.h:5,
frominclude/uapi/linux/timex.h:56,
frominclude/linux/timex.h:56,
frominclude/linux/sched.h:17,
fromarch/powerpc/kernel/asm-offsets.c:17:/home/aneesh/linus/arch/powerpc/include/asm/pgtable-ppc64.h:563:42: error: unknown type name a??spinlock_ta??
static inline int pmd_move_must_withdraw(spinlock_t*new_pmd_ptl,Signed-off-by Aneesh Kumar K.V <[email protected]>---
NOTE: We can either do this or stuck a typdef struct spinlock
spinlock_t; inpgtable-ppc64.harch/powerpc/include/asm/mmu-hash64.h | 2 +- arch/powerpc/include/asm/pgtable-ppc64-range.h | 101 +++++++++++++++++++++++++ arch/powerpc/include/asm/pgtable-ppc64.h | 101 +------------------------ 3 files changed, 103 insertions(+), 101 deletions(-) create mode 100644 arch/powerpc/include/asm/pgtable-ppc64-range.harch/powerpc/include/asm/mmu-hash64.h +1
-1@@ -20,7 +20,7 @@* need for various slices related matters. Note that this isn't the * complete pgtable.h but only a portion of it. */ -#include <asm/pgtable-ppc64.h> +#include <asm/pgtable-ppc64-range.h> #include <asm/bug.h> /* arch/powerpc/include/asm/pgtable-ppc64-range.h new file +101
-0@@ -0,0 +1,101 @@ +#ifndef _ASM_POWERPC_PGTABLE_PPC64_RANGE_H_ +#define _ASM_POWERPC_PGTABLE_PPC64_RANGE_H_ +/* +* This file contains the functions and defines necessary to modify and use +* the ppc64 hashed page table. +*/ + +#ifdef CONFIG_PPC_64K_PAGES +#include <asm/pgtable-ppc64-64k.h> +#else +#include <asm/pgtable-ppc64-4k.h> +#endif +#include <asm/barrier.h> + +#define FIRST_USER_ADDRESS 0 + +/* +* Size of EA range mapped by our pagetables. +*/ +#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ + PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) +#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define PMD_CACHE_INDEX (PMD_INDEX_SIZE + 1) +#else +#define PMD_CACHE_INDEX PMD_INDEX_SIZE +#endif +/* +* Define the address range of the kernel non-linear virtual area +*/ + +#ifdef CONFIG_PPC_BOOK3E +#define KERN_VIRT_START ASM_CONST(0x8000000000000000) +#else +#define KERN_VIRT_START ASM_CONST(0xD000000000000000) +#endif +#define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000) + +/* +* The vmalloc space starts at the beginning of that region, and +* occupies half of it on hash CPUs and a quarter of it on Book3E +* (we keep a quarter for the virtual memmap) +*/ +#define VMALLOC_START KERN_VIRT_START +#ifdef CONFIG_PPC_BOOK3E +#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 2) +#else +#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) +#endif +#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE) + +/* +* The second half of the kernel virtual space is used for IO mappings, +* it's itself carved into the PIO region (ISA and PHB IO space) and +* the ioremap space +* +* ISA_IO_BASE = KERN_IO_START, 64K reserved area +* PHB_IO_BASE = ISA_IO_BASE + 64K to ISA_IO_BASE + 2G, PHB IO spaces +* IOREMAP_BASE = ISA_IO_BASE + 2G to VMALLOC_START + PGTABLE_RANGE +*/ +#define KERN_IO_START (KERN_VIRT_START + (KERN_VIRT_SIZE >> 1)) +#define FULL_IO_SIZE 0x80000000ul +#define ISA_IO_BASE (KERN_IO_START) +#define ISA_IO_END (KERN_IO_START + 0x10000ul) +#define PHB_IO_BASE (ISA_IO_END) +#define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE) +#define IOREMAP_BASE (PHB_IO_END) +#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE) + + +/* +* Region IDs +*/ +#define REGION_SHIFT 60UL +#define REGION_MASK (0xfUL << REGION_SHIFT) +#define REGION_ID (ea) (((unsigned long)(ea)) >> REGION_SHIFT) + +#define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START)) +#define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET)) +#define VMEMMAP_REGION_ID (0xfUL)/* Server only */ +#define USER_REGION_ID (0UL) + +/* +* Defines the address of the vmemap area, in its own region on +* hash table CPUs and after the vmalloc space on Book3E +*/ +#ifdef CONFIG_PPC_BOOK3E +#define VMEMMAP_BASE VMALLOC_END +#define VMEMMAP_END KERN_IO_START +#else +#define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT) +#endif +#define vmemmap ((struct page *)VMEMMAP_BASE) + +#ifdef CONFIG_PPC_MM_SLICES +#define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#endif /* CONFIG_PPC_MM_SLICES */ + +#endif arch/powerpc/include/asm/pgtable-ppc64.h +1
-95@@ -1,102 +1,8 @@#ifndef _ASM_POWERPC_PGTABLE_PPC64_H_#define _ASM_POWERPC_PGTABLE_PPC64_H_ -/* -* This file contains the functions and defines necessary to modify and use -* the ppc64 hashed page table. -*/ - -#ifdef CONFIG_PPC_64K_PAGES -#include <asm/pgtable-ppc64-64k.h> -#else -#include <asm/pgtable-ppc64-4k.h> -#endif -#include <asm/barrier.h> - -#define FIRST_USER_ADDRESS 0 - -/* -* Size of EA range mapped by our pagetables. -*/ -#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ - PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) -#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) - -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define PMD_CACHE_INDEX (PMD_INDEX_SIZE + 1) -#else -#define PMD_CACHE_INDEX PMD_INDEX_SIZE -#endif -/* -* Define the address range of the kernel non-linear virtual area -*/ - -#ifdef CONFIG_PPC_BOOK3E -#define KERN_VIRT_START ASM_CONST(0x8000000000000000) -#else -#define KERN_VIRT_START ASM_CONST(0xD000000000000000) -#endif -#define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000) - -/* -* The vmalloc space starts at the beginning of that region, and -* occupies half of it on hash CPUs and a quarter of it on Book3E -* (we keep a quarter for the virtual memmap) -*/ -#define VMALLOC_START KERN_VIRT_START -#ifdef CONFIG_PPC_BOOK3E -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 2) -#else -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) -#endif -#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE) - -/* -* The second half of the kernel virtual space is used for IO mappings, -* it's itself carved into the PIO region (ISA and PHB IO space) and -* the ioremap space -* -* ISA_IO_BASE = KERN_IO_START, 64K reserved area -* PHB_IO_BASE = ISA_IO_BASE + 64K to ISA_IO_BASE + 2G, PHB IO spaces -* IOREMAP_BASE = ISA_IO_BASE + 2G to VMALLOC_START + PGTABLE_RANGE -*/ -#define KERN_IO_START (KERN_VIRT_START + (KERN_VIRT_SIZE >> 1)) -#define FULL_IO_SIZE 0x80000000ul -#define ISA_IO_BASE (KERN_IO_START) -#define ISA_IO_END (KERN_IO_START + 0x10000ul) -#define PHB_IO_BASE (ISA_IO_END) -#define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE) -#define IOREMAP_BASE (PHB_IO_END) -#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE) - - -/* -* Region IDs -*/ -#define REGION_SHIFT 60UL -#define REGION_MASK (0xfUL << REGION_SHIFT) -#define REGION_ID (ea) (((unsigned long)(ea)) >> REGION_SHIFT) - -#define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START)) -#define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET)) -#define VMEMMAP_REGION_ID (0xfUL)/* Server only */ -#define USER_REGION_ID (0UL) - -/* -* Defines the address of the vmemap area, in its own region on -* hash table CPUs and after the vmalloc space on Book3E -*/ -#ifdef CONFIG_PPC_BOOK3E -#define VMEMMAP_BASE VMALLOC_END -#define VMEMMAP_END KERN_IO_START -#else -#define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT) -#endif -#define vmemmap ((struct page *)VMEMMAP_BASE) +#include <asm/pgtable-ppc64-range.h> -/* -* Include the PTE bits definitions -*/ #ifdef CONFIG_PPC_BOOK3S #include <asm/pte-hash64.h> #else @@ -104,11 +10,6 @@#endif
arch/powerpc/include/asm/pgtable-ppc64.h line 15
Quoted 10 lines
arch/powerpc/include/asm/pgtable-ppc64.h +0
-5#include <asm/pte-common.h> -#ifdef CONFIG_PPC_MM_SLICES -#define HAVE_ARCH_UNMAPPED_AREA -#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN -#endif /* CONFIG_PPC_MM_SLICES */ -#ifndef __ASSEMBLY__/*
--
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 8 lines · Benjamin Herrenschmidt
Quoted 4 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
This avoid
mmu-hash64.hincludingpagetable-ppc64.h. That inclusion cause issues likeI don't like this. We have that stuff split into too many includes already it's a mess.
I understand. Let me know, if you have any suggestion on cleaning that up. I can do that.
Quoted 2 lines
Why do we need to include it from mmu*.h ?
in mmu-hash64.h added by me via 78f1dbde9fd020419313c2a0c3b602ea2427118f
/*
* This is necessary to get the definition of PGTABLE_RANGE which we
* need for various slices related matters. Note that this isn't the
* complete pgtable.h but only a portion of it.
*/
#include <asm/pgtable-ppc64.h>
-aneesh
Quoted 17 lines · Aneesh Kumar K.V
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 4 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
This avoid
mmu-hash64.hincludingpagetable-ppc64.h. That inclusion cause issues likeI don't like this. We have that stuff split into too many includes already it's a mess.
I understand. Let me know, if you have any suggestion on cleaning that up. I can do that.
Quoted 2 lines
Why do we need to include it from mmu*.h ?
Quoted 8 lines
in
mmu-hash64.hadded by me via78f1dbde9fd020419313c2a0c3b602ea2427118f/*
* This is necessary to get the definition ofPGTABLE_RANGEwhich we
* need for various slices related matters. Note that this isn't the
* completepgtable.hbut only a portion of it.
*/
#include <asm/pgtable-ppc64.h>
For now, instead, just do fwd def of the spinlock, I don't like the inclusion of spinlock.h there anyway.
Cheers,
Ben,
--
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>