powerpc/mm: enable memory hotplug on radix
v2 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);
Refactor {create,remove}_section_mapping() into hash__ and radix__ variants.
RFC/TODO:
I wasn't sure what to do in radix__remove_section_mapping(). Its vmemmap counterpart radix__vmemmap_remove_mapping() is stubbed as a FIXME. I left it empty for now.
v2:
* 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 (2):
powerpc/mm: refactor {create,remove}_section_mapping() powerpc/mm: add radix__{create,remove}_section_mapping()
arch/powerpc/include/asm/book3s/64/hash.h | 5 +++++ arch/powerpc/include/asm/book3s/64/radix.h | 5 +++++ arch/powerpc/include/asm/sparsemem.h | 22 ++++++++++++++++++++-- arch/powerpc/mm/hash_utils_64.c | 4 ++-- arch/powerpc/mm/pgtable-radix.c | 23 +++++++++++++++++++++++ 5 files changed, 55 insertions(+), 4 deletions(-)
Signature · 18 lines
1.8.3.1
*** BLURB HERE ***
Reza Arbab (2):
powerpc/mm: refactor {create,remove}_section_mapping()
powerpc/mm: add radix__{create,remove}_section_mapping()
arch/powerpc/include/asm/book3s/64/hash.h | 5 +++++
arch/powerpc/include/asm/book3s/64/radix.h | 5 +++++
arch/powerpc/include/asm/sparsemem.h | 22 ++++++++++++++++++++--
arch/powerpc/mm/hash_utils_64.c | 4 ++--
arch/powerpc/mm/pgtable-radix.c | 23 +++++++++++++++++++++++
5 files changed, 55 insertions(+), 4 deletions(-)
--
1.8.3.1RFC v2 1/2 powerpc/mm: refactor {create,remove}_section_mapping()
Change {create,remove}_section_mapping() to be inline 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/include/asm/sparsemem.h | 14 ++++++++++++-- arch/powerpc/mm/hash_utils_64.c | 4 ++-- 3 files changed, 19 insertions(+), 4 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/include/asm/sparsemem.h +12 -2
@@ -16,8 +16,18 @@#endif /* CONFIG_SPARSEMEM */ #ifdef CONFIG_MEMORY_HOTPLUG -extern int create_section_mapping (unsigned long start,unsigned long end); -extern int remove_section_mapping (unsigned long start,unsigned long end); +static inline int create_section_mapping (unsigned long start, +unsigned long end) +{ +return hash__create_section_mapping (start, end); +} + +static inline int remove_section_mapping (unsigned long start, +unsigned long end) +{ +return hash__remove_section_mapping (start, end); +} +#ifdef CONFIG_NUMA extern int hot_add_scn_to_nid (unsigned long scn_addr);#else
arch/powerpc/mm/hash_utils_64.c +2 -2
@@ -688,7 +688,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,
@@ -702,7 +702,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);
Signature · 1 line
1.8.3.1
RFC v2 2/2 powerpc/mm: add radix__{create, remove}_section_mapping()
In reply to Reza ArbabAdd radix variants of the memory hotplug mapping functions.
--- arch/powerpc/include/asm/book3s/64/radix.h | 5 +++++ arch/powerpc/include/asm/sparsemem.h | 8 ++++++++ arch/powerpc/mm/pgtable-radix.c | 23 +++++++++++++++++++++++ 3 files changed, 36 insertions(+)
arch/powerpc/include/asm/book3s/64/radix.h +5 -0
@@ -229,6 +229,11 @@ extern void radix__vmemmap_remove_mapping(unsigned long start,extern int radix__map_kernel_page (unsigned long ea,unsigned long pa,pgprot_t flags,unsigned int psz); +#ifdef CONFIG_MEMORY_HOTPLUG +int radix__create_section_mapping (unsigned long start,unsigned long end); +void radix__remove_section_mapping (unsigned long start,unsigned long end); +#endif /* CONFIG_MEMORY_HOTPLUG */ +static inline unsigned long radix__get_tree_size (void ) {unsigned long rts_field;
arch/powerpc/include/asm/sparsemem.h +8 -0
@@ -19,12 +19,20 @@static inline int create_section_mapping (unsigned long start,unsigned long end) { +if (radix_enabled ()) +return radix__create_section_mapping (start, end); +return hash__create_section_mapping (start, end); }static inline int remove_section_mapping (unsigned long start,unsigned long end) { +if (radix_enabled ()) { +radix__remove_section_mapping (start, end); +return 0 ; + } +return hash__remove_section_mapping (start, end); }
arch/powerpc/mm/pgtable-radix.c +23 -0
@@ -527,3 +527,26 @@ int radix__has_transparent_hugepage(void) return 0; }#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ + +#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 ; +} + +void radix__remove_section_mapping (unsigned long start,unsigned long end) +{ +} +#endif /* CONFIG_MEMORY_HOTPLUG */
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 6 lines
Refactor {create,remove}_section_mapping() into
hash__andradix__variants.RFC/TODO:
I wasn't sure what to do inradix__remove_section_mapping(). Its vmemmap counterpartradix__vmemmap_remove_mapping()is stubbed as a FIXME. I left it empty for now.
For linear mapping and for vmemmap area we should do something equivalent of
static void __meminitremove_pagetable(unsigned long start, unsigned long end, bool direct)
as done for x86.
-aneesh