powerpc/mm: enable memory hotplug on radix
v3 cover powerpc/mm: enable memory hotplug on radix
Memory hotplug is leading to hash page table calls, even on radix:
...
arch_add_memory
create_section_mapping
htab_bolt_mapping
BUG_ON(!ppc_md.hpte_insert);To fix, refactor {create,remove}_section_mapping() into hash__ and radix__ variants. Implement the radix versions by borrowing from existing vmemmap and x86 code.
This passes basic verification of plugging and removing memory, but this stuff is tricky and I'd appreciate extra scrutiny of the series for correctness--in particular, the adaptation of remove_pagetable() from x86.
/* changelog */
v3:
* Port remove_pagetable() et al. from x86 for unmapping.
* [RFC] -> [PATCH]
v2:
* https://lkml.kernel.org/r/[email protected]
* Do not simply fall through to vmemmap_{create,remove}_mapping(). As Aneesh and Michael pointed out, they are tied to CONFIG_SPARSEMEM_VMEMMAP and only did what I needed by luck anyway.
v1:
* https://lkml.kernel.org/r/[email protected]
Reza Arbab (5):
powerpc/mm: set the radix linear page mapping size powerpc/mm: refactor {create,remove}_section_mapping() powerpc/mm: add radix__create_section_mapping() powerpc/mm: add radix__remove_section_mapping() powerpc/mm: unstub radix__vmemmap_remove_mapping()
arch/powerpc/include/asm/book3s/64/hash.h | 5 + arch/powerpc/include/asm/book3s/64/radix.h | 5 + arch/powerpc/mm/hash_utils_64.c | 4 +- arch/powerpc/mm/pgtable-book3s64.c | 18 +++ arch/powerpc/mm/pgtable-radix.c | 207 ++++++++++++++++++++++++++++- 5 files changed, 236 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 3/5 powerpc/mm: add radix__create_section_mapping()
Add the linear page mapping function for radix, used by memory hotplug. This is similar to vmemmap_populate().
--- arch/powerpc/include/asm/book3s/64/radix.h | 4 ++++ arch/powerpc/mm/pgtable-book3s64.c | 2 +- arch/powerpc/mm/pgtable-radix.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/book3s/64/radix.h +4 -0
@@ -291,5 +291,9 @@ static inline unsigned long radix__get_tree_size(void) }return rts_field; } + +#ifdef CONFIG_MEMORY_HOTPLUG +int radix__create_section_mapping (unsigned long start,unsigned long end); +#endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* __ASSEMBLY__ */ #endif
arch/powerpc/mm/pgtable-book3s64.c +1 -1
@@ -131,7 +131,7 @@ void mmu_cleanup_all(void)int create_section_mapping (unsigned long start,unsigned long end) {if (radix_enabled ()) -return -ENODEV ; +return radix__create_section_mapping (start, end);return hash__create_section_mapping (start, end); }
arch/powerpc/mm/pgtable-radix.c +19 -0
@@ -465,6 +465,25 @@ void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base,memblock_set_current_limit (first_memblock_base + first_memblock_size); } +#ifdef CONFIG_MEMORY_HOTPLUG +int radix__create_section_mapping (unsigned long start,unsigned long end) +{ +unsigned long page_size =1 << mmu_psize_defs[mmu_linear_psize].shift; + +/* Align to the page size of the linear mapping. */ + start =_ALIGN_DOWN (start, page_size); + +for (; start < end; start += page_size) { +int rc =radix__map_kernel_page (start,__pa (start), +PAGE_KERNEL , page_size); +if (rc) +return rc; + } + +return 0 ; +} +#endif /* CONFIG_MEMORY_HOTPLUG */ +#ifdef CONFIG_SPARSEMEM_VMEMMAP int __meminit radix__vmemmap_create_mapping(unsigned long start, unsigned long page_size,
Signature · 1 line
1.8.3.1
PATCH v3 5/5 powerpc/mm: unstub radix__vmemmap_remove_mapping()
In reply to Reza ArbabUse remove_pagetable() and friends for radix vmemmap removal.
We do not require the special-case handling of vmemmap done in the x86 versions of these functions. This is because vmemmap_free() has already freed the mapped pages, and calls us with an aligned address range.
So, add a few failsafe WARNs, but otherwise the code to remove linear mappings is already sufficient for vmemmap.
--- arch/powerpc/mm/pgtable-radix.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
arch/powerpc/mm/pgtable-radix.c +22 -1
@@ -532,6 +532,15 @@ static void remove_pte_table(pte_t *pte_start, unsigned long addr,if (!pte_present (*pte))continue ; +if (!PAGE_ALIGNED (addr) || !PAGE_ALIGNED (next)) { +/* +* The vmemmap_free() and remove_section_mapping() +* codepaths call us with aligned addresses. +*/ +WARN_ONCE (1 ,"%s: unaligned range\n" , __func__); +continue ; + } +spin_lock (&init_mm.page_table_lock);pte_clear (&init_mm, addr, pte);spin_unlock (&init_mm.page_table_lock);
@@ -555,6 +564,12 @@ static void remove_pmd_table(pmd_t *pmd_start, unsigned long addr,continue ;if (map_page_size ==PMD_SIZE ) { +if (!IS_ALIGNED (addr,PMD_SIZE ) || + !IS_ALIGNED (next,PMD_SIZE )) { +WARN_ONCE (1 ,"%s: unaligned range\n" , __func__); +continue ; + } +spin_lock (&init_mm.page_table_lock);pte_clear (&init_mm, addr, (pte_t *)pmd);spin_unlock (&init_mm.page_table_lock);
@@ -583,6 +598,12 @@ static void remove_pud_table(pud_t *pud_start, unsigned long addr,continue ;if (map_page_size ==PUD_SIZE ) { +if (!IS_ALIGNED (addr,PUD_SIZE ) || + !IS_ALIGNED (next,PUD_SIZE )) { +WARN_ONCE (1 ,"%s: unaligned range\n" , __func__); +continue ; + } +spin_lock (&init_mm.page_table_lock);pte_clear (&init_mm, addr, (pte_t *)pud);spin_unlock (&init_mm.page_table_lock);
@@ -662,7 +683,7 @@ int __meminit radix__vmemmap_create_mapping(unsigned long start,#ifdef CONFIG_MEMORY_HOTPLUG void radix__vmemmap_remove_mapping (unsigned long start,unsigned long page_size) { -/* FIXME!! intel does more. We should free page tables mapping vmemmap ? */ +remove_pagetable (start, start + page_size, page_size); }#endif #endif
Signature · 1 line
1.8.3.1
PATCH v3 1/5 powerpc/mm: set the radix linear page mapping size
In reply to Reza ArbabThis was defaulting to 4K, regardless of PAGE_SIZE.
--- arch/powerpc/mm/pgtable-radix.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/mm/pgtable-radix.c +2 -0
@@ -351,8 +351,10 @@ void __init radix__early_init_mmu(void)#ifdef CONFIG_PPC_64K_PAGES /* PAGE_SIZE mappings */ mmu_virtual_psize =MMU_PAGE_64K ; + mmu_linear_psize =MMU_PAGE_64K ;#else mmu_virtual_psize =MMU_PAGE_4K ; + mmu_linear_psize =MMU_PAGE_4K ;#endif #ifdef CONFIG_SPARSEMEM_VMEMMAP
Signature · 1 line
1.8.3.1
PATCH v3 2/5 powerpc/mm: refactor {create, remove}_section_mapping()
In reply to Reza ArbabChange {create,remove}_section_mapping() to be wrappers around functions prefixed with "hash__".
This is preparation for the addition of their "radix__" variants. No functional change.
--- arch/powerpc/include/asm/book3s/64/hash.h | 5 +++++ arch/powerpc/mm/hash_utils_64.c | 4 ++-- arch/powerpc/mm/pgtable-book3s64.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/hash.h +5 -0
@@ -201,6 +201,11 @@ extern int __meminit hash__vmemmap_create_mapping(unsigned long start, unsigned long phys);extern void hash__vmemmap_remove_mapping (unsigned long start,unsigned long page_size); + +#ifdef CONFIG_MEMORY_HOTPLUG +int hash__create_section_mapping (unsigned long start,unsigned long end); +int hash__remove_section_mapping (unsigned long start,unsigned long end); +#endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */
arch/powerpc/mm/hash_utils_64.c +2 -2
@@ -743,7 +743,7 @@ static unsigned long __init htab_get_table_size(void) }#ifdef CONFIG_MEMORY_HOTPLUG -int create_section_mapping (unsigned long start,unsigned long end) +int hash__create_section_mapping (unsigned long start,unsigned long end) { int rc = htab_bolt_mapping(start, end, __pa(start), pgprot_val(PAGE_KERNEL), mmu_linear_psize,
@@ -757,7 +757,7 @@ int create_section_mapping(unsigned long start, unsigned long end)return rc; } -int remove_section_mapping (unsigned long start,unsigned long end) +int hash__remove_section_mapping (unsigned long start,unsigned long end) {int rc =htab_remove_mapping (start, end, mmu_linear_psize, mmu_kernel_ssize);
arch/powerpc/mm/pgtable-book3s64.c +18 -0
@@ -126,3 +126,21 @@ void mmu_cleanup_all(void)else if (mmu_hash_ops.hpte_clear_all) mmu_hash_ops.hpte_clear_all (); } + +#ifdef CONFIG_MEMORY_HOTPLUG +int create_section_mapping (unsigned long start,unsigned long end) +{ +if (radix_enabled ()) +return -ENODEV ; + +return hash__create_section_mapping (start, end); +} + +int remove_section_mapping (unsigned long start,unsigned long end) +{ +if (radix_enabled ()) +return -ENODEV ; + +return hash__remove_section_mapping (start, end); +} +#endif /* CONFIG_MEMORY_HOTPLUG */
Signature · 1 line
1.8.3.1
PATCH v3 4/5 powerpc/mm: add radix__remove_section_mapping()
In reply to Reza ArbabTear down and free the four-level page tables of the linear mapping during memory hotremove.
We borrow the basic structure of remove_pagetable() and friends from the identically-named x86 functions.
--- arch/powerpc/include/asm/book3s/64/radix.h | 1 + arch/powerpc/mm/pgtable-book3s64.c | 2 +- arch/powerpc/mm/pgtable-radix.c | 163 +++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/book3s/64/radix.h +1 -0
@@ -294,6 +294,7 @@ static inline unsigned long radix__get_tree_size(void)#ifdef CONFIG_MEMORY_HOTPLUG int radix__create_section_mapping (unsigned long start,unsigned long end); +int radix__remove_section_mapping (unsigned long start,unsigned long end);#endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* __ASSEMBLY__ */ #endif
arch/powerpc/mm/pgtable-book3s64.c +1 -1
@@ -139,7 +139,7 @@ int create_section_mapping(unsigned long start, unsigned long end)int remove_section_mapping (unsigned long start,unsigned long end) {if (radix_enabled ()) -return -ENODEV ; +return radix__remove_section_mapping (start, end);return hash__remove_section_mapping (start, end); }
arch/powerpc/mm/pgtable-radix.c +163 -0
175 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 8 lines · Reza Arbab
Memory hotplug is leading to hash page table calls, even on radix:
...
arch_add_memory create_section_mapping htab_bolt_mapping BUG_ON(!ppc_md.hpte_insert);
Quoted 7 lines
To fix, refactor {create,remove}_section_mapping() into
hash__andradix__variants. Implement the radix versions by borrowing from existing vmemmap and x86 code.This passes basic verification of plugging and removing memory, but this stuff is tricky and I'd appreciate extra scrutiny of the series for correctness--in particular, the adaptation of
remove_pagetable()from x86.
On quick glance everything seemed alright to me. I'll review each patch and Ack/provide comments. Do we care about alt maps yet?
Balbir Singh.
Re: [PATCH v3 1/5] powerpc/mm: set the radix linear page mapping size
In reply to Reza ArbabQuoted 12 lines · Reza Arbab
This was defaulting to 4K, regardless of
PAGE_SIZE.Signed-off-by Reza Arbab <[email protected]>--- arch/powerpc/mm/pgtable-radix.c | 2 ++ 1 file changed, 2 insertions(+)arch/powerpc/mm/pgtable-radix.c +0
-0
arch/powerpc/mm/pgtable-radix.c void __init radix__early_init_mmu(void) · line 354
Quoted 4 lines
arch/powerpc/mm/pgtable-radix.c +1
-0@@ -351,8 +351,10 @@ void __init radix__early_init_mmu(void)#ifdef CONFIG_PPC_64K_PAGES /* PAGE_SIZE mappings */ mmu_virtual_psize =MMU_PAGE_64K ; + mmu_linear_psize =MMU_PAGE_64K ;
That is not clearly correct, we map the linear address with either 64K, 2M or 1G depending on the memory available. Take a look at static void __init radix_init_pgtable(void)
Quoted 8 lines
arch/powerpc/mm/pgtable-radix.c +1
-0#else mmu_virtual_psize =MMU_PAGE_4K ; + mmu_linear_psize =MMU_PAGE_4K ;#endif #ifdef CONFIG_SPARSEMEM_VMEMMAP Signature · 1 line
1.8.3.1
Re: [PATCH v3 2/5] powerpc/mm: refactor {create, remove}_section_mapping()
In reply to Reza ArbabQuoted 6 lines · Reza Arbab
Change {create,remove}_section_mapping() to be wrappers around functions prefixed with "
hash__".This is preparation for the addition of their "
radix__" variants. No functional change.
I think this can go upstream now ? To fixup broken hotplug with radix ?
Quoted 73 lines
Signed-off-by Reza Arbab <[email protected]>--- arch/powerpc/include/asm/book3s/64/hash.h | 5 +++++ arch/powerpc/mm/hash_utils_64.c | 4 ++-- arch/powerpc/mm/pgtable-book3s64.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-)arch/powerpc/include/asm/book3s/64/hash.h +5
-0@@ -201,6 +201,11 @@ extern int __meminit hash__vmemmap_create_mapping(unsigned long start, unsigned long phys);extern void hash__vmemmap_remove_mapping (unsigned long start,unsigned long page_size); + +#ifdef CONFIG_MEMORY_HOTPLUG +int hash__create_section_mapping (unsigned long start,unsigned long end); +int hash__remove_section_mapping (unsigned long start,unsigned long end); +#endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */ arch/powerpc/mm/hash_utils_64.c +2
-2@@ -743,7 +743,7 @@ static unsigned long __init htab_get_table_size(void) }#ifdef CONFIG_MEMORY_HOTPLUG -int create_section_mapping (unsigned long start,unsigned long end) +int hash__create_section_mapping (unsigned long start,unsigned long end) { int rc = htab_bolt_mapping(start, end, __pa(start), pgprot_val(PAGE_KERNEL), mmu_linear_psize,@@ -757,7 +757,7 @@ int create_section_mapping(unsigned long start, unsigned long end)return rc; } -int remove_section_mapping (unsigned long start,unsigned long end) +int hash__remove_section_mapping (unsigned long start,unsigned long end) {int rc =htab_remove_mapping (start, end, mmu_linear_psize, mmu_kernel_ssize);arch/powerpc/mm/pgtable-book3s64.c +18
-0@@ -126,3 +126,21 @@ void mmu_cleanup_all(void)else if (mmu_hash_ops.hpte_clear_all) mmu_hash_ops.hpte_clear_all (); } + +#ifdef CONFIG_MEMORY_HOTPLUG +int create_section_mapping (unsigned long start,unsigned long end) +{ +if (radix_enabled ()) +return -ENODEV ; + +return hash__create_section_mapping (start, end); +} + +int remove_section_mapping (unsigned long start,unsigned long end) +{ +if (radix_enabled ()) +return -ENODEV ; + +return hash__remove_section_mapping (start, end); +} +#endif /* CONFIG_MEMORY_HOTPLUG */ Signature · 1 line
1.8.3.1
Re: [PATCH v3 3/5] powerpc/mm: add radix__create_section_mapping()
In reply to Reza ArbabQuoted 3 lines · Reza Arbab
Add the linear page mapping function for radix, used by memory hotplug. This is similar to
vmemmap_populate().
Ok with this patch your first patch becomes useful. Can you merge that with this and rename mmu_linear_psize to mmu_hotplug_psize or even use mmu_virtual_psize. The linear naming is confusing.
Quoted 66 lines
Signed-off-by Reza Arbab <[email protected]>--- arch/powerpc/include/asm/book3s/64/radix.h | 4 ++++ arch/powerpc/mm/pgtable-book3s64.c | 2 +- arch/powerpc/mm/pgtable-radix.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-)arch/powerpc/include/asm/book3s/64/radix.h +4
-0@@ -291,5 +291,9 @@ static inline unsigned long radix__get_tree_size(void) }return rts_field; } + +#ifdef CONFIG_MEMORY_HOTPLUG +int radix__create_section_mapping (unsigned long start,unsigned long end); +#endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* __ASSEMBLY__ */ #endif arch/powerpc/mm/pgtable-book3s64.c +1
-1@@ -131,7 +131,7 @@ void mmu_cleanup_all(void)int create_section_mapping (unsigned long start,unsigned long end) {if (radix_enabled ()) -return -ENODEV ; +return radix__create_section_mapping (start, end);return hash__create_section_mapping (start, end); }arch/powerpc/mm/pgtable-radix.c +19
-0@@ -465,6 +465,25 @@ void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base,memblock_set_current_limit (first_memblock_base + first_memblock_size); } +#ifdef CONFIG_MEMORY_HOTPLUG +int radix__create_section_mapping (unsigned long start,unsigned long end) +{ +unsigned long page_size =1 << mmu_psize_defs[mmu_linear_psize].shift; + +/* Align to the page size of the linear mapping. */ + start =_ALIGN_DOWN (start, page_size); + +for (; start < end; start += page_size) { +int rc =radix__map_kernel_page (start,__pa (start), +PAGE_KERNEL , page_size); +if (rc) +return rc; + } + +return 0 ; +} +#endif /* CONFIG_MEMORY_HOTPLUG */ +#ifdef CONFIG_SPARSEMEM_VMEMMAP int __meminit radix__vmemmap_create_mapping(unsigned long start, unsigned long page_size,Signature · 1 line
1.8.3.1
Re: [PATCH v3 4/5] powerpc/mm: add radix__remove_section_mapping()
In reply to Reza ArbabQuoted 6 lines · Reza Arbab
Tear down and free the four-level page tables of the linear mapping during memory hotremove.
We borrow the basic structure of
remove_pagetable()and friends from the identically-named x86 functions.
Can you add more details here, which explain why we don't need to follow the RCU page table free when doing memory hotunplug ?
Quoted 7 lines
Signed-off-by Reza Arbab <[email protected]>--- arch/powerpc/include/asm/book3s/64/radix.h | 1 + arch/powerpc/mm/pgtable-book3s64.c | 2 +- arch/powerpc/mm/pgtable-radix.c | 163 +++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 1 deletion(-)
....
....
Quoted 11 lines
arch/powerpc/mm/pgtable-radix.c +11
-0+static void remove_pte_table (pte_t *pte_start,unsigned long addr, +unsigned long end) +{ +unsigned long next; +pte_t *pte; + + pte = pte_start +pte_index (addr); +for (; addr < end; addr = next, pte++) { + next = (addr +PAGE_SIZE ) &PAGE_MASK ; +if (next > end) + next = end;
arch/powerpc/mm/pgtable-radix.c void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base, · line 540
Quoted 10 lines
arch/powerpc/mm/pgtable-radix.c +10
-0+ +if (!pte_present (*pte)) +continue ; + +spin_lock (&init_mm.page_table_lock); +pte_clear (&init_mm, addr, pte); +spin_unlock (&init_mm.page_table_lock); + } + +flush_tlb_mm (&init_mm);
Why call a flush here. we do that at the end of remove_page_table . Isn't that sufficient ?
Quoted 69 lines
arch/powerpc/mm/pgtable-radix.c +69
-0+} + +static void remove_pmd_table (pmd_t *pmd_start,unsigned long addr, +unsigned long end,unsigned long map_page_size) +{ +unsigned long next; +pte_t *pte_base; +pmd_t *pmd; + + pmd = pmd_start +pmd_index (addr); +for (; addr < end; addr = next, pmd++) { + next =pmd_addr_end (addr, end); + +if (!pmd_present (*pmd)) +continue ; + +if (map_page_size ==PMD_SIZE ) { +spin_lock (&init_mm.page_table_lock); +pte_clear (&init_mm, addr, (pte_t *)pmd); +spin_unlock (&init_mm.page_table_lock); + +continue ; + } + + pte_base = (pte_t *)pmd_page_vaddr (*pmd); +remove_pte_table (pte_base, addr, next); +free_pte_table (pte_base, pmd); + } +} + +static void remove_pud_table (pud_t *pud_start,unsigned long addr, +unsigned long end,unsigned long map_page_size) +{ +unsigned long next; +pmd_t *pmd_base; +pud_t *pud; + + pud = pud_start +pud_index (addr); +for (; addr < end; addr = next, pud++) { + next =pud_addr_end (addr, end); + +if (!pud_present (*pud)) +continue ; + +if (map_page_size ==PUD_SIZE ) { +spin_lock (&init_mm.page_table_lock); +pte_clear (&init_mm, addr, (pte_t *)pud); +spin_unlock (&init_mm.page_table_lock); + +continue ; + } + + pmd_base = (pmd_t *)pud_page_vaddr (*pud); +remove_pmd_table (pmd_base, addr, next, map_page_size); +free_pmd_table (pmd_base, pud); + } +} + +static void remove_pagetable (unsigned long start,unsigned long end, +unsigned long map_page_size) +{ +unsigned long next; +unsigned long addr; +pgd_t *pgd; +pud_t *pud; + +for (addr = start; addr < end; addr = next) { + next =pgd_addr_end (addr, end); +
arch/powerpc/mm/pgtable-radix.c void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base, · line 619
Quoted 10 lines
arch/powerpc/mm/pgtable-radix.c +10
-0+ pgd =pgd_offset_k (addr); +if (!pgd_present (*pgd)) +continue ; + + pud = (pud_t *)pgd_page_vaddr (*pgd); +remove_pud_table (pud, addr, next, map_page_size); +free_pud_table (pud, pgd); + } + +flush_tlb_mm (&init_mm);
So we want to flush the full kernel tlb when we do a hotplug ? May be check using flush_tlb_kernel_range(). Also that flush_tlb_mm() do check for mm_is_thread_local(). Do we update init_mm correct to handle that check ? I assume we want a tlbie() here instead of tlbiel() ?
Quoted 12 lines
arch/powerpc/mm/pgtable-radix.c +5
-0+} +int radix__create_section_mapping (unsigned long start,unsigned long end) {unsigned long page_size =1 << mmu_psize_defs[mmu_linear_psize].shift;@@ -482,6 +635,16 @@ int radix__create_section_mapping(unsigned long start, unsigned long end)return 0 ; } + +int radix__remove_section_mapping (unsigned long start,unsigned long end) +{
arch/powerpc/mm/pgtable-radix.c int radix__create_section_mapping(unsigned long start, unsigned long end) · line 650
Quoted 10 lines
arch/powerpc/mm/pgtable-radix.c +7
-0+unsigned long page_size =1 << mmu_psize_defs[mmu_linear_psize].shift; + + start =_ALIGN_DOWN (start, page_size); +remove_pagetable (start, end, page_size); + + return 0; +}#endif /* CONFIG_MEMORY_HOTPLUG */ #ifdef CONFIG_SPARSEMEM_VMEMMAP
-aneesh
Quoted 1 line · Balbir Singh
Do we care about alt maps yet?
Good question. I'll try to see if/how altmaps might need special consideration here.
Signature · 1 line
Reza Arbab
Re: [PATCH v3 2/5] powerpc/mm: refactor {create,remove}_section_mapping()
In reply to Aneesh Kumar K.VQuoted 8 lines · Aneesh Kumar K.V
Quoted 5 lines · Reza Arbab
Change {create,remove}_section_mapping() to be wrappers around functions prefixed with "
hash__".This is preparation for the addition of their "
radix__" variants. No functional change.I think this can go upstream now ? To fixup broken hotplug with radix ?
Yes, this one might be worth separating as a fix for the BUG() on radix.
Signature · 1 line
Reza Arbab
Re: [PATCH v3 3/5] powerpc/mm: add radix__create_section_mapping()
In reply to Aneesh Kumar K.VQuoted 7 lines · Aneesh Kumar K.V
Quoted 2 lines · Reza Arbab
Add the linear page mapping function for radix, used by memory hotplug. This is similar to
vmemmap_populate().Ok with this patch your first patch becomes useful. Can you merge that with this and rename
mmu_linear_psizetommu_hotplug_psizeor even usemmu_virtual_psize. The linear naming is confusing.
Thanks for pointing out radix_init_pgtable(). I think the right thing to do here is create these mappings the same way it does. We can probably factor out a common function.
Signature · 1 line
Reza Arbab
Re: [PATCH v3 4/5] powerpc/mm: add radix__remove_section_mapping()
In reply to Aneesh Kumar K.VQuoted 17 lines · Aneesh Kumar K.V
Quoted 16 lines · Reza Arbab
arch/powerpc/mm/pgtable-radix.c +16
-0+static void remove_pte_table (pte_t *pte_start,unsigned long addr, +unsigned long end) +{ +unsigned long next; +pte_t *pte; + + pte = pte_start +pte_index (addr); +for (; addr < end; addr = next, pte++) { + next = (addr +PAGE_SIZE ) &PAGE_MASK ; +if (next > end) + next = end; + +if (!pte_present (*pte)) +continue ; + +spin_lock (&init_mm.page_table_lock);
Quoted 8 lines
arch/powerpc/mm/pgtable-radix.c void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base, · line 540
Quoted 5 lines
arch/powerpc/mm/pgtable-radix.c +5
-0+pte_clear (&init_mm, addr, pte); +spin_unlock (&init_mm.page_table_lock); + } + +flush_tlb_mm (&init_mm);Why call a flush here. we do that at the end of
remove_page_table. Isn't that sufficient ?
This was carried over from the x86 version of the function, where they do flush_tlb_all(). I can experiment to make sure things work without it.
Quoted 19 lines
Quoted 19 lines
arch/powerpc/mm/pgtable-radix.c +19
-0+static void remove_pagetable (unsigned long start,unsigned long end, +unsigned long map_page_size) +{ +unsigned long next; +unsigned long addr; +pgd_t *pgd; +pud_t *pud; + +for (addr = start; addr < end; addr = next) { + next =pgd_addr_end (addr, end); + + pgd =pgd_offset_k (addr); +if (!pgd_present (*pgd)) +continue ; + + pud = (pud_t *)pgd_page_vaddr (*pgd); +remove_pud_table (pud, addr, next, map_page_size); +free_pud_table (pud, pgd); + }
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + flush_tlb_mm(&init_mm);So we want to flush the full kernel tlb when we do a hotplug ? May be check using
flush_tlb_kernel_range(). Also thatflush_tlb_mm()do check formm_is_thread_local(). Do we updateinit_mmcorrect to handle that check ? I assume we want atlbie()here instead oftlbiel()?
I'll try using flush_tlb_kernel_range() instead. That sure does seem more appropriate.
Signature · 1 line
Reza Arbab
Re: [PATCH v3 1/5] powerpc/mm: set the radix linear page mapping size
In reply to Aneesh Kumar K.VQuoted 9 lines · Aneesh Kumar K.V
Quoted 7 lines · Reza Arbab
This was defaulting to 4K, regardless of
PAGE_SIZE.Signed-off-by Reza Arbab <[email protected]>---
arch/powerpc/mm/pgtable-radix.c | 2 ++1 file changed, 2 insertions(+)
Quoted 16 lines
arch/powerpc/mm/pgtable-radix.c void __init radix__early_init_mmu(void) · line 354
Quoted 10 lines
arch/powerpc/mm/pgtable-radix.c +1
-0@@ -351,8 +351,10 @@ void __init radix__early_init_mmu(void) #ifdef CONFIG_PPC_64K_PAGES /* PAGE_SIZE mappings */ mmu_virtual_psize = MMU_PAGE_64K; + mmu_linear_psize =MMU_PAGE_64K ;That is not clearly correct, we map the linear address with either 64K,
2M or 1G depending on the memory available. Take a look at static void__initradix_init_pgtable(void)
So should we fix that initialization regardless or take it out ?
Quoted 9 lines
Quoted 9 lines
arch/powerpc/mm/pgtable-radix.c +1
-0#else mmu_virtual_psize = MMU_PAGE_4K; + mmu_linear_psize =MMU_PAGE_4K ; #endif #ifdef CONFIG_SPARSEMEM_VMEMMAP--
1.8.3.1
Re: [PATCH v3 4/5] powerpc/mm: add radix__remove_section_mapping()
In reply to Aneesh Kumar K.VQuoted 10 lines · Aneesh Kumar K.V
Quoted 10 lines
+ pte =
pte_start+pte_index(addr);
+ for (; addr < end; addr = next, pte++) { + next = (addr +PAGE_SIZE) &PAGE_MASK; + if (next > end)
+ next = end;arch/powerpc/mm/pgtable-radix.c +5
-0+ + if (!pte_present(*pte)) + continue; + + spin_lock(&init_mm.page_table_lock);
Quoted 8 lines
Quoted 5 lines
+ pte_clear(&init_mm, addr, pte); + spin_unlock(&init_mm.page_table_lock); + }
+
+ flush_tlb_mm(&init_mm);Why call a flush here. we do that at the end of
remove_page_table. Isn't that sufficient ?
All those lock/unlock ... what for ? Can't we just do the whole page ?
Also I agree, we can delay the flush of the PTEs to the end.
Ben.
Re: [PATCH v3 1/5] powerpc/mm: set the radix linear page mapping size
In reply to Benjamin HerrenschmidtQuoted 27 lines · Benjamin Herrenschmidt
Quoted 17 lines · Aneesh Kumar K.V
Reza Arbab <[email protected]> writes:
=20Quoted 15 lines
This was defaulting to 4K, regardless of
PAGE_SIZE. =20Signed-off-by Reza Arbab <[email protected]>---
=C2=A0arch/powerpc/mm/pgtable-radix.c | 2 ++
=C2=A01 file changed, 2 insertions(+)
=20arch/powerpc/mm/pgtable-radix.c +0
-0@@ -351,8 +351,10 @@ void __init radix__early_init_mmu(void)=C2=A0#ifdef
CONFIG_PPC_64K_PAGES
=C2=A0 /*PAGE_SIZEmappings */Quoted 8 lines
arch/powerpc/mm/pgtable-radix.c
Quoted 2 lines
=C2=A0
mmu_virtual_psize=3DMMU_PAGE_64K;arch/powerpc/mm/pgtable-radix.c +1
-0+ mmu_linear_psize =3D MMU_PAGE_64K;=20
That is not clearly correct, we map the linear address with either 64K,
2M or 1G depending on the memory available. Take a look at static void__initradix_init_pgtable(void)
=20
Quoted 1 line
So should we fix that initialization regardless or take it out ?
We should not be usuing mmu_linear_psize on radix. Hence we can skip that initialization.
-aneesh
Re: [PATCH v3 2/5] powerpc/mm: refactor {create,remove}_section_mapping()
In reply to Reza ArbabQuoted 7 lines · Reza Arbab
Change {create,remove}_section_mapping() to be wrappers around functions prefixed with "
hash__".This is preparation for the addition of their "
radix__" variants. No functional change.Signed-off-by Reza Arbab <[email protected]>
Re: [PATCH v3 3/5] powerpc/mm: add radix__create_section_mapping()
In reply to Reza Arbabarch/powerpc/mm/pgtable-radix.c void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base, · line 471
Quoted 5 lines
arch/powerpc/mm/pgtable-radix.c +4
-0+#ifdef CONFIG_MEMORY_HOTPLUG +int radix__create_section_mapping (unsigned long start,unsigned long end) +{ +unsigned long page_size =1 << mmu_psize_defs[mmu_linear_psize].shift;
Can we refactor bits from radix_init_pgtable() and reuse?
Balbir
Re: [PATCH v3 3/5] powerpc/mm: add radix__create_section_mapping()
Quoted 6 lines · Balbir Singh
arch/powerpc/mm/pgtable-radix.c void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base, · line 471
Quoted 4 lines
arch/powerpc/mm/pgtable-radix.c +4
-0+#ifdef CONFIG_MEMORY_HOTPLUG +int radix__create_section_mapping (unsigned long start,unsigned long end) +{ +unsigned long page_size =1 << mmu_psize_defs[mmu_linear_psize].shift;Can we refactor bits from
radix_init_pgtable()and reuse?
Yes, that's my plan for v4.
Signature · 1 line
Reza Arbab
Quoted 5 lines · Reza Arbab
Quoted 1 line · Balbir Singh
Do we care about alt maps yet?
Good question. I'll try to see if/how altmaps might need special consideration here.
vmemmap alt-map should be enabled separately and should not be mixed in this series which tries to just get hotplug working on radix.
Re: [PATCH v3 3/5] powerpc/mm: add radix__create_section_mapping()
In reply to Aneesh Kumar K.VQuoted 8 lines · Aneesh Kumar K.V
Quoted 3 lines · Reza Arbab
Quoted 3 lines
Add the linear page mapping function for radix, used by memory hotplug. This is similar to
vmemmap_populate().Ok with this patch your first patch becomes useful. Can you merge that with this and rename
mmu_linear_psizetommu_hotplug_psizeor even usemmu_virtual_psize. The linear naming is confusing.
mmu_linear_psize variable was referring to the page size used to create kernel linear mapping (the 0xc00.... range) for the newly added memory section. Why the name should be changed ?