Skip to contentSkip to conversation

mm/hugetlb: Allow arch to override and call the weak function

PATCH Superseded Aneesh Kumar K.V 4 participants 8 messages Jun 1, 2017 – Jun 9, 2017

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 mm/hugetlb: Allow arch to override and call the weak function

For ppc64, we want to call this function when we are not running as guest. Also, if we failed to allocate hugepages, let the user know.

---
 include/linux/hugetlb.h | 1 +
 mm/hugetlb.c            | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
include/linux/hugetlb.h +1 -0
index caee7c4664c8..964401ff0af0 100644
@@ -357,6 +357,7 @@ int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
 			pgoff_t idx);
 
 /* arch callback */
+int __init __alloc_bootmem_huge_page(struct hstate *h);
 int __init alloc_bootmem_huge_page(struct hstate *h);
 
 void __init hugetlb_bad_size(void);
mm/hugetlb.c +4 -1
index 28217a147fe3..160282b13722 100644
@@ -2103,7 +2103,9 @@ struct page *alloc_huge_page_noerr(struct vm_area_struct *vma,
 	return page;
 }
 
-int __weak alloc_bootmem_huge_page(struct hstate *h)
+int alloc_bootmem_huge_page(struct hstate *h)
+	__attribute__ ((weak, alias("__alloc_bootmem_huge_page")));
+int __alloc_bootmem_huge_page(struct hstate *h)
 {
 	struct huge_bootmem_page *m;
 	int nr_nodes, node;
@@ -2124,6 +2126,7 @@ int __weak alloc_bootmem_huge_page(struct hstate *h)
 			goto found;
 		}
 	}
+	pr_info("Failed to allocate hugepage of size %ld\n", huge_page_size(h));
 	return 0;
 
 found:
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 2/2 powerpc/mm/hugetlb: Add support for reserving gigantic huge pages via kernel command line

With commit aa888a74977a8 ("hugetlb: support larger than MAX_ORDER") we added support for allocating gigantic hugepages via kernel command line. Switch ppc64 arch specific code to use that.

W.r.t FSL support, we now limit our allocation range using BOOTMEM_ALLOC_ACCESSIBLE.

We use the kernel command line to do reservation of hugetlb pages on powernv platforms. On pseries hash mmu mode the supported gigantic huge page size is 16GB and that can only be allocated with hypervisor assist. For pseries the command line option doesn't do the allocation. Instead pseries does gigantic hugepage allocation based on hypervisor hint that is specified via "ibm,expected#pages" property of the memory node.

Cc Scott Wood <[email protected]>
Cc Christophe Leroy <[email protected]>
---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |   2 +-
 arch/powerpc/include/asm/hugetlb.h            |  14 --
 arch/powerpc/kernel/setup-common.c            |   7 -
 arch/powerpc/mm/hash_utils_64.c               |   2 +-
 arch/powerpc/mm/hugetlbpage.c                 | 177 +++-----------------------
 arch/powerpc/mm/init_32.c                     |   2 -
 6 files changed, 22 insertions(+), 182 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu-hash.h +1 -1
index 6981a52b3887..67766e60a6b6 100644
@@ -468,7 +468,7 @@ extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
 			     int psize, int ssize);
 int htab_remove_mapping(unsigned long vstart, unsigned long vend,
 			int psize, int ssize);
-extern void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages);
+extern void pSeries_add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages);
 extern void demote_segment_4k(struct mm_struct *mm, unsigned long addr);
 
 #ifdef CONFIG_PPC_PSERIES
arch/powerpc/include/asm/hugetlb.h +0 -14
index 7f4025a6c69e..b8a0fb442c64 100644
@@ -218,18 +218,4 @@ static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
 }
 #endif /* CONFIG_HUGETLB_PAGE */
 
-/*
- * FSL Book3E platforms require special gpage handling - the gpages
- * are reserved early in the boot process by memblock instead of via
- * the .dts as on IBM platforms.
- */
-#if defined(CONFIG_HUGETLB_PAGE) && (defined(CONFIG_PPC_FSL_BOOK3E) || \
-    defined(CONFIG_PPC_8xx))
-extern void __init reserve_hugetlb_gpages(void);
-#else
-static inline void reserve_hugetlb_gpages(void)
-{
-}
-#endif
-
 #endif /* _ASM_POWERPC_HUGETLB_H */
arch/powerpc/kernel/setup-common.c +0 -7
index 71dcda91755d..8389ff5ac002 100644
@@ -912,13 +912,6 @@ void __init setup_arch(char **cmdline_p)
 	/* Reserve large chunks of memory for use by CMA for KVM. */
 	kvm_cma_reserve();
 
-	/*
-	 * Reserve any gigantic pages requested on the command line.
-	 * memblock needs to have been initialized by the time this is
-	 * called since this will reserve memory.
-	 */
-	reserve_hugetlb_gpages();
-
 	klp_init_thread_info(&init_thread_info);
 
 	init_mm.start_code = (unsigned long)_stext;
arch/powerpc/mm/hash_utils_64.c +1 -1
index f2095ce9d4b0..c4b04c4aac86 100644
@@ -509,7 +509,7 @@ static int __init htab_dt_scan_hugepage_blocks(unsigned long node,
 			phys_addr, block_size, expected_pages);
 	if (phys_addr + (16 * GB) <= memblock_end_of_DRAM()) {
 		memblock_reserve(phys_addr, block_size * expected_pages);
-		add_gpage(phys_addr, block_size, expected_pages);
+		pSeries_add_gpage(phys_addr, block_size, expected_pages);
 	}
 	return 0;
 }
arch/powerpc/mm/hugetlbpage.c +20 -157

207 lines not on this page · raw message

arch/powerpc/mm/init_32.c +0 -2
index 8a7c38b8d335..436d9721ab63 100644
@@ -132,8 +132,6 @@ void __init MMU_init(void)
 	 * Reserve gigantic pages for hugetlb.  This MUST occur before
 	 * lowmem_end_addr is initialized below.
 	 */
-	reserve_hugetlb_gpages();
-
 	if (memblock.memory.cnt > 1) {
 #ifndef CONFIG_WII
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v2 2/2] powerpc/mm/hugetlb: Add support for reserving gigantic huge pages via kernel command line

Quoted 3 lines · Aneesh Kumar K.V

With commit aa888a74977a8 ("hugetlb: support larger than MAX_ORDER") we added support for allocating gigantic hugepages via kernel command line. Switch ppc64 arch specific code to use that.

Is it only ppc64 ? Your patch removes things defined for the 8xx and modifies stuff in init_32.c

On the 8xx, as far as I remember, 8M pages on 4k pages mode are above default MAX_ORDER, I solved it by increasing MAX_ORDER. Is that wrong ?

Quoted 27 lines

W.r.t FSL support, we now limit our allocation range using BOOTMEM_ALLOC_ACCESSIBLE.

We use the kernel command line to do reservation of hugetlb pages on powernv platforms. On pseries hash mmu mode the supported gigantic huge page size is 16GB and that can only be allocated with hypervisor assist. For pseries the command line option doesn't do the allocation. Instead pseries does gigantic hugepage allocation based on hypervisor hint that is specified via "ibm,expected#pages" property of the memory node.

Cc Scott Wood <[email protected]>
Cc Christophe Leroy <[email protected]>
---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |   2 +-
 arch/powerpc/include/asm/hugetlb.h            |  14 --
 arch/powerpc/kernel/setup-common.c            |   7 -
 arch/powerpc/mm/hash_utils_64.c               |   2 +-
 arch/powerpc/mm/hugetlbpage.c                 | 177 +++-----------------------
 arch/powerpc/mm/init_32.c                     |   2 -
 6 files changed, 22 insertions(+), 182 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -0
index 6981a52b3887..67766e60a6b6 100644

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend, · line 471

Quoted 5 lines
arch/powerpc/include/asm/book3s/64/mmu-hash.h +1 -1
@@ -468,7 +468,7 @@ extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
 			     int psize, int ssize);
 int htab_remove_mapping(unsigned long vstart, unsigned long vend,
 			int psize, int ssize);
-extern void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages);
+extern void pSeries_add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages);

Linux kernel coding style says 'mixed-case names are frowned upon'

Christophe

---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus

#3 lore raw

Re: [PATCH v2 2/2] powerpc/mm/hugetlb: Add support for reserving gigantic huge pages via kernel command line

Quoted 35 lines · christophe leroy
Quoted 3 lines · Aneesh Kumar K.V

With commit aa888a74977a8 ("hugetlb: support larger than MAX_ORDER") we added support for allocating gigantic hugepages via kernel command line. Switch ppc64 arch specific code to use that.

Is it only ppc64 ? Your patch removes things defined for the 8xx and modifies stuff in init_32.c

On the 8xx, as far as I remember, 8M pages on 4k pages mode are above default MAX_ORDER, I solved it by increasing MAX_ORDER. Is that wrong ?

Quoted 22 lines

W.r.t FSL support, we now limit our allocation range using BOOTMEM_ALLOC_ACCESSIBLE.

We use the kernel command line to do reservation of hugetlb pages on powernv platforms. On pseries hash mmu mode the supported gigantic huge page size is 16GB and that can only be allocated with hypervisor assist. For pseries the command line option doesn't do the allocation. Instead pseries does gigantic hugepage allocation based on hypervisor hint that is specified via "ibm,expected#pages" property of the memory node.

Cc Scott Wood <[email protected]>
Cc Christophe Leroy <[email protected]>
---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |   2 +-
 arch/powerpc/include/asm/hugetlb.h            |  14 --
 arch/powerpc/kernel/setup-common.c            |   7 -
 arch/powerpc/mm/hash_utils_64.c               |   2 +-
 arch/powerpc/mm/hugetlbpage.c                 | 177 +++-----------------------
 arch/powerpc/mm/init_32.c                     |   2 -
 6 files changed, 22 insertions(+), 182 deletions(-)
Quoted 12 lines

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend, · line 471

Quoted 10 lines
arch/powerpc/include/asm/book3s/64/mmu-hash.h +1 -1
index 6981a52b3887..67766e60a6b6 100644
@@ -468,7 +468,7 @@ extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
 			     int psize, int ssize);
 int htab_remove_mapping(unsigned long vstart, unsigned long vend,
 			int psize, int ssize);
-extern void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages);
+extern void pSeries_add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages);

Linux kernel coding style says 'mixed-case names are frowned upon'

True, but there is precedent within arch/powerpc/platforms/pseries seeing as "pSeries_" is already used heavily to prefix function names.

-Tyrel

Quoted 7 lines

Christophe

---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus

#4 lore raw

Re: [PATCH v2 2/2] powerpc/mm/hugetlb: Add support for reserving gigantic huge pages via kernel command line

Quoted 3 lines · Tyrel Datwyler
Quoted 2 lines · christophe leroy

Le 01/06/2017 =C3=A0 16:30, Aneesh Kumar K.V a =C3=A9crit :

arch/power=

Quoted 1 line
arch/power= renamed from arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -0

pc/include/asm/book3s/64/mmu-hash.h

Quoted 4 lines
Quoted 4 lines

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, =

Quoted 4 lines

index 6981a52b3887..67766e60a6b6 100644

arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -0
@@ -468,7 +468,7 @@ extern int htab_bolt_mapping(unsigned long vstart, =

unsigned long vend,

Quoted 4 lines
Quoted 4 lines

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,

Quoted 4 lines
arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -1
 			     int psize, int ssize);
 int htab_remove_mapping(unsigned long vstart, unsigned long vend,
 			int psize, int ssize);
-extern void add_gpage(u64 addr, u64 page_size, unsigned long number_of=

_pages);

Quoted 1 line
Quoted 1 line

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, = · line 471

Quoted 1 line
arch/powerpc/include/asm/book3s/64/mmu-hash.h +1 -0
+extern void pSeries_add_gpage(u64 addr, u64 page_size, unsigned long n=

umber_of_pages);

Quoted 4 lines
Quoted 2 lines

=20
Linux kernel coding style says 'mixed-case names are frowned upon'

True, but there is precedent within arch/powerpc/platforms/pseries seeing=

as "pSeries_" is

Quoted 1 line

already used heavily to prefix function names.

True, but it's still horrible. Any new names should just use "pseries".

cheers

#6 lore raw

Re: [PATCH v2 2/2] powerpc/mm/hugetlb: Add support for reserving gigantic huge pages via kernel command line

In reply to christophe leroy
Quoted 2 lines · christophe leroy

Le 01/06/2017 =C3=A0 16:30, Aneesh Kumar K.V a =C3=A9crit :

Quoted 1 line

With commit aa888a74977a8 ("hugetlb: support larger than MAX_ORDER") we =

added

Quoted 8 lines
Quoted 2 lines

support for allocating gigantic hugepages via kernel command line. Switch ppc64 arch specific code to use that.

Is it only ppc64 ? Your patch removes things defined for the 8xx and=20 modifies stuff in init_32.c

On the 8xx, as far as I remember, 8M pages on 4k pages mode are above=20 default MAX_ORDER, I solved it by increasing MAX_ORDER. Is that wrong ?

I was hoping every platform can switch to generic code. Obviously I didn't test the changes on anything other than ppc64. Can you try with this patchset and pass hugepagesz=3D<size> hugepages=3D<number> kernel arg and see if hugepage allocation works for you ?

Quoted 3 lines
Quoted 3 lines

W.r.t FSL support, we now limit our allocation range using BOOTMEM_ALLOC=

_ACCESSIBLE.

Quoted 2 lines
Quoted 2 lines

We use the kernel command line to do reservation of hugetlb pages on pow=

ernv

Quoted 1 line
Quoted 1 line

platforms. On pseries hash mmu mode the supported gigantic huge page siz=

e is

Quoted 1 line
Quoted 1 line

16GB and that can only be allocated with hypervisor assist. For pseries =

the

Quoted 1 line
Quoted 1 line

command line option doesn't do the allocation. Instead pseries does giga=

ntic

Quoted 12 lines
Quoted 6 lines

hugepage allocation based on hypervisor hint that is specified via "ibm,expected#pages" property of the memory node.

Cc Scott Wood <[email protected]>
Cc Christophe Leroy <[email protected]>
Quoted 6 lines
---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |   2 +-
 arch/powerpc/include/asm/hugetlb.h            |  14 --
 arch/powerpc/kernel/setup-common.c            |   7 -
 arch/powerpc/mm/hash_utils_64.c               |   2 +-

arch/powerpc/mm/hugetlbpage.c | 177 +++----------------=

-------

Quoted 4 lines

arch/powerp=

Quoted 4 lines
 arch/powerpc/mm/init_32.c                     |   2 -
 6 files changed, 22 insertions(+), 182 deletions(-)
arch/powerp= renamed from arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -0

c/include/asm/book3s/64/mmu-hash.h

Quoted 4 lines

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, u=

Quoted 4 lines

index 6981a52b3887..67766e60a6b6 100644

arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -0
@@ -468,7 +468,7 @@ extern int htab_bolt_mapping(unsigned long vstart, u=

nsigned long vend,

Quoted 4 lines

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,

Quoted 4 lines
arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -1
 			     int psize, int ssize);
 int htab_remove_mapping(unsigned long vstart, unsigned long vend,
 			int psize, int ssize);
-extern void add_gpage(u64 addr, u64 page_size, unsigned long number_of_=

pages);

Quoted 1 line

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, u= · line 471

Quoted 1 line
arch/powerpc/include/asm/book3s/64/mmu-hash.h +1 -0
+extern void pSeries_add_gpage(u64 addr, u64 page_size, unsigned long nu=

mber_of_pages);

Quoted 2 lines

Linux kernel coding style says 'mixed-case names are frowned upon'

Agreed, but that is how we named all the pseries related functions in platforms/pseries/*.c files. Hence i kept the same naming style.

-aneesh

#5 lore raw

Re: [PATCH v2 2/2] powerpc/mm/hugetlb: Add support for reserving gigantic huge pages via kernel command line

In reply to Michael Ellerman
Quoted 4 lines · Michael Ellerman
Quoted 3 lines · Tyrel Datwyler
Quoted 2 lines · christophe leroy

Le 01/06/2017 =C3=A0 16:30, Aneesh Kumar K.V a =C3=A9crit :

arch/powe=

Quoted 1 line
arch/powe= renamed from arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -0

rpc/include/asm/book3s/64/mmu-hash.h

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart,=

Quoted 4 lines

index 6981a52b3887..67766e60a6b6 100644

arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -0
@@ -468,7 +468,7 @@ extern int htab_bolt_mapping(unsigned long vstart,=

unsigned long vend,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,

Quoted 4 lines
arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -1
 			     int psize, int ssize);
 int htab_remove_mapping(unsigned long vstart, unsigned long vend,
 			int psize, int ssize);
-extern void add_gpage(u64 addr, u64 page_size, unsigned long number_o=

f_pages);

Quoted 1 line
Quoted 1 line
Quoted 1 line

arch/powerpc/include/asm/book3s/64/mmu-hash.h extern int htab_bolt_mapping(unsigned long vstart,= · line 471

Quoted 1 line
arch/powerpc/include/asm/book3s/64/mmu-hash.h +1 -0
+extern void pSeries_add_gpage(u64 addr, u64 page_size, unsigned long =

number_of_pages);

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

=20
Linux kernel coding style says 'mixed-case names are frowned upon'

True, but there is precedent within arch/powerpc/platforms/pseries seein=

g as "pSeries_" is

Quoted 3 lines
Quoted 1 line

already used heavily to prefix function names.

True, but it's still horrible. Any new names should just use "pseries".

I will update in the next iteration. I will wait to get feedback on FSL/8xx before posting the next version.

-aneesh

#7 lore raw

Re: [PATCH v2 2/2] powerpc/mm/hugetlb: Add support for reserving gigantic huge pages via kernel command line

In reply to Aneesh Kumar K.V
Quoted 10 lines · Aneesh Kumar K.V
Quoted 8 lines · christophe leroy
Quoted 3 lines · Aneesh Kumar K.V

With commit aa888a74977a8 ("hugetlb: support larger than MAX_ORDER") we added support for allocating gigantic hugepages via kernel command line. Switch ppc64 arch specific code to use that.

Is it only ppc64 ? Your patch removes things defined for the 8xx and modifies stuff in init_32.c

Quoted 9 lines
Quoted 2 lines

On the 8xx, as far as I remember, 8M pages on 4k pages mode are above default MAX_ORDER, I solved it by increasing MAX_ORDER. Is that wrong ?

I was hoping every platform can switch to generic code. Obviously I didn't test the changes on anything other than ppc64. Can you try with this patchset and pass hugepagesz=<size> hugepages=<number> kernel arg and see if hugepage allocation works for you ?

I'm sorry I didn't have time to test it this week and I won't have time either in the next two weeks.

Christophe