* [PATCH] selftest/mm: Do not use hint for riscv mmap
@ 2024-09-12 10:00 Chunyan Zhang
2024-09-12 20:47 ` Charlie Jenkins
0 siblings, 1 reply; 3+ messages in thread
From: Chunyan Zhang @ 2024-09-12 10:00 UTC (permalink / raw)
To: Andrew Morton, Shuah Khan, Paul Walmsley, Palmer Dabbelt,
Alexandre Ghiti
Cc: linux-mm, linux-kselftest, linux-riscv, linux-kernel, Chunyan Zhang
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)
+{
+ 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)
{
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] selftest/mm: Do not use hint for riscv mmap
2024-09-12 10:00 [PATCH] selftest/mm: Do not use hint for riscv mmap Chunyan Zhang
@ 2024-09-12 20:47 ` Charlie Jenkins
2024-09-13 2:07 ` Chunyan Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Charlie Jenkins @ 2024-09-12 20:47 UTC (permalink / raw)
To: Chunyan Zhang
Cc: Andrew Morton, Shuah Khan, Paul Walmsley, Palmer Dabbelt,
Alexandre Ghiti, linux-mm, linux-kselftest, linux-riscv,
linux-kernel, Chunyan Zhang
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] selftest/mm: Do not use hint for riscv mmap
2024-09-12 20:47 ` Charlie Jenkins
@ 2024-09-13 2:07 ` Chunyan Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Chunyan Zhang @ 2024-09-13 2:07 UTC (permalink / raw)
To: Charlie Jenkins
Cc: Chunyan Zhang, Andrew Morton, Shuah Khan, Paul Walmsley,
Palmer Dabbelt, Alexandre Ghiti, linux-mm, linux-kselftest,
linux-riscv, linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-13 2:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-12 10:00 [PATCH] selftest/mm: Do not use hint for riscv mmap Chunyan Zhang
2024-09-12 20:47 ` Charlie Jenkins
2024-09-13 2:07 ` Chunyan Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox