Reduce ifdef mess in slice.c
v2 cover Reduce ifdef mess in slice.c
This series is a split out of the v1 series "Reduce ifdef mess in hugetlbpage.c and slice.c".
It is also rebased after the series from Aneesh to reduce context size for Radix.
See http://kisskb.ellerman.id.au/kisskb/branch/chleroy/head/f263887b4ca31f4bb0fe77823e301c28ba27c796/ for wide compilation.
Christophe Leroy (11):
powerpc/mm: fix erroneous duplicate slb_addr_limit init powerpc/mm: no slice for nohash/64
powerpc/mm: hand a context_t over to slice_mask_for_size() instead of
mm_struct
powerpc/mm: move slice_mask_for_size() into mmu.h powerpc/mm: get rid of mm_ctx_slice_mask_xxx()
powerpc/mm: remove unnecessary #ifdef CONFIG_PPC64 powerpc/mm: remove a couple of #ifdef CONFIG_PPC_64K_PAGES in
mm/slice.c
powerpc/8xx: get rid of #ifdef CONFIG_HUGETLB_PAGE for slices powerpc/mm: define get_slice_psize() all the time powerpc/mm: define subarch SLB_ADDR_LIMIT_DEFAULT powerpc/mm: drop slice DEBUG
arch/powerpc/include/asm/book3s/64/mmu.h | 29 +++--- arch/powerpc/include/asm/book3s/64/slice.h | 2 + arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 51 +++++------ arch/powerpc/include/asm/nohash/32/slice.h | 2 + arch/powerpc/include/asm/nohash/64/slice.h | 12 --- arch/powerpc/include/asm/slice.h | 9 +- arch/powerpc/kernel/setup-common.c | 6 -- arch/powerpc/mm/hash_utils_64.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 4 +- arch/powerpc/mm/slice.c | 132 ++++----------------------- arch/powerpc/mm/tlb_nohash.c | 4 +- arch/powerpc/platforms/Kconfig.cputype | 4 + 12 files changed, 69 insertions(+), 188 deletions(-) delete mode 100644 arch/powerpc/include/asm/nohash/64/slice.h
Signature · 1 line
2.13.3
PATCH v2 1/11 powerpc/mm: fix erroneous duplicate slb_addr_limit init
Commit 67fda38f0d68 ("powerpc/mm: Move slb_addr_linit to early_init_mmu") moved slb_addr_limit init out of setup_arch().
Commit 701101865f5d ("powerpc/mm: Reduce memory usage for mm_context_t for radix") brought it back into setup_arch() by error.
This patch reverts that erroneous regress.
--- arch/powerpc/kernel/setup-common.c | 6 ------ 1 file changed, 6 deletions(-)
arch/powerpc/kernel/setup-common.c +0 -6
@@ -950,12 +950,6 @@ void __init setup_arch(char **cmdline_p) init_mm.end_data = (unsigned long ) _edata; init_mm.brk = klimit; -#ifdef CONFIG_PPC_MM_SLICES -#if defined(CONFIG_PPC_8xx) - init_mm.context.slb_addr_limit =DEFAULT_MAP_WINDOW ; -#endif -#endif -#ifdef CONFIG_SPAPR_TCE_IOMMU mm_iommu_init (&init_mm);#endif
Signature · 1 line
2.13.3
Re: [PATCH v2 01/11] powerpc/mm: fix erroneous duplicate slb_addr_limit init
Quoted 8 lines · Christophe Leroy
Commit
67fda38f0d68("powerpc/mm: Moveslb_addr_linittoearly_init_mmu") movedslb_addr_limitinit out ofsetup_arch().Commit
701101865f5d("powerpc/mm: Reduce memory usage formm_context_tfor radix") brought it back intosetup_arch()by error.This patch reverts that erroneous regress.
Quoted 25 lines
Fixes 701101865f5d ("powerpc/mm: Reduce memory usage for mm_context_t for radix")Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/kernel/setup-common.c | 6 ------ 1 file changed, 6 deletions(-)arch/powerpc/kernel/setup-common.c +0
-6@@ -950,12 +950,6 @@ void __init setup_arch(char **cmdline_p) init_mm.end_data = (unsigned long ) _edata; init_mm.brk = klimit; -#ifdef CONFIG_PPC_MM_SLICES -#if defined(CONFIG_PPC_8xx) - init_mm.context.slb_addr_limit =DEFAULT_MAP_WINDOW ; -#endif -#endif -#ifdef CONFIG_SPAPR_TCE_IOMMU mm_iommu_init (&init_mm);#endif Signature · 1 line
2.13.3
Re: [PATCH v2 01/11] powerpc/mm: fix erroneous duplicate slb_addr_limit init
In reply to Christophe LeroyQuoted 11 lines · Christophe Leroy
Commit
67fda38f0d68("powerpc/mm: Moveslb_addr_linittoearly_init_mmu") movedslb_addr_limitinit out ofsetup_arch().Commit
701101865f5d("powerpc/mm: Reduce memory usage formm_context_tfor radix") brought it back intosetup_arch()by error.This patch reverts that erroneous regress.
Fixes 701101865f5d ("powerpc/mm: Reduce memory usage for mm_context_t for radix")Signed-off-by Christophe Leroy <[email protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>
Patches 1-10 applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/5ba666d56c4ff9b011c1b029dcc689cf
cheers
PATCH v2 2/11 powerpc/mm: no slice for nohash/64
In reply to Christophe LeroyOnly nohash/32 and book3s/64 support mm slices.
--- arch/powerpc/include/asm/nohash/64/slice.h | 12 ------------ arch/powerpc/include/asm/slice.h | 4 +--- arch/powerpc/platforms/Kconfig.cputype | 4 ++++ 3 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 arch/powerpc/include/asm/nohash/64/slice.h
arch/powerpc/include/asm/nohash/64/slice.h deleted +0 -12
@@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_POWERPC_NOHASH_64_SLICE_H -#define _ASM_POWERPC_NOHASH_64_SLICE_H - -#ifdef CONFIG_PPC_64K_PAGES -#define get_slice_psize (mm, addr) MMU_PAGE_64K -#else /* CONFIG_PPC_64K_PAGES */ -#define get_slice_psize (mm, addr) MMU_PAGE_4K -#endif /* !CONFIG_PPC_64K_PAGES */ -#define slice_set_user_psize (mm, psize) do { BUG(); } while (0) - -#endif /* _ASM_POWERPC_NOHASH_64_SLICE_H */
arch/powerpc/include/asm/slice.h +1 -3
@@ -4,9 +4,7 @@#ifdef CONFIG_PPC_BOOK3S_64 #include <asm/book3s/64/slice.h> -#elif defined(CONFIG_PPC64 ) -#include <asm/nohash/64/slice.h> -#elif defined(CONFIG_PPC_MMU_NOHASH ) +#elif defined(CONFIG_PPC_MMU_NOHASH_32 )#include <asm/nohash/32/slice.h> #endif
arch/powerpc/platforms/Kconfig.cputype +4 -0
@@ -391,6 +391,10 @@ config PPC_MMU_NOHASH def_bool y depends on !PPC_BOOK3S +config PPC_MMU_NOHASH_32 + def_bool y + depends on PPC_MMU_NOHASH && PPC32 + config PPC_BOOK3E_MMU def_bool y depends on FSL_BOOKE || PPC_BOOK3E
Signature · 1 line
2.13.3
Re: [PATCH v2 02/11] powerpc/mm: no slice for nohash/64
Quoted 2 lines · Christophe Leroy
Only nohash/32 and book3s/64 support mm slices.
Quoted 58 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/include/asm/nohash/64/slice.h | 12 ------------ arch/powerpc/include/asm/slice.h | 4 +--- arch/powerpc/platforms/Kconfig.cputype | 4 ++++ 3 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 arch/powerpc/include/asm/nohash/64/slice.harch/powerpc/include/asm/nohash/64/slice.h deleted +0
-12@@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_POWERPC_NOHASH_64_SLICE_H -#define _ASM_POWERPC_NOHASH_64_SLICE_H - -#ifdef CONFIG_PPC_64K_PAGES -#define get_slice_psize (mm, addr) MMU_PAGE_64K -#else /* CONFIG_PPC_64K_PAGES */ -#define get_slice_psize (mm, addr) MMU_PAGE_4K -#endif /* !CONFIG_PPC_64K_PAGES */ -#define slice_set_user_psize (mm, psize) do { BUG(); } while (0) - -#endif /* _ASM_POWERPC_NOHASH_64_SLICE_H */ arch/powerpc/include/asm/slice.h +1
-3@@ -4,9 +4,7 @@#ifdef CONFIG_PPC_BOOK3S_64 #include <asm/book3s/64/slice.h> -#elif defined(CONFIG_PPC64 ) -#include <asm/nohash/64/slice.h> -#elif defined(CONFIG_PPC_MMU_NOHASH ) +#elif defined(CONFIG_PPC_MMU_NOHASH_32 )#include <asm/nohash/32/slice.h> #endif arch/powerpc/platforms/Kconfig.cputype +4
-0@@ -391,6 +391,10 @@ config PPC_MMU_NOHASH def_bool y depends on !PPC_BOOK3S +config PPC_MMU_NOHASH_32 + def_bool y + depends on PPC_MMU_NOHASH && PPC32 + config PPC_BOOK3E_MMU def_bool y depends on FSL_BOOKE || PPC_BOOK3ESignature · 1 line
2.13.3
PATCH v2 3/11 powerpc/mm: hand a context_t over to slice_mask_for_size() instead of mm_struct
In reply to Christophe Leroyslice_mask_for_size() only uses mm->context, so hand directly a pointer to the context. This will help moving the function in subarch mmu.h in the next patch by avoiding having to include the definition of struct mm_struct
--- arch/powerpc/mm/slice.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
arch/powerpc/mm/slice.c +17 -17
@@ -151,32 +151,32 @@ static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret, }#ifdef CONFIG_PPC_BOOK3S_64 -static struct slice_mask *slice_mask_for_size (struct mm_struct *mm,int psize) +static struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) {#ifdef CONFIG_PPC_64K_PAGES if (psize ==MMU_PAGE_64K ) -return mm_ctx_slice_mask_64k (&mm->context); +return mm_ctx_slice_mask_64k (&ctx);#endif if (psize ==MMU_PAGE_4K ) -return mm_ctx_slice_mask_4k (&mm->context); +return mm_ctx_slice_mask_4k (&ctx);#ifdef CONFIG_HUGETLB_PAGE if (psize ==MMU_PAGE_16M ) -return mm_ctx_slice_mask_16m (&mm->context); +return mm_ctx_slice_mask_16m (&ctx);if (psize ==MMU_PAGE_16G ) -return mm_ctx_slice_mask_16g (&mm->context); +return mm_ctx_slice_mask_16g (&ctx);#endif BUG (); }#elif defined(CONFIG_PPC_8xx) -static struct slice_mask *slice_mask_for_size (struct mm_struct *mm,int psize) +static struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) {if (psize == mmu_virtual_psize) -return &mm->context.mask_base_psize; +return &ctx->mask_base_psize;#ifdef CONFIG_HUGETLB_PAGE if (psize ==MMU_PAGE_512K ) -return &mm->context.mask_512k; +return &ctx->mask_512k;if (psize ==MMU_PAGE_8M ) -return &mm->context.mask_8m; +return &ctx->mask_8m;#endif BUG (); }
@@ -246,7 +246,7 @@ static void slice_convert(struct mm_struct *mm,slice_dbg ("slice_convert(mm=%p, psize=%d)\n" , mm, psize);slice_print_mask (" mask" , mask); - psize_mask =slice_mask_for_size (mm, psize); + psize_mask =slice_mask_for_size (&mm->context, psize);/* We need to use a spinlock here to protect against * concurrent 64k -> 4k demotion ...
@@ -263,7 +263,7 @@ static void slice_convert(struct mm_struct *mm,/* Update the slice_mask */ old_psize = (lpsizes[index] >> (mask_index *4 )) &0xf ; - old_mask =slice_mask_for_size (mm, old_psize); + old_mask =slice_mask_for_size (&mm->context, old_psize); old_mask->low_slices &= ~(1u << i); psize_mask->low_slices |=1u << i;
@@ -282,7 +282,7 @@ static void slice_convert(struct mm_struct *mm,/* Update the slice_mask */ old_psize = (hpsizes[index] >> (mask_index *4 )) &0xf ; - old_mask =slice_mask_for_size (mm, old_psize); + old_mask =slice_mask_for_size (&mm->context, old_psize);__clear_bit (i, old_mask->high_slices);__set_bit (i, psize_mask->high_slices);
@@ -538,7 +538,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,/* First make up a "good" mask of slices that have the right size * already */ - maskp =slice_mask_for_size (mm, psize); + maskp =slice_mask_for_size (&mm->context, psize);/* * Here "good" means slices that are already the right page size,
@@ -565,7 +565,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,* a pointer to good mask for the next code to use. */ if (IS_ENABLED (CONFIG_PPC_64K_PAGES ) && psize ==MMU_PAGE_64K ) { - compat_maskp =slice_mask_for_size (mm,MMU_PAGE_4K ); + compat_maskp =slice_mask_for_size (&mm->context,MMU_PAGE_4K );if (fixed)slice_or_mask (&good_mask, maskp, compat_maskp);else
@@ -760,7 +760,7 @@ void slice_init_new_context_exec(struct mm_struct *mm)/* * Slice mask cache starts zeroed, fill the default size cache. */ - mask =slice_mask_for_size (mm, psize); + mask =slice_mask_for_size (&mm->context, psize); mask->low_slices = ~0UL ;if (SLICE_NUM_HIGH )bitmap_fill (mask->high_slices,SLICE_NUM_HIGH );
@@ -819,14 +819,14 @@ int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,VM_BUG_ON (radix_enabled ()); - maskp =slice_mask_for_size (mm, psize); + maskp =slice_mask_for_size (&mm->context, psize);#ifdef CONFIG_PPC_64K_PAGES /* We need to account for 4k slices too */ if (psize ==MMU_PAGE_64K ) {const struct slice_mask *compat_maskp;struct slice_mask available; - compat_maskp =slice_mask_for_size (mm,MMU_PAGE_4K ); + compat_maskp =slice_mask_for_size (&mm->context,MMU_PAGE_4K );slice_or_mask (&available, maskp, compat_maskp);return !slice_check_range_fits (mm, &available, addr, len); }
Signature · 1 line
2.13.3
Re: [PATCH v2 03/11] powerpc/mm: hand a context_t over to slice_mask_for_size() instead of mm_struct
Quoted 5 lines · Christophe Leroy
slice_mask_for_size()only usesmm->context, so hand directly a pointer to the context. This will help moving the function in subarchmmu.hin the next patch by avoiding having to include the definition of structmm_struct
Quoted 124 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/mm/slice.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)arch/powerpc/mm/slice.c +17
-17@@ -151,32 +151,32 @@ static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret, }#ifdef CONFIG_PPC_BOOK3S_64 -static struct slice_mask *slice_mask_for_size (struct mm_struct *mm,int psize) +static struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) {#ifdef CONFIG_PPC_64K_PAGES if (psize ==MMU_PAGE_64K ) -return mm_ctx_slice_mask_64k (&mm->context); +return mm_ctx_slice_mask_64k (&ctx);#endif if (psize ==MMU_PAGE_4K ) -return mm_ctx_slice_mask_4k (&mm->context); +return mm_ctx_slice_mask_4k (&ctx);#ifdef CONFIG_HUGETLB_PAGE if (psize ==MMU_PAGE_16M ) -return mm_ctx_slice_mask_16m (&mm->context); +return mm_ctx_slice_mask_16m (&ctx);if (psize ==MMU_PAGE_16G ) -return mm_ctx_slice_mask_16g (&mm->context); +return mm_ctx_slice_mask_16g (&ctx);#endif BUG (); }#elif defined(CONFIG_PPC_8xx) -static struct slice_mask *slice_mask_for_size (struct mm_struct *mm,int psize) +static struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) {if (psize == mmu_virtual_psize) -return &mm->context.mask_base_psize; +return &ctx->mask_base_psize;#ifdef CONFIG_HUGETLB_PAGE if (psize ==MMU_PAGE_512K ) -return &mm->context.mask_512k; +return &ctx->mask_512k;if (psize ==MMU_PAGE_8M ) -return &mm->context.mask_8m; +return &ctx->mask_8m;#endif BUG (); }@@ -246,7 +246,7 @@ static void slice_convert(struct mm_struct *mm,slice_dbg ("slice_convert(mm=%p, psize=%d)\n" , mm, psize);slice_print_mask (" mask" , mask); - psize_mask =slice_mask_for_size (mm, psize); + psize_mask =slice_mask_for_size (&mm->context, psize);/* We need to use a spinlock here to protect against * concurrent 64k -> 4k demotion ... @@ -263,7 +263,7 @@ static void slice_convert(struct mm_struct *mm,/* Update the slice_mask */ old_psize = (lpsizes[index] >> (mask_index *4 )) &0xf ; - old_mask =slice_mask_for_size (mm, old_psize); + old_mask =slice_mask_for_size (&mm->context, old_psize); old_mask->low_slices &= ~(1u << i); psize_mask->low_slices |=1u << i;@@ -282,7 +282,7 @@ static void slice_convert(struct mm_struct *mm,/* Update the slice_mask */ old_psize = (hpsizes[index] >> (mask_index *4 )) &0xf ; - old_mask =slice_mask_for_size (mm, old_psize); + old_mask =slice_mask_for_size (&mm->context, old_psize);__clear_bit (i, old_mask->high_slices);__set_bit (i, psize_mask->high_slices);@@ -538,7 +538,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,/* First make up a "good" mask of slices that have the right size * already */ - maskp =slice_mask_for_size (mm, psize); + maskp =slice_mask_for_size (&mm->context, psize);/* * Here "good" means slices that are already the right page size, @@ -565,7 +565,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,* a pointer to good mask for the next code to use. */ if (IS_ENABLED (CONFIG_PPC_64K_PAGES ) && psize ==MMU_PAGE_64K ) { - compat_maskp =slice_mask_for_size (mm,MMU_PAGE_4K ); + compat_maskp =slice_mask_for_size (&mm->context,MMU_PAGE_4K );if (fixed)slice_or_mask (&good_mask, maskp, compat_maskp);else @@ -760,7 +760,7 @@ void slice_init_new_context_exec(struct mm_struct *mm)/* * Slice mask cache starts zeroed, fill the default size cache. */ - mask =slice_mask_for_size (mm, psize); + mask =slice_mask_for_size (&mm->context, psize); mask->low_slices = ~0UL ;if (SLICE_NUM_HIGH )bitmap_fill (mask->high_slices,SLICE_NUM_HIGH );@@ -819,14 +819,14 @@ int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,VM_BUG_ON (radix_enabled ()); - maskp =slice_mask_for_size (mm, psize); + maskp =slice_mask_for_size (&mm->context, psize);#ifdef CONFIG_PPC_64K_PAGES /* We need to account for 4k slices too */ if (psize ==MMU_PAGE_64K ) {const struct slice_mask *compat_maskp;struct slice_mask available; - compat_maskp =slice_mask_for_size (mm,MMU_PAGE_4K ); + compat_maskp =slice_mask_for_size (&mm->context,MMU_PAGE_4K );slice_or_mask (&available, maskp, compat_maskp);return !slice_check_range_fits (mm, &available, addr, len); }Signature · 1 line
2.13.3
PATCH v2 4/11 powerpc/mm: move slice_mask_for_size() into mmu.h
In reply to Christophe LeroyMove slice_mask_for_size() into subarch mmu.h
At the same time, replace BUG() by VM_BUG_ON() as those BUG() are not there to catch runtime errors but to catch errors during development cycle only.
--- arch/powerpc/include/asm/book3s/64/mmu.h | 17 +++++++++++ arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 42 +++++++++++++++++++--------- arch/powerpc/mm/slice.c | 34 ---------------------- 3 files changed, 46 insertions(+), 47 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +17 -0
@@ -203,6 +203,23 @@ static inline struct slice_mask *mm_ctx_slice_mask_16g(mm_context_t *ctx) }#endif +static inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) +{ +#ifdef CONFIG_PPC_64K_PAGES +if (psize ==MMU_PAGE_64K ) +return mm_ctx_slice_mask_64k (&ctx); +#endif +#ifdef CONFIG_HUGETLB_PAGE +if (psize ==MMU_PAGE_16M ) +return mm_ctx_slice_mask_16m (&ctx); +if (psize ==MMU_PAGE_16G ) +return mm_ctx_slice_mask_16g (&ctx); +#endif +VM_BUG_ON (psize !=MMU_PAGE_4K ); + +return mm_ctx_slice_mask_4k (&ctx); +} +#ifdef CONFIG_PPC_SUBPAGE_PROT static inline struct subpage_prot_table *mm_ctx_subpage_prot (mm_context_t *ctx) {
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +29 -13
59 lines not on this page · raw message
arch/powerpc/mm/slice.c +0 -34
@@ -150,40 +150,6 @@ static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret,__set_bit (i, ret->high_slices); } -#ifdef CONFIG_PPC_BOOK3S_64 -static struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) -{ -#ifdef CONFIG_PPC_64K_PAGES -if (psize ==MMU_PAGE_64K ) -return mm_ctx_slice_mask_64k (&ctx); -#endif -if (psize ==MMU_PAGE_4K ) -return mm_ctx_slice_mask_4k (&ctx); -#ifdef CONFIG_HUGETLB_PAGE -if (psize ==MMU_PAGE_16M ) -return mm_ctx_slice_mask_16m (&ctx); -if (psize ==MMU_PAGE_16G ) -return mm_ctx_slice_mask_16g (&ctx); -#endif -BUG (); -} -#elif defined(CONFIG_PPC_8xx) -static struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) -{ -if (psize == mmu_virtual_psize) -return &ctx->mask_base_psize; -#ifdef CONFIG_HUGETLB_PAGE -if (psize ==MMU_PAGE_512K ) -return &ctx->mask_512k; -if (psize ==MMU_PAGE_8M ) -return &ctx->mask_8m; -#endif -BUG (); -} -#else -#error "Must define the slice masks for page sizes supported by the platform" -#endif -static bool slice_check_range_fits (struct mm_struct *mm,const struct slice_mask *available,unsigned long start,unsigned long len)
Signature · 1 line
2.13.3
Re: [PATCH v2 04/11] powerpc/mm: move slice_mask_for_size() into mmu.h
Quoted 6 lines · Christophe Leroy
Move
slice_mask_for_size()into subarchmmu.hAt the same time, replace
BUG()byVM_BUG_ON()as thoseBUG()are not there to catch runtime errors but to catch errors during development cycle only.
Quoted 148 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/include/asm/book3s/64/mmu.h | 17 +++++++++++ arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 42 +++++++++++++++++++--------- arch/powerpc/mm/slice.c | 34 ---------------------- 3 files changed, 46 insertions(+), 47 deletions(-)arch/powerpc/include/asm/book3s/64/mmu.h +17
-0@@ -203,6 +203,23 @@ static inline struct slice_mask *mm_ctx_slice_mask_16g(mm_context_t *ctx) }#endif +static inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) +{ +#ifdef CONFIG_PPC_64K_PAGES +if (psize ==MMU_PAGE_64K ) +return mm_ctx_slice_mask_64k (&ctx); +#endif +#ifdef CONFIG_HUGETLB_PAGE +if (psize ==MMU_PAGE_16M ) +return mm_ctx_slice_mask_16m (&ctx); +if (psize ==MMU_PAGE_16G ) +return mm_ctx_slice_mask_16g (&ctx); +#endif +VM_BUG_ON (psize !=MMU_PAGE_4K ); + +return mm_ctx_slice_mask_4k (&ctx); +} +#ifdef CONFIG_PPC_SUBPAGE_PROT static inline struct subpage_prot_table *mm_ctx_subpage_prot (mm_context_t *ctx) {arch/powerpc/include/asm/nohash/32/mmu-8xx.h +29
-13@@ -184,7 +184,23 @@#define LOW_SLICE_ARRAY_SZ SLICE_ARRAY_SIZE#endif +#if defined(CONFIG_PPC_4K_PAGES ) +#define mmu_virtual_psize MMU_PAGE_4K +#elif defined(CONFIG_PPC_16K_PAGES ) +#define mmu_virtual_psize MMU_PAGE_16K +#define PTE_FRAG_NR 4 +#define PTE_FRAG_SIZE_SHIFT 12 +#define PTE_FRAG_SIZE (1UL << 12) +#else +#error "Unsupported PAGE_SIZE" +#endif + +#define mmu_linear_psize MMU_PAGE_8M + #ifndef __ASSEMBLY__ + +#include <linux/mmdebug.h> + struct slice_mask { u64 low_slices; DECLARE_BITMAP(high_slices, 0);@@ -255,6 +271,19 @@ static inline struct slice_mask *mm_ctx_slice_mask_8m(mm_context_t *ctx)return &ctx->mask_8m; }#endif + +static inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) +{ +#ifdef CONFIG_HUGETLB_PAGE +if (psize ==MMU_PAGE_512K ) +return &ctx->mask_512k; +if (psize ==MMU_PAGE_8M ) +return &ctx->mask_8m; +#endif +VM_BUG_ON (psize != mmu_virtual_psize); + +return &ctx->mask_base_psize; +}#endif /* CONFIG_PPC_MM_SLICE */ #define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000)@@ -306,17 +335,4 @@ extern s32 patch__itlbmiss_perf, patch__dtlbmiss_perf;#endif /* !__ASSEMBLY__ */ -#if defined(CONFIG_PPC_4K_PAGES ) -#define mmu_virtual_psize MMU_PAGE_4K -#elif defined(CONFIG_PPC_16K_PAGES ) -#define mmu_virtual_psize MMU_PAGE_16K -#define PTE_FRAG_NR 4 -#define PTE_FRAG_SIZE_SHIFT 12 -#define PTE_FRAG_SIZE (1UL << 12) -#else -#error "Unsupported PAGE_SIZE" -#endif - -#define mmu_linear_psize MMU_PAGE_8M -#endif /* _ASM_POWERPC_MMU_8XX_H_ */ arch/powerpc/mm/slice.c +0
-34@@ -150,40 +150,6 @@ static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret,__set_bit (i, ret->high_slices); } -#ifdef CONFIG_PPC_BOOK3S_64 -static struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) -{ -#ifdef CONFIG_PPC_64K_PAGES -if (psize ==MMU_PAGE_64K ) -return mm_ctx_slice_mask_64k (&ctx); -#endif -if (psize ==MMU_PAGE_4K ) -return mm_ctx_slice_mask_4k (&ctx); -#ifdef CONFIG_HUGETLB_PAGE -if (psize ==MMU_PAGE_16M ) -return mm_ctx_slice_mask_16m (&ctx); -if (psize ==MMU_PAGE_16G ) -return mm_ctx_slice_mask_16g (&ctx); -#endif -BUG (); -} -#elif defined(CONFIG_PPC_8xx) -static struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) -{ -if (psize == mmu_virtual_psize) -return &ctx->mask_base_psize; -#ifdef CONFIG_HUGETLB_PAGE -if (psize ==MMU_PAGE_512K ) -return &ctx->mask_512k; -if (psize ==MMU_PAGE_8M ) -return &ctx->mask_8m; -#endif -BUG (); -} -#else -#error "Must define the slice masks for page sizes supported by the platform" -#endif -static bool slice_check_range_fits (struct mm_struct *mm,const struct slice_mask *available,unsigned long start,unsigned long len)Signature · 1 line
2.13.3
PATCH v2 5/11 powerpc/mm: get rid of mm_ctx_slice_mask_xxx()
In reply to Christophe LeroyNow that slice_mask_for_size() is in mmu.h, the mm_ctx_slice_mask_xxx() are not needed anymore, so drop them. Note that the 8xx ones where not used anyway.
--- arch/powerpc/include/asm/book3s/64/mmu.h | 32 ++++------------------------ arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 17 --------------- 2 files changed, 4 insertions(+), 45 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +4 -28
@@ -179,45 +179,21 @@ static inline void mm_ctx_set_slb_addr_limit(mm_context_t *ctx, unsigned long li ctx->hash_context->slb_addr_limit = limit; } -#ifdef CONFIG_PPC_64K_PAGES -static inline struct slice_mask *mm_ctx_slice_mask_64k (mm_context_t *ctx) -{ -return &ctx->hash_context->mask_64k; -} -#endif - -static inline struct slice_mask *mm_ctx_slice_mask_4k (mm_context_t *ctx) -{ -return &ctx->hash_context->mask_4k; -} - -#ifdef CONFIG_HUGETLB_PAGE -static inline struct slice_mask *mm_ctx_slice_mask_16m (mm_context_t *ctx) -{ -return &ctx->hash_context->mask_16m; -} - -static inline struct slice_mask *mm_ctx_slice_mask_16g (mm_context_t *ctx) -{ -return &ctx->hash_context->mask_16g; -} -#endif -static inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) {#ifdef CONFIG_PPC_64K_PAGES if (psize ==MMU_PAGE_64K ) -return mm_ctx_slice_mask_64k (&ctx); +return &ctx->hash_context->mask_64k;#endif #ifdef CONFIG_HUGETLB_PAGE if (psize ==MMU_PAGE_16M ) -return mm_ctx_slice_mask_16m (&ctx); +return &ctx->hash_context->mask_16m;if (psize ==MMU_PAGE_16G ) -return mm_ctx_slice_mask_16g (&ctx); +return &ctx->hash_context->mask_16g;#endif VM_BUG_ON (psize !=MMU_PAGE_4K ); -return mm_ctx_slice_mask_4k (&ctx); +return &ctx->hash_context->mask_4k; }#ifdef CONFIG_PPC_SUBPAGE_PROT
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +0 -17
@@ -255,23 +255,6 @@ static inline void mm_ctx_set_slb_addr_limit(mm_context_t *ctx, unsigned long li ctx->slb_addr_limit = limit; } -static inline struct slice_mask *mm_ctx_slice_mask_base (mm_context_t *ctx) -{ -return &ctx->mask_base_psize; -} - -#ifdef CONFIG_HUGETLB_PAGE -static inline struct slice_mask *mm_ctx_slice_mask_512k (mm_context_t *ctx) -{ -return &ctx->mask_512k; -} - -static inline struct slice_mask *mm_ctx_slice_mask_8m (mm_context_t *ctx) -{ -return &ctx->mask_8m; -} -#endif -static inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) {#ifdef CONFIG_HUGETLB_PAGE
Signature · 1 line
2.13.3
Re: [PATCH v2 05/11] powerpc/mm: get rid of mm_ctx_slice_mask_xxx()
Quoted 4 lines · Christophe Leroy
Now that
slice_mask_for_size()is inmmu.h, themm_ctx_slice_mask_xxx()are not needed anymore, so drop them. Note that the 8xx ones where not used anyway.
Quoted 90 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/include/asm/book3s/64/mmu.h | 32 ++++------------------------ arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 17 --------------- 2 files changed, 4 insertions(+), 45 deletions(-)arch/powerpc/include/asm/book3s/64/mmu.h +4
-28@@ -179,45 +179,21 @@ static inline void mm_ctx_set_slb_addr_limit(mm_context_t *ctx, unsigned long li ctx->hash_context->slb_addr_limit = limit; } -#ifdef CONFIG_PPC_64K_PAGES -static inline struct slice_mask *mm_ctx_slice_mask_64k (mm_context_t *ctx) -{ -return &ctx->hash_context->mask_64k; -} -#endif - -static inline struct slice_mask *mm_ctx_slice_mask_4k (mm_context_t *ctx) -{ -return &ctx->hash_context->mask_4k; -} - -#ifdef CONFIG_HUGETLB_PAGE -static inline struct slice_mask *mm_ctx_slice_mask_16m (mm_context_t *ctx) -{ -return &ctx->hash_context->mask_16m; -} - -static inline struct slice_mask *mm_ctx_slice_mask_16g (mm_context_t *ctx) -{ -return &ctx->hash_context->mask_16g; -} -#endif -static inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) {#ifdef CONFIG_PPC_64K_PAGES if (psize ==MMU_PAGE_64K ) -return mm_ctx_slice_mask_64k (&ctx); +return &ctx->hash_context->mask_64k;#endif #ifdef CONFIG_HUGETLB_PAGE if (psize ==MMU_PAGE_16M ) -return mm_ctx_slice_mask_16m (&ctx); +return &ctx->hash_context->mask_16m;if (psize ==MMU_PAGE_16G ) -return mm_ctx_slice_mask_16g (&ctx); +return &ctx->hash_context->mask_16g;#endif VM_BUG_ON (psize !=MMU_PAGE_4K ); -return mm_ctx_slice_mask_4k (&ctx); +return &ctx->hash_context->mask_4k; }#ifdef CONFIG_PPC_SUBPAGE_PROT arch/powerpc/include/asm/nohash/32/mmu-8xx.h +0
-17@@ -255,23 +255,6 @@ static inline void mm_ctx_set_slb_addr_limit(mm_context_t *ctx, unsigned long li ctx->slb_addr_limit = limit; } -static inline struct slice_mask *mm_ctx_slice_mask_base (mm_context_t *ctx) -{ -return &ctx->mask_base_psize; -} - -#ifdef CONFIG_HUGETLB_PAGE -static inline struct slice_mask *mm_ctx_slice_mask_512k (mm_context_t *ctx) -{ -return &ctx->mask_512k; -} - -static inline struct slice_mask *mm_ctx_slice_mask_8m (mm_context_t *ctx) -{ -return &ctx->mask_8m; -} -#endif -static inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) {#ifdef CONFIG_HUGETLB_PAGE Signature · 1 line
2.13.3
PATCH v2 6/11 powerpc/mm: remove unnecessary #ifdef CONFIG_PPC64
In reply to Christophe LeroyFor PPC32 that's a noop, gcc should be smart enough to ignore it.
--- arch/powerpc/mm/slice.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/powerpc/mm/slice.c +1 -3
@@ -118,13 +118,11 @@ static int slice_high_has_vma(struct mm_struct *mm, unsigned long slice)unsigned long start = slice <<SLICE_HIGH_SHIFT ;unsigned long end = start + (1ul <<SLICE_HIGH_SHIFT ); -#ifdef CONFIG_PPC64 /* Hack, so that each addresses is controlled by exactly one * of the high or low area bitmaps, the first high area starts * at 4GB, not 0 */ if (start ==0 ) - start =SLICE_LOW_TOP ; -#endif + start = (unsigned long )SLICE_LOW_TOP ;return !slice_area_is_free (mm, start, end - start); }
Signature · 1 line
2.13.3
PATCH v2 7/11 powerpc/mm: remove a couple of #ifdef CONFIG_PPC_64K_PAGES in mm/slice.c
In reply to Christophe LeroyThis patch replaces a couple of #ifdef CONFIG_PPC_64K_PAGES by IS_ENABLED(CONFIG_PPC_64K_PAGES) to improve code maintainability.
--- arch/powerpc/mm/slice.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/powerpc/mm/slice.c +4 -6
@@ -606,14 +606,13 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, newaddr =slice_find_area (mm, len, &potential_mask, psize, topdown, high_limit); -#ifdef CONFIG_PPC_64K_PAGES -if (newaddr == -ENOMEM && psize ==MMU_PAGE_64K ) { +if (IS_ENABLED (CONFIG_PPC_64K_PAGES ) && newaddr == -ENOMEM && + psize ==MMU_PAGE_64K ) {/* retry the search with 4k-page slices included */ slice_or_mask (&potential_mask, &potential_mask, compat_maskp); newaddr =slice_find_area (mm, len, &potential_mask, psize, topdown, high_limit); } -#endif if (newaddr == -ENOMEM )return -ENOMEM ;
@@ -784,9 +783,9 @@ int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,VM_BUG_ON (radix_enabled ()); maskp =slice_mask_for_size (&mm->context, psize); -#ifdef CONFIG_PPC_64K_PAGES +/* We need to account for 4k slices too */ -if (psize ==MMU_PAGE_64K ) { +if (IS_ENABLED (CONFIG_PPC_64K_PAGES ) && psize ==MMU_PAGE_64K ) {const struct slice_mask *compat_maskp;struct slice_mask available;
@@ -794,7 +793,6 @@ int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,slice_or_mask (&available, maskp, compat_maskp);return !slice_check_range_fits (mm, &available, addr, len); } -#endif return !slice_check_range_fits (mm, maskp, addr, len); }
Signature · 1 line
2.13.3
Re: [PATCH v2 07/11] powerpc/mm: remove a couple of #ifdef CONFIG_PPC_64K_PAGES in mm/slice.c
Quoted 3 lines · Christophe Leroy
This patch replaces a couple of #ifdef
CONFIG_PPC_64K_PAGESbyIS_ENABLED(CONFIG_PPC_64K_PAGES)to improve code maintainability.
Quoted 48 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/mm/slice.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)arch/powerpc/mm/slice.c +4
-6@@ -606,14 +606,13 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, newaddr =slice_find_area (mm, len, &potential_mask, psize, topdown, high_limit); -#ifdef CONFIG_PPC_64K_PAGES -if (newaddr == -ENOMEM && psize ==MMU_PAGE_64K ) { +if (IS_ENABLED (CONFIG_PPC_64K_PAGES ) && newaddr == -ENOMEM && + psize ==MMU_PAGE_64K ) {/* retry the search with 4k-page slices included */ slice_or_mask (&potential_mask, &potential_mask, compat_maskp); newaddr =slice_find_area (mm, len, &potential_mask, psize, topdown, high_limit); } -#endif if (newaddr == -ENOMEM )return -ENOMEM ;@@ -784,9 +783,9 @@ int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,VM_BUG_ON (radix_enabled ()); maskp =slice_mask_for_size (&mm->context, psize); -#ifdef CONFIG_PPC_64K_PAGES +/* We need to account for 4k slices too */ -if (psize ==MMU_PAGE_64K ) { +if (IS_ENABLED (CONFIG_PPC_64K_PAGES ) && psize ==MMU_PAGE_64K ) {const struct slice_mask *compat_maskp;struct slice_mask available;@@ -794,7 +793,6 @@ int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,slice_or_mask (&available, maskp, compat_maskp);return !slice_check_range_fits (mm, &available, addr, len); } -#endif return !slice_check_range_fits (mm, maskp, addr, len); }Signature · 1 line
2.13.3
PATCH v2 8/11 powerpc/8xx: get rid of #ifdef CONFIG_HUGETLB_PAGE for slices
In reply to Christophe LeroyThe 8xx only selects CONFIG_PPC_MM_SLICES when CONFIG_HUGETLB_PAGE is set.
--- arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 4 ---- 1 file changed, 4 deletions(-)
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +0 -4
@@ -216,10 +216,8 @@ typedef struct {unsigned char high_slices_psize[0 ];unsigned long slb_addr_limit;struct slice_mask mask_base_psize;/* 4k or 16k */ -# ifdef CONFIG_HUGETLB_PAGE struct slice_mask mask_512k;struct slice_mask mask_8m; -# endif #endif void *pte_frag; } mm_context_t;
@@ -257,12 +255,10 @@ static inline void mm_ctx_set_slb_addr_limit(mm_context_t *ctx, unsigned long listatic inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) { -#ifdef CONFIG_HUGETLB_PAGE if (psize ==MMU_PAGE_512K )return &ctx->mask_512k;if (psize ==MMU_PAGE_8M )return &ctx->mask_8m; -#endif VM_BUG_ON (psize != mmu_virtual_psize);return &ctx->mask_base_psize;
Signature · 1 line
2.13.3
PATCH v2 9/11 powerpc/mm: define get_slice_psize() all the time
In reply to Christophe Leroyget_slice_psize() can be defined regardless of CONFIG_PPC_MM_SLICES to avoid ifdefs
--- arch/powerpc/include/asm/slice.h | 5 +++++ arch/powerpc/mm/hugetlbpage.c | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/slice.h +5 -0
@@ -36,6 +36,11 @@ void slice_setup_new_exec(void);static inline void slice_init_new_context_exec (struct mm_struct *mm) {} +static inline unsigned int get_slice_psize (struct mm_struct *mm,unsigned long addr) +{ +return 0 ; +} +#endif /* CONFIG_PPC_MM_SLICES */ #endif /* __ASSEMBLY__ */
arch/powerpc/mm/hugetlbpage.c +1 -3
@@ -578,14 +578,12 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,unsigned long vma_mmu_pagesize (struct vm_area_struct *vma) { -#ifdef CONFIG_PPC_MM_SLICES /* With radix we don't use slice, so derive it from vma*/ -if (!radix_enabled ()) { +if (IS_ENABLED (CONFIG_PPC_MM_SLICES ) && !radix_enabled ()) {unsigned int psize =get_slice_psize (vma->vm_mm, vma->vm_start);return 1UL <<mmu_psize_to_shift (psize); } -#endif return vma_kernel_pagesize (vma); }
Signature · 1 line
2.13.3
Re: [PATCH v2 09/11] powerpc/mm: define get_slice_psize() all the time
Quoted 3 lines · Christophe Leroy
get_slice_psize()can be defined regardless ofCONFIG_PPC_MM_SLICESto avoid ifdefs
Quoted 44 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/include/asm/slice.h | 5 +++++ arch/powerpc/mm/hugetlbpage.c | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-)arch/powerpc/include/asm/slice.h +5
-0@@ -36,6 +36,11 @@ void slice_setup_new_exec(void);static inline void slice_init_new_context_exec (struct mm_struct *mm) {} +static inline unsigned int get_slice_psize (struct mm_struct *mm,unsigned long addr) +{ +return 0 ; +} +#endif /* CONFIG_PPC_MM_SLICES */ #endif /* __ASSEMBLY__ */ arch/powerpc/mm/hugetlbpage.c +1
-3@@ -578,14 +578,12 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,unsigned long vma_mmu_pagesize (struct vm_area_struct *vma) { -#ifdef CONFIG_PPC_MM_SLICES /* With radix we don't use slice, so derive it from vma*/ -if (!radix_enabled ()) { +if (IS_ENABLED (CONFIG_PPC_MM_SLICES ) && !radix_enabled ()) {unsigned int psize =get_slice_psize (vma->vm_mm, vma->vm_start);return 1UL <<mmu_psize_to_shift (psize); } -#endif return vma_kernel_pagesize (vma); }Signature · 1 line
2.13.3
PATCH v2 10/11 powerpc/mm: define subarch SLB_ADDR_LIMIT_DEFAULT
In reply to Christophe LeroyThis patch defines a subarch specific SLB_ADDR_LIMIT_DEFAULT to remove the #ifdefs around the setup of mm->context.slb_addr_limit
It also generalises the use of mm_ctx_set_slb_addr_limit() helper.
--- arch/powerpc/include/asm/book3s/64/slice.h | 2 ++ arch/powerpc/include/asm/nohash/32/slice.h | 2 ++ arch/powerpc/mm/hash_utils_64.c | 2 +- arch/powerpc/mm/slice.c | 6 +----- arch/powerpc/mm/tlb_nohash.c | 4 +--- 5 files changed, 7 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/book3s/64/slice.h +2 -0
@@ -11,4 +11,6 @@#define SLICE_NUM_HIGH (H_PGTABLE_RANGE >> SLICE_HIGH_SHIFT)#define GET_HIGH_SLICE_INDEX (addr) ((addr) >> SLICE_HIGH_SHIFT) +#define SLB_ADDR_LIMIT_DEFAULT DEFAULT_MAP_WINDOW_USER64 +#endif /* _ASM_POWERPC_BOOK3S_64_SLICE_H */
arch/powerpc/include/asm/nohash/32/slice.h +2 -0
@@ -13,6 +13,8 @@#define SLICE_NUM_HIGH 0ul#define GET_HIGH_SLICE_INDEX (addr) (addr & 0) +#define SLB_ADDR_LIMIT_DEFAULT DEFAULT_MAP_WINDOW +#endif /* CONFIG_PPC_MM_SLICES */ #endif /* _ASM_POWERPC_NOHASH_32_SLICE_H */
arch/powerpc/mm/hash_utils_64.c +1 -1
@@ -1050,7 +1050,7 @@ void __init hash__early_init_mmu(void)htab_initialize (); init_mm.context.hash_context = &init_hash_mm_context; - init_mm.context.hash_context->slb_addr_limit =DEFAULT_MAP_WINDOW_USER64 ; +mm_ctx_set_slb_addr_limit (&init_mm.context,SLB_ADDR_LIMIT_DEFAULT );pr_info ("Initializing hash mmu with SLB\n" );/* Initialize SLB management */
arch/powerpc/mm/slice.c +1 -5
@@ -704,11 +704,7 @@ void slice_init_new_context_exec(struct mm_struct *mm)* case of fork it is just inherited from the mm being * duplicated. */ -#ifdef CONFIG_PPC64 -mm_ctx_set_slb_addr_limit (&mm->context,DEFAULT_MAP_WINDOW_USER64 ); -#else - mm->context.slb_addr_limit =DEFAULT_MAP_WINDOW ; -#endif +mm_ctx_set_slb_addr_limit (&mm->context,SLB_ADDR_LIMIT_DEFAULT );mm_ctx_set_user_psize (&mm->context, psize);/*
arch/powerpc/mm/tlb_nohash.c +1 -3
@@ -802,9 +802,7 @@ void __init early_init_mmu(void)#endif #ifdef CONFIG_PPC_MM_SLICES -#if defined(CONFIG_PPC_8xx) - init_mm.context.slb_addr_limit =DEFAULT_MAP_WINDOW ; -#endif +mm_ctx_set_slb_addr_limit (&init_mm.context,SLB_ADDR_LIMIT_DEFAULT ); #endif }#endif /* CONFIG_PPC64 */
Signature · 1 line
2.13.3
Re: [PATCH v2 10/11] powerpc/mm: define subarch SLB_ADDR_LIMIT_DEFAULT
Quoted 5 lines · Christophe Leroy
This patch defines a subarch specific
SLB_ADDR_LIMIT_DEFAULTto remove the #ifdefs around the setup ofmm->context.slb_addr_limitIt also generalises the use of
mm_ctx_set_slb_addr_limit()helper.
Quoted 80 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/include/asm/book3s/64/slice.h | 2 ++ arch/powerpc/include/asm/nohash/32/slice.h | 2 ++ arch/powerpc/mm/hash_utils_64.c | 2 +- arch/powerpc/mm/slice.c | 6 +----- arch/powerpc/mm/tlb_nohash.c | 4 +--- 5 files changed, 7 insertions(+), 9 deletions(-)arch/powerpc/include/asm/book3s/64/slice.h +2
-0@@ -11,4 +11,6 @@#define SLICE_NUM_HIGH (H_PGTABLE_RANGE >> SLICE_HIGH_SHIFT)#define GET_HIGH_SLICE_INDEX (addr) ((addr) >> SLICE_HIGH_SHIFT) +#define SLB_ADDR_LIMIT_DEFAULT DEFAULT_MAP_WINDOW_USER64 +#endif /* _ASM_POWERPC_BOOK3S_64_SLICE_H */ arch/powerpc/include/asm/nohash/32/slice.h +2
-0@@ -13,6 +13,8 @@#define SLICE_NUM_HIGH 0ul#define GET_HIGH_SLICE_INDEX (addr) (addr & 0) +#define SLB_ADDR_LIMIT_DEFAULT DEFAULT_MAP_WINDOW +#endif /* CONFIG_PPC_MM_SLICES */ #endif /* _ASM_POWERPC_NOHASH_32_SLICE_H */ arch/powerpc/mm/hash_utils_64.c +1
-1@@ -1050,7 +1050,7 @@ void __init hash__early_init_mmu(void)htab_initialize (); init_mm.context.hash_context = &init_hash_mm_context; - init_mm.context.hash_context->slb_addr_limit =DEFAULT_MAP_WINDOW_USER64 ; +mm_ctx_set_slb_addr_limit (&init_mm.context,SLB_ADDR_LIMIT_DEFAULT );pr_info ("Initializing hash mmu with SLB\n" );/* Initialize SLB management */ arch/powerpc/mm/slice.c +1
-5@@ -704,11 +704,7 @@ void slice_init_new_context_exec(struct mm_struct *mm)* case of fork it is just inherited from the mm being * duplicated. */ -#ifdef CONFIG_PPC64 -mm_ctx_set_slb_addr_limit (&mm->context,DEFAULT_MAP_WINDOW_USER64 ); -#else - mm->context.slb_addr_limit =DEFAULT_MAP_WINDOW ; -#endif +mm_ctx_set_slb_addr_limit (&mm->context,SLB_ADDR_LIMIT_DEFAULT );mm_ctx_set_user_psize (&mm->context, psize);/* arch/powerpc/mm/tlb_nohash.c +1
-3@@ -802,9 +802,7 @@ void __init early_init_mmu(void)#endif #ifdef CONFIG_PPC_MM_SLICES -#if defined(CONFIG_PPC_8xx) - init_mm.context.slb_addr_limit =DEFAULT_MAP_WINDOW ; -#endif +mm_ctx_set_slb_addr_limit (&init_mm.context,SLB_ADDR_LIMIT_DEFAULT ); #endif }#endif /* CONFIG_PPC64 */ Signature · 1 line
2.13.3
PATCH v2 11/11 powerpc/mm: drop slice DEBUG
In reply to Christophe Leroyslice is now an improved functionnality. Drop the DEBUG stuff.
--- arch/powerpc/mm/slice.c | 62 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 58 deletions(-)
arch/powerpc/mm/slice.c +4 -58
@@ -41,28 +41,6 @@static DEFINE_SPINLOCK (slice_convert_lock); -#ifdef DEBUG -int _slice_debug =1 ; - -static void slice_print_mask (const char *label,const struct slice_mask *mask) -{ -if (!_slice_debug) -return ; -pr_devel ("%s low_slice: %*pbl\n" , label, - (int )SLICE_NUM_LOW , &mask->low_slices); -pr_devel ("%s high_slice: %*pbl\n" , label, - (int )SLICE_NUM_HIGH , mask->high_slices); -} - -#define slice_dbg(fmt...) do { if (_slice_debug) pr_devel(fmt); } while (0) - -#else - -static void slice_print_mask (const char *label,const struct slice_mask *mask) {} -#define slice_dbg(fmt...) - -#endif -static inline bool slice_addr_is_low (unsigned long addr) {u64 tmp = (u64 )addr;
@@ -207,9 +185,6 @@ static void slice_convert(struct mm_struct *mm,unsigned long i, flags;int old_psize; -slice_dbg ("slice_convert(mm=%p, psize=%d)\n" , mm, psize); -slice_print_mask (" mask" , mask); - psize_mask =slice_mask_for_size (&mm->context, psize);/* We need to use a spinlock here to protect against
@@ -255,10 +230,6 @@ static void slice_convert(struct mm_struct *mm, (((unsigned long )psize) << (mask_index *4 )); } -slice_dbg (" lsps=%lx, hsps=%lx\n" , - (unsigned long )mm_ctx_low_slices (&mm->context), - (unsigned long )mm_ctx_high_slices (&mm->context)); -spin_unlock_irqrestore (&slice_convert_lock, flags);copro_flush_all_slbs (mm);
@@ -485,14 +456,9 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,BUG_ON (mm_ctx_slb_addr_limit (&mm->context) ==0 );VM_BUG_ON (radix_enabled ()); -slice_dbg ("slice_get_unmapped_area(mm=%p, psize=%d...\n" , mm, psize); -slice_dbg (" addr=%lx, len=%lx, flags=%lx, topdown=%d\n" , - addr, len, flags, topdown); -/* If hint, make sure it matches our alignment restrictions */ if (!fixed && addr) { addr =_ALIGN_UP (addr, page_size); -slice_dbg (" aligned addr=%lx\n" , addr);/* Ignore hint if it's too large or overlaps a VMA */ if (addr > high_limit - len || addr < mmap_min_addr || !slice_area_is_free (mm, addr, len))
@@ -538,17 +504,12 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,slice_copy_mask (&good_mask, maskp); } -slice_print_mask (" good_mask" , &good_mask); -if (compat_maskp) -slice_print_mask (" compat_mask" , compat_maskp); -/* First check hint if it's valid or if we have MAP_FIXED */ if (addr !=0 || fixed) {/* Check if we fit in the good mask. If we do, we just return, * nothing else to do */ if (slice_check_range_fits (mm, &good_mask, addr, len)) { -slice_dbg (" fits good !\n" ); newaddr = addr; goto return_addr; }
@@ -558,13 +519,10 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,*/ newaddr =slice_find_area (mm, len, &good_mask, psize, topdown, high_limit); -if (newaddr != -ENOMEM ) { -/* Found within the good mask, we don't have to setup, -* we thus return directly -*/ -slice_dbg (" found area at 0x%lx\n" , newaddr); + +/* Found within good mask, don't have to setup, thus return directly */ +if (newaddr != -ENOMEM ) goto return_addr; - } }/* * We don't fit in the good mask, check what other slices are
@@ -572,11 +530,9 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,*/ slice_mask_for_free (mm, &potential_mask, high_limit);slice_or_mask (&potential_mask, &potential_mask, &good_mask); -slice_print_mask (" potential" , &potential_mask);if (addr !=0 || fixed) {if (slice_check_range_fits (mm, &potential_mask, addr, len)) { -slice_dbg (" fits potential !\n" ); newaddr = addr; goto convert; }
@@ -586,18 +542,14 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,if (fixed)return -EBUSY ; -slice_dbg (" search...\n" ); -/* If we had a hint that didn't work out, see if we can fit * anywhere in the good area. */ if (addr) { newaddr =slice_find_area (mm, len, &good_mask, psize, topdown, high_limit); -if (newaddr != -ENOMEM ) { -slice_dbg (" found area at 0x%lx\n" , newaddr); +if (newaddr != -ENOMEM ) goto return_addr; - } }/* Now let's see if we can find something in the existing slices
@@ -618,8 +570,6 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,return -ENOMEM ;slice_range_to_mask (newaddr, len, &potential_mask); -slice_dbg (" found potential area at 0x%lx\n" , newaddr); -slice_print_mask (" mask" , &potential_mask); convert:/*
@@ -697,8 +647,6 @@ void slice_init_new_context_exec(struct mm_struct *mm)struct slice_mask *mask;unsigned int psize = mmu_virtual_psize; -slice_dbg ("slice_init_new_context_exec(mm=%p)\n" , mm); -/* * In the case of exec, use the default limit. In the * case of fork it is just inherited from the mm being
@@ -730,8 +678,6 @@ void slice_setup_new_exec(void) {struct mm_struct *mm = current->mm; -slice_dbg ("slice_setup_new_exec(mm=%p)\n" , mm); -if (!is_32bit_task ())return ;
Signature · 1 line
2.13.3
Re: [PATCH v2 11/11] powerpc/mm: drop slice DEBUG
Quoted 2 lines · Christophe Leroy
slice is now an improved functionnality. Drop the DEBUG stuff.
I would like to keep that. I helped a lot when moving address ranges and it should not have any runtime impact.
Quoted 170 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/mm/slice.c | 62 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 58 deletions(-)arch/powerpc/mm/slice.c +4
-58@@ -41,28 +41,6 @@static DEFINE_SPINLOCK (slice_convert_lock); -#ifdef DEBUG -int _slice_debug =1 ; - -static void slice_print_mask (const char *label,const struct slice_mask *mask) -{ -if (!_slice_debug) -return ; -pr_devel ("%s low_slice: %*pbl\n" , label, - (int )SLICE_NUM_LOW , &mask->low_slices); -pr_devel ("%s high_slice: %*pbl\n" , label, - (int )SLICE_NUM_HIGH , mask->high_slices); -} - -#define slice_dbg(fmt...) do { if (_slice_debug) pr_devel(fmt); } while (0) - -#else - -static void slice_print_mask (const char *label,const struct slice_mask *mask) {} -#define slice_dbg(fmt...) - -#endif -static inline bool slice_addr_is_low (unsigned long addr) {u64 tmp = (u64 )addr;@@ -207,9 +185,6 @@ static void slice_convert(struct mm_struct *mm,unsigned long i, flags;int old_psize; -slice_dbg ("slice_convert(mm=%p, psize=%d)\n" , mm, psize); -slice_print_mask (" mask" , mask); - psize_mask =slice_mask_for_size (&mm->context, psize);/* We need to use a spinlock here to protect against @@ -255,10 +230,6 @@ static void slice_convert(struct mm_struct *mm, (((unsigned long )psize) << (mask_index *4 )); } -slice_dbg (" lsps=%lx, hsps=%lx\n" , - (unsigned long )mm_ctx_low_slices (&mm->context), - (unsigned long )mm_ctx_high_slices (&mm->context)); -spin_unlock_irqrestore (&slice_convert_lock, flags);copro_flush_all_slbs (mm);@@ -485,14 +456,9 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,BUG_ON (mm_ctx_slb_addr_limit (&mm->context) ==0 );VM_BUG_ON (radix_enabled ()); -slice_dbg ("slice_get_unmapped_area(mm=%p, psize=%d...\n" , mm, psize); -slice_dbg (" addr=%lx, len=%lx, flags=%lx, topdown=%d\n" , - addr, len, flags, topdown); -/* If hint, make sure it matches our alignment restrictions */ if (!fixed && addr) { addr =_ALIGN_UP (addr, page_size); -slice_dbg (" aligned addr=%lx\n" , addr);/* Ignore hint if it's too large or overlaps a VMA */ if (addr > high_limit - len || addr < mmap_min_addr || !slice_area_is_free (mm, addr, len))@@ -538,17 +504,12 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,slice_copy_mask (&good_mask, maskp); } -slice_print_mask (" good_mask" , &good_mask); -if (compat_maskp) -slice_print_mask (" compat_mask" , compat_maskp); -/* First check hint if it's valid or if we have MAP_FIXED */ if (addr !=0 || fixed) {/* Check if we fit in the good mask. If we do, we just return, * nothing else to do */ if (slice_check_range_fits (mm, &good_mask, addr, len)) { -slice_dbg (" fits good !\n" ); newaddr = addr; goto return_addr; }@@ -558,13 +519,10 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,*/ newaddr =slice_find_area (mm, len, &good_mask, psize, topdown, high_limit); -if (newaddr != -ENOMEM ) { -/* Found within the good mask, we don't have to setup, -* we thus return directly -*/ -slice_dbg (" found area at 0x%lx\n" , newaddr); + +/* Found within good mask, don't have to setup, thus return directly */ +if (newaddr != -ENOMEM ) goto return_addr; - } }/* * We don't fit in the good mask, check what other slices are @@ -572,11 +530,9 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,*/ slice_mask_for_free (mm, &potential_mask, high_limit);slice_or_mask (&potential_mask, &potential_mask, &good_mask); -slice_print_mask (" potential" , &potential_mask);if (addr !=0 || fixed) {if (slice_check_range_fits (mm, &potential_mask, addr, len)) { -slice_dbg (" fits potential !\n" ); newaddr = addr; goto convert; }@@ -586,18 +542,14 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,if (fixed)return -EBUSY ; -slice_dbg (" search...\n" ); -/* If we had a hint that didn't work out, see if we can fit * anywhere in the good area. */ if (addr) { newaddr =slice_find_area (mm, len, &good_mask, psize, topdown, high_limit); -if (newaddr != -ENOMEM ) { -slice_dbg (" found area at 0x%lx\n" , newaddr); +if (newaddr != -ENOMEM ) goto return_addr; - } }/* Now let's see if we can find something in the existing slices @@ -618,8 +570,6 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,return -ENOMEM ;slice_range_to_mask (newaddr, len, &potential_mask); -slice_dbg (" found potential area at 0x%lx\n" , newaddr); -slice_print_mask (" mask" , &potential_mask); convert:/* @@ -697,8 +647,6 @@ void slice_init_new_context_exec(struct mm_struct *mm)struct slice_mask *mask;unsigned int psize = mmu_virtual_psize; -slice_dbg ("slice_init_new_context_exec(mm=%p)\n" , mm); -/* * In the case of exec, use the default limit. In the * case of fork it is just inherited from the mm being @@ -730,8 +678,6 @@ void slice_setup_new_exec(void) {struct mm_struct *mm = current->mm; -slice_dbg ("slice_setup_new_exec(mm=%p)\n" , mm); -if (!is_32bit_task ())return ;Signature · 1 line
2.13.3
Re: [PATCH v2 11/11] powerpc/mm: drop slice DEBUG
Le 26/04/2019 à 08:44, Aneesh Kumar K.V a écrit :
Quoted 7 lines
Quoted 2 lines · Christophe Leroy
slice is now an improved functionnality. Drop the DEBUG stuff.
I would like to keep that. I helped a lot when moving address ranges and it should not have any runtime impact.
Ok for me.
Christophe
Quoted 172 lines
Quoted 172 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/mm/slice.c | 62 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 58 deletions(-)arch/powerpc/mm/slice.c +4
-58@@ -41,28 +41,6 @@static DEFINE_SPINLOCK (slice_convert_lock); -#ifdef DEBUG -int _slice_debug =1 ; - -static void slice_print_mask (const char *label,const struct slice_mask *mask) -{ -if (!_slice_debug) -return ; -pr_devel ("%s low_slice: %*pbl\n" , label, - (int )SLICE_NUM_LOW , &mask->low_slices); -pr_devel ("%s high_slice: %*pbl\n" , label, - (int )SLICE_NUM_HIGH , mask->high_slices); -} - -#define slice_dbg(fmt...) do { if (_slice_debug) pr_devel(fmt); } while (0) - -#else - -static void slice_print_mask (const char *label,const struct slice_mask *mask) {} -#define slice_dbg(fmt...) - -#endif -static inline bool slice_addr_is_low (unsigned long addr) {u64 tmp = (u64 )addr;@@ -207,9 +185,6 @@ static void slice_convert(struct mm_struct *mm,unsigned long i, flags;int old_psize; -slice_dbg ("slice_convert(mm=%p, psize=%d)\n" , mm, psize); -slice_print_mask (" mask" , mask); - psize_mask =slice_mask_for_size (&mm->context, psize);/* We need to use a spinlock here to protect against @@ -255,10 +230,6 @@ static void slice_convert(struct mm_struct *mm, (((unsigned long )psize) << (mask_index *4 )); } -slice_dbg (" lsps=%lx, hsps=%lx\n" , - (unsigned long )mm_ctx_low_slices (&mm->context), - (unsigned long )mm_ctx_high_slices (&mm->context)); -spin_unlock_irqrestore (&slice_convert_lock, flags);copro_flush_all_slbs (mm);@@ -485,14 +456,9 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,BUG_ON (mm_ctx_slb_addr_limit (&mm->context) ==0 );VM_BUG_ON (radix_enabled ()); -slice_dbg ("slice_get_unmapped_area(mm=%p, psize=%d...\n" , mm, psize); -slice_dbg (" addr=%lx, len=%lx, flags=%lx, topdown=%d\n" , - addr, len, flags, topdown); -/* If hint, make sure it matches our alignment restrictions */ if (!fixed && addr) { addr =_ALIGN_UP (addr, page_size); -slice_dbg (" aligned addr=%lx\n" , addr);/* Ignore hint if it's too large or overlaps a VMA */ if (addr > high_limit - len || addr < mmap_min_addr || !slice_area_is_free (mm, addr, len))@@ -538,17 +504,12 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,slice_copy_mask (&good_mask, maskp); } -slice_print_mask (" good_mask" , &good_mask); -if (compat_maskp) -slice_print_mask (" compat_mask" , compat_maskp); -/* First check hint if it's valid or if we have MAP_FIXED */ if (addr !=0 || fixed) {/* Check if we fit in the good mask. If we do, we just return, * nothing else to do */ if (slice_check_range_fits (mm, &good_mask, addr, len)) { -slice_dbg (" fits good !\n" ); newaddr = addr; goto return_addr; }@@ -558,13 +519,10 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,*/ newaddr =slice_find_area (mm, len, &good_mask, psize, topdown, high_limit); -if (newaddr != -ENOMEM ) { -/* Found within the good mask, we don't have to setup, -* we thus return directly -*/ -slice_dbg (" found area at 0x%lx\n" , newaddr); + +/* Found within good mask, don't have to setup, thus return directly */ +if (newaddr != -ENOMEM ) goto return_addr; - } }/* * We don't fit in the good mask, check what other slices are @@ -572,11 +530,9 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,*/ slice_mask_for_free (mm, &potential_mask, high_limit);slice_or_mask (&potential_mask, &potential_mask, &good_mask); -slice_print_mask (" potential" , &potential_mask);if (addr !=0 || fixed) {if (slice_check_range_fits (mm, &potential_mask, addr, len)) { -slice_dbg (" fits potential !\n" ); newaddr = addr; goto convert; }@@ -586,18 +542,14 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,if (fixed)return -EBUSY ; -slice_dbg (" search...\n" ); -/* If we had a hint that didn't work out, see if we can fit * anywhere in the good area. */ if (addr) { newaddr =slice_find_area (mm, len, &good_mask, psize, topdown, high_limit); -if (newaddr != -ENOMEM ) { -slice_dbg (" found area at 0x%lx\n" , newaddr); +if (newaddr != -ENOMEM ) goto return_addr; - } }/* Now let's see if we can find something in the existing slices @@ -618,8 +570,6 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,return -ENOMEM ;slice_range_to_mask (newaddr, len, &potential_mask); -slice_dbg (" found potential area at 0x%lx\n" , newaddr); -slice_print_mask (" mask" , &potential_mask); convert:/* @@ -697,8 +647,6 @@ void slice_init_new_context_exec(struct mm_struct *mm)struct slice_mask *mask;unsigned int psize = mmu_virtual_psize; -slice_dbg ("slice_init_new_context_exec(mm=%p)\n" , mm); -/* * In the case of exec, use the default limit. In the * case of fork it is just inherited from the mm being @@ -730,8 +678,6 @@ void slice_setup_new_exec(void) {struct mm_struct *mm = current->mm; -slice_dbg ("slice_setup_new_exec(mm=%p)\n" , mm); -if (!is_32bit_task ())return ;Signature · 1 line
2.13.3