diff mbox series

selftest/mm: Do not use hint for riscv mmap

Message ID 20240912100018.736447-1-zhangchunyan@iscas.ac.cn (mailing list archive)
State New
Headers show
Series selftest/mm: Do not use hint for riscv mmap | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 127.30s
conchuod/patch-1-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 1263.75s
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 1492.02s
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 19.65s
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 21.67s
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh took 0.44s
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 41.78s
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.00s
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.55s
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.00s
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.03s

Commit Message

Chunyan Zhang Sept. 12, 2024, 10 a.m. UTC
When the virtual address range selftest is run on RISC-V platforms,
it is observed that using the hint address when calling mmap cannot
get the address in the range of that validate_addr() checks, also
that will cause '/proc/self/maps' have gaps larger than MAP_CHUNK_SIZE.

Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
---
 tools/testing/selftests/mm/virtual_address_range.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Charlie Jenkins Sept. 12, 2024, 8:47 p.m. UTC | #1
On Thu, Sep 12, 2024 at 06:00:18PM +0800, Chunyan Zhang wrote:
> When the virtual address range selftest is run on RISC-V platforms,
> it is observed that using the hint address when calling mmap cannot
> get the address in the range of that validate_addr() checks, also
> that will cause '/proc/self/maps' have gaps larger than MAP_CHUNK_SIZE.
> 
> Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
> ---
>  tools/testing/selftests/mm/virtual_address_range.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c
> index 4e4c1e311247..25f3eb304999 100644
> --- a/tools/testing/selftests/mm/virtual_address_range.c
> +++ b/tools/testing/selftests/mm/virtual_address_range.c
> @@ -64,6 +64,14 @@
>  #define NR_CHUNKS_HIGH  NR_CHUNKS_384TB
>  #endif
>  
> +#if defined(__riscv) && (__riscv_xlen == 64)
> +static char *hind_addr(void)

This is not a typo by you since this is the name of the original
function but this should be "hint_addr" right?

> +{
> +	return NULL;
> +}
> +
> +static void validate_addr(char *ptr, int high_addr) { }
> +#else

This is something that I am trying to solve over at
https://lore.kernel.org/lkml/20240905-patches-below_hint_mmap-v3-0-3cd5564efbbb@rivosinc.com/
(the solution is still in flux). Since riscv doesn't currently have this
behavior of restricting the virtual address space, I think it is more
reasonable to disable this test entirely. After we have a longer-term
solution with the patch I have up we can adjust the test and re-enable
it. What do you think?

- Charlie

>  static char *hind_addr(void)
>  {
>  	int bits = HIGH_ADDR_SHIFT + rand() % (63 - HIGH_ADDR_SHIFT);
> @@ -81,6 +89,7 @@ static void validate_addr(char *ptr, int high_addr)
>  	if (addr > HIGH_ADDR_MARK)
>  		ksft_exit_fail_msg("Bad address %lx\n", addr);
>  }
> +#endif
>  
>  static int validate_lower_address_hint(void)
>  {
> -- 
> 2.34.1
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Chunyan Zhang Sept. 13, 2024, 2:07 a.m. UTC | #2
On Fri, 13 Sept 2024 at 04:47, Charlie Jenkins <charlie@rivosinc.com> wrote:
>
> On Thu, Sep 12, 2024 at 06:00:18PM +0800, Chunyan Zhang wrote:
> > When the virtual address range selftest is run on RISC-V platforms,
> > it is observed that using the hint address when calling mmap cannot
> > get the address in the range of that validate_addr() checks, also
> > that will cause '/proc/self/maps' have gaps larger than MAP_CHUNK_SIZE.
> >
> > Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
> > ---
> >  tools/testing/selftests/mm/virtual_address_range.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c
> > index 4e4c1e311247..25f3eb304999 100644
> > --- a/tools/testing/selftests/mm/virtual_address_range.c
> > +++ b/tools/testing/selftests/mm/virtual_address_range.c
> > @@ -64,6 +64,14 @@
> >  #define NR_CHUNKS_HIGH  NR_CHUNKS_384TB
> >  #endif
> >
> > +#if defined(__riscv) && (__riscv_xlen == 64)
> > +static char *hind_addr(void)
>
> This is not a typo by you since this is the name of the original
> function but this should be "hint_addr" right?

Right, didn't notice this typo, let me fix it.

>
> > +{
> > +     return NULL;
> > +}
> > +
> > +static void validate_addr(char *ptr, int high_addr) { }
> > +#else
>
> This is something that I am trying to solve over at
> https://lore.kernel.org/lkml/20240905-patches-below_hint_mmap-v3-0-3cd5564efbbb@rivosinc.com/
> (the solution is still in flux). Since riscv doesn't currently have this
> behavior of restricting the virtual address space, I think it is more
> reasonable to disable this test entirely. After we have a longer-term
> solution with the patch I have up we can adjust the test and re-enable
> it. What do you think?

That also makes sense, I will send another patch to do that.

Thanks,
Chunyan

>
> - Charlie
>
> >  static char *hind_addr(void)
> >  {
> >       int bits = HIGH_ADDR_SHIFT + rand() % (63 - HIGH_ADDR_SHIFT);
> > @@ -81,6 +89,7 @@ static void validate_addr(char *ptr, int high_addr)
> >       if (addr > HIGH_ADDR_MARK)
> >               ksft_exit_fail_msg("Bad address %lx\n", addr);
> >  }
> > +#endif
> >
> >  static int validate_lower_address_hint(void)
> >  {
> > --
> > 2.34.1
> >
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c
index 4e4c1e311247..25f3eb304999 100644
--- a/tools/testing/selftests/mm/virtual_address_range.c
+++ b/tools/testing/selftests/mm/virtual_address_range.c
@@ -64,6 +64,14 @@ 
 #define NR_CHUNKS_HIGH  NR_CHUNKS_384TB
 #endif
 
+#if defined(__riscv) && (__riscv_xlen == 64)
+static char *hind_addr(void)
+{
+	return NULL;
+}
+
+static void validate_addr(char *ptr, int high_addr) { }
+#else
 static char *hind_addr(void)
 {
 	int bits = HIGH_ADDR_SHIFT + rand() % (63 - HIGH_ADDR_SHIFT);
@@ -81,6 +89,7 @@  static void validate_addr(char *ptr, int high_addr)
 	if (addr > HIGH_ADDR_MARK)
 		ksft_exit_fail_msg("Bad address %lx\n", addr);
 }
+#endif
 
 static int validate_lower_address_hint(void)
 {