Message ID | 20221204141137.691790-4-panqinglin2020@iscas.ac.cn (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Palmer Dabbelt |
Headers | show |
Series | riscv, mm: detect svnapot cpu support at runtime | expand |
Context | Check | Description |
---|---|---|
conchuod/patch_count | success | Link |
conchuod/cover_letter | success | Series has a cover letter |
conchuod/tree_selection | success | Guessed tree name to be for-next |
conchuod/fixes_present | success | Fixes tag not required for -next series |
conchuod/verify_signedoff | success | Signed-off-by tag matches author and committer |
conchuod/kdoc | success | Errors and warnings before: 0 this patch: 0 |
conchuod/module_param | success | Was 0 now: 0 |
conchuod/alphanumeric_selects | success | Out of order selects before the patch: 59 and now 59 |
conchuod/build_rv32_defconfig | success | Build OK |
conchuod/build_warn_rv64 | success | Errors and warnings before: 0 this patch: 0 |
conchuod/dtb_warn_rv64 | success | Errors and warnings before: 0 this patch: 0 |
conchuod/header_inline | success | No static functions without inline keyword in header files |
conchuod/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 66 lines checked |
conchuod/source_inline | success | Was 0 now: 0 |
conchuod/build_rv64_nommu_k210_defconfig | success | Build OK |
conchuod/verify_fixes | success | No Fixes tag |
conchuod/build_rv64_nommu_virt_defconfig | success | Build OK |
On Sun, Dec 04, 2022 at 10:11:37PM +0800, panqinglin2020@iscas.ac.cn wrote: > From: Qinglin Pan <panqinglin2020@iscas.ac.cn> > > As HAVE_ARCH_HUGE_VMAP and HAVE_ARCH_HUGE_VMALLOC is supported, we can > implement arch_vmap_pte_range_map_size and arch_vmap_pte_supported_shift > for Svnapot to support huge vmap about napot size. > > It can be tested by huge vmap used in pci driver. Huge vmalloc with svnapot > can be tested by changing test_vmalloc module like [1], and probe this > module to run fix_size_alloc_test with use_huge true. > > [1]https://github.com/RV-VM/linux-vm-support/commit/33f4ee399c36d355c412ebe5334ca46fd727f8f5 Please make this one a standard Link: tag. > > Signed-off-by: Qinglin Pan <panqinglin2020@iscas.ac.cn> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > diff --git a/arch/riscv/include/asm/vmalloc.h b/arch/riscv/include/asm/vmalloc.h > index 48da5371f1e9..6f7447d563ab 100644 > --- a/arch/riscv/include/asm/vmalloc.h > +++ b/arch/riscv/include/asm/vmalloc.h > @@ -17,6 +17,65 @@ static inline bool arch_vmap_pmd_supported(pgprot_t prot) > return true; > } > > -#endif > +#ifdef CONFIG_RISCV_ISA_SVNAPOT > +#include <linux/pgtable.h> > > +#define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size > +static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end, > + u64 pfn, unsigned int max_page_shift) > +{ > + unsigned long size, order; > + unsigned long map_size = PAGE_SIZE; > + > + if (!has_svnapot()) > + return map_size; These ones are obvious about what you're gonna do if !has_svnapot() though, nice :) With a proper Link: tag Acked-by: Conor Dooley <conor.dooley@microchip.com> > + > + for_each_napot_order_rev(order) { > + if (napot_cont_shift(order) > max_page_shift) > + continue; > + > + size = napot_cont_size(order); > + if (end - addr < size) > + continue; > + > + if (!IS_ALIGNED(addr, size)) > + continue; > + > + if (!IS_ALIGNED(PFN_PHYS(pfn), size)) > + continue; > + > + map_size = size; > + break; > + } > + > + return map_size; > +} > + > +#define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift > +static inline int arch_vmap_pte_supported_shift(unsigned long size) > +{ > + int shift = PAGE_SHIFT; > + unsigned long order; > + > + if (!has_svnapot()) > + return shift; > + > + WARN_ON_ONCE(size >= PMD_SIZE); > + > + for_each_napot_order_rev(order) { > + if (napot_cont_size(order) > size) > + continue; > + > + if (!IS_ALIGNED(size, napot_cont_size(order))) > + continue; > + > + shift = napot_cont_shift(order); > + break; > + } > + > + return shift; > +} > + > +#endif /* CONFIG_RISCV_ISA_SVNAPOT */ > +#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ > #endif /* _ASM_RISCV_VMALLOC_H */ > -- > 2.37.4 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv >
Hey! On 2022/12/8 02:59, Conor Dooley wrote: > On Sun, Dec 04, 2022 at 10:11:37PM +0800, panqinglin2020@iscas.ac.cn wrote: >> From: Qinglin Pan <panqinglin2020@iscas.ac.cn> >> >> As HAVE_ARCH_HUGE_VMAP and HAVE_ARCH_HUGE_VMALLOC is supported, we can >> implement arch_vmap_pte_range_map_size and arch_vmap_pte_supported_shift >> for Svnapot to support huge vmap about napot size. >> >> It can be tested by huge vmap used in pci driver. Huge vmalloc with svnapot >> can be tested by changing test_vmalloc module like [1], and probe this >> module to run fix_size_alloc_test with use_huge true. >> >> [1]https://github.com/RV-VM/linux-vm-support/commit/33f4ee399c36d355c412ebe5334ca46fd727f8f5 > > Please make this one a standard Link: tag. Got it. > >> >> Signed-off-by: Qinglin Pan <panqinglin2020@iscas.ac.cn> >> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> >> >> diff --git a/arch/riscv/include/asm/vmalloc.h b/arch/riscv/include/asm/vmalloc.h >> index 48da5371f1e9..6f7447d563ab 100644 >> --- a/arch/riscv/include/asm/vmalloc.h >> +++ b/arch/riscv/include/asm/vmalloc.h >> @@ -17,6 +17,65 @@ static inline bool arch_vmap_pmd_supported(pgprot_t prot) >> return true; >> } >> >> -#endif >> +#ifdef CONFIG_RISCV_ISA_SVNAPOT >> +#include <linux/pgtable.h> >> >> +#define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size >> +static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end, >> + u64 pfn, unsigned int max_page_shift) >> +{ >> + unsigned long size, order; >> + unsigned long map_size = PAGE_SIZE; >> + >> + if (!has_svnapot()) >> + return map_size; > > These ones are obvious about what you're gonna do if !has_svnapot() > though, nice :) > With a proper Link: tag > Acked-by: Conor Dooley <conor.dooley@microchip.com> Thanks, Qinglin. > >> + >> + for_each_napot_order_rev(order) { >> + if (napot_cont_shift(order) > max_page_shift) >> + continue; >> + >> + size = napot_cont_size(order); >> + if (end - addr < size) >> + continue; >> + >> + if (!IS_ALIGNED(addr, size)) >> + continue; >> + >> + if (!IS_ALIGNED(PFN_PHYS(pfn), size)) >> + continue; >> + >> + map_size = size; >> + break; >> + } >> + >> + return map_size; >> +} >> + >> +#define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift >> +static inline int arch_vmap_pte_supported_shift(unsigned long size) >> +{ >> + int shift = PAGE_SHIFT; >> + unsigned long order; >> + >> + if (!has_svnapot()) >> + return shift; >> + >> + WARN_ON_ONCE(size >= PMD_SIZE); >> + >> + for_each_napot_order_rev(order) { >> + if (napot_cont_size(order) > size) >> + continue; >> + >> + if (!IS_ALIGNED(size, napot_cont_size(order))) >> + continue; >> + >> + shift = napot_cont_shift(order); >> + break; >> + } >> + >> + return shift; >> +} >> + >> +#endif /* CONFIG_RISCV_ISA_SVNAPOT */ >> +#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ >> #endif /* _ASM_RISCV_VMALLOC_H */ >> -- >> 2.37.4 >> >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv >>
On Sun, Dec 04, 2022 at 10:11:37PM +0800, panqinglin2020@iscas.ac.cn wrote: > From: Qinglin Pan <panqinglin2020@iscas.ac.cn> > > As HAVE_ARCH_HUGE_VMAP and HAVE_ARCH_HUGE_VMALLOC is supported, we can > implement arch_vmap_pte_range_map_size and arch_vmap_pte_supported_shift > for Svnapot to support huge vmap about napot size. > > It can be tested by huge vmap used in pci driver. Huge vmalloc with svnapot > can be tested by changing test_vmalloc module like [1], and probe this > module to run fix_size_alloc_test with use_huge true. > > [1]https://github.com/RV-VM/linux-vm-support/commit/33f4ee399c36d355c412ebe5334ca46fd727f8f5 Do you plan to post this test_vmalloc.c patch? Thanks, drew
Hey! On 2022/12/8 23:22, Andrew Jones wrote: > On Sun, Dec 04, 2022 at 10:11:37PM +0800, panqinglin2020@iscas.ac.cn wrote: >> From: Qinglin Pan <panqinglin2020@iscas.ac.cn> >> >> As HAVE_ARCH_HUGE_VMAP and HAVE_ARCH_HUGE_VMALLOC is supported, we can >> implement arch_vmap_pte_range_map_size and arch_vmap_pte_supported_shift >> for Svnapot to support huge vmap about napot size. >> >> It can be tested by huge vmap used in pci driver. Huge vmalloc with svnapot >> can be tested by changing test_vmalloc module like [1], and probe this >> module to run fix_size_alloc_test with use_huge true. >> >> [1]https://github.com/RV-VM/linux-vm-support/commit/33f4ee399c36d355c412ebe5334ca46fd727f8f5 > > Do you plan to post this test_vmalloc.c patch? I am sure to do it if it makes sense :) I will send a patch of it later. Thanks, Qinglin. > > Thanks, > drew
diff --git a/arch/riscv/include/asm/vmalloc.h b/arch/riscv/include/asm/vmalloc.h index 48da5371f1e9..6f7447d563ab 100644 --- a/arch/riscv/include/asm/vmalloc.h +++ b/arch/riscv/include/asm/vmalloc.h @@ -17,6 +17,65 @@ static inline bool arch_vmap_pmd_supported(pgprot_t prot) return true; } -#endif +#ifdef CONFIG_RISCV_ISA_SVNAPOT +#include <linux/pgtable.h> +#define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size +static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end, + u64 pfn, unsigned int max_page_shift) +{ + unsigned long size, order; + unsigned long map_size = PAGE_SIZE; + + if (!has_svnapot()) + return map_size; + + for_each_napot_order_rev(order) { + if (napot_cont_shift(order) > max_page_shift) + continue; + + size = napot_cont_size(order); + if (end - addr < size) + continue; + + if (!IS_ALIGNED(addr, size)) + continue; + + if (!IS_ALIGNED(PFN_PHYS(pfn), size)) + continue; + + map_size = size; + break; + } + + return map_size; +} + +#define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift +static inline int arch_vmap_pte_supported_shift(unsigned long size) +{ + int shift = PAGE_SHIFT; + unsigned long order; + + if (!has_svnapot()) + return shift; + + WARN_ON_ONCE(size >= PMD_SIZE); + + for_each_napot_order_rev(order) { + if (napot_cont_size(order) > size) + continue; + + if (!IS_ALIGNED(size, napot_cont_size(order))) + continue; + + shift = napot_cont_shift(order); + break; + } + + return shift; +} + +#endif /* CONFIG_RISCV_ISA_SVNAPOT */ +#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ #endif /* _ASM_RISCV_VMALLOC_H */