* [PATCH] selftests: vm: use 1 MB hugepage size for s390
@ 2022-10-25 15:26 Gerald Schaefer
2022-10-25 15:34 ` David Hildenbrand
0 siblings, 1 reply; 3+ messages in thread
From: Gerald Schaefer @ 2022-10-25 15:26 UTC (permalink / raw)
To: Andrew Morton, Shuah Khan, Muchun Song
Cc: linux-mm, LKML, linux-kselftest, linux-s390
hugepage-vmemmap test fails for s390 because it assumes a hugepagesize
of 2 MB, while we have 1 MB on s390. This results in iterating over two
hugepages. If they are consecutive in memory, check_page_flags() will
stumble over the additional head page. Otherwise, it will stumble over
non-huge pageflags, after crossing the first 1 MB hugepage.
Fix this by using 1 MB MAP_LENGTH for s390.
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
---
tools/testing/selftests/vm/hugepage-vmemmap.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/vm/hugepage-vmemmap.c b/tools/testing/selftests/vm/hugepage-vmemmap.c
index 557bdbd4f87e..a4695f138cec 100644
--- a/tools/testing/selftests/vm/hugepage-vmemmap.c
+++ b/tools/testing/selftests/vm/hugepage-vmemmap.c
@@ -11,7 +11,14 @@
#include <sys/mman.h>
#include <fcntl.h>
+/*
+ * 1 MB hugepage size for s390
+ */
+#if defined(__s390x__)
+#define MAP_LENGTH (1UL * 1024 * 1024)
+#else
#define MAP_LENGTH (2UL * 1024 * 1024)
+#endif
#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0x40000 /* arch specific */
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: vm: use 1 MB hugepage size for s390
2022-10-25 15:26 [PATCH] selftests: vm: use 1 MB hugepage size for s390 Gerald Schaefer
@ 2022-10-25 15:34 ` David Hildenbrand
2022-10-26 12:44 ` Gerald Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: David Hildenbrand @ 2022-10-25 15:34 UTC (permalink / raw)
To: Gerald Schaefer, Andrew Morton, Shuah Khan, Muchun Song
Cc: linux-mm, LKML, linux-kselftest, linux-s390
On 25.10.22 17:26, Gerald Schaefer wrote:
> hugepage-vmemmap test fails for s390 because it assumes a hugepagesize
> of 2 MB, while we have 1 MB on s390. This results in iterating over two
> hugepages. If they are consecutive in memory, check_page_flags() will
> stumble over the additional head page. Otherwise, it will stumble over
> non-huge pageflags, after crossing the first 1 MB hugepage.
>
> Fix this by using 1 MB MAP_LENGTH for s390.
>
> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> ---
> tools/testing/selftests/vm/hugepage-vmemmap.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/testing/selftests/vm/hugepage-vmemmap.c b/tools/testing/selftests/vm/hugepage-vmemmap.c
> index 557bdbd4f87e..a4695f138cec 100644
> --- a/tools/testing/selftests/vm/hugepage-vmemmap.c
> +++ b/tools/testing/selftests/vm/hugepage-vmemmap.c
> @@ -11,7 +11,14 @@
> #include <sys/mman.h>
> #include <fcntl.h>
>
> +/*
> + * 1 MB hugepage size for s390
> + */
> +#if defined(__s390x__)
> +#define MAP_LENGTH (1UL * 1024 * 1024)
> +#else
> #define MAP_LENGTH (2UL * 1024 * 1024)
> +#endif
Why not detect it at runtime, so this works on any architecture (e.g.,
ppc64 with 16 MiB IIRC and arm64 with weird sizes)?
A patch that adds such detection code is currently on its way upstream:
https://lore.kernel.org/all/20220927110120.106906-5-david@redhat.com/T/#u
We could factor that out into vm_utils.c
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: vm: use 1 MB hugepage size for s390
2022-10-25 15:34 ` David Hildenbrand
@ 2022-10-26 12:44 ` Gerald Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Gerald Schaefer @ 2022-10-26 12:44 UTC (permalink / raw)
To: David Hildenbrand
Cc: Andrew Morton, Shuah Khan, Muchun Song, linux-mm, LKML,
linux-kselftest, linux-s390
On Tue, 25 Oct 2022 17:34:52 +0200
David Hildenbrand <david@redhat.com> wrote:
> On 25.10.22 17:26, Gerald Schaefer wrote:
> > hugepage-vmemmap test fails for s390 because it assumes a hugepagesize
> > of 2 MB, while we have 1 MB on s390. This results in iterating over two
> > hugepages. If they are consecutive in memory, check_page_flags() will
> > stumble over the additional head page. Otherwise, it will stumble over
> > non-huge pageflags, after crossing the first 1 MB hugepage.
> >
> > Fix this by using 1 MB MAP_LENGTH for s390.
> >
> > Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> > ---
> > tools/testing/selftests/vm/hugepage-vmemmap.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/tools/testing/selftests/vm/hugepage-vmemmap.c b/tools/testing/selftests/vm/hugepage-vmemmap.c
> > index 557bdbd4f87e..a4695f138cec 100644
> > --- a/tools/testing/selftests/vm/hugepage-vmemmap.c
> > +++ b/tools/testing/selftests/vm/hugepage-vmemmap.c
> > @@ -11,7 +11,14 @@
> > #include <sys/mman.h>
> > #include <fcntl.h>
> >
> > +/*
> > + * 1 MB hugepage size for s390
> > + */
> > +#if defined(__s390x__)
> > +#define MAP_LENGTH (1UL * 1024 * 1024)
> > +#else
> > #define MAP_LENGTH (2UL * 1024 * 1024)
> > +#endif
>
> Why not detect it at runtime, so this works on any architecture (e.g.,
> ppc64 with 16 MiB IIRC and arm64 with weird sizes)?
>
> A patch that adds such detection code is currently on its way upstream:
>
> https://lore.kernel.org/all/20220927110120.106906-5-david@redhat.com/T/#u
>
> We could factor that out into vm_utils.c
>
Hello David, nice, I guess that would be much better than adding new #ifdefs,
and also allow to check all available hugepage sizes per arch.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-26 12:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-25 15:26 [PATCH] selftests: vm: use 1 MB hugepage size for s390 Gerald Schaefer
2022-10-25 15:34 ` David Hildenbrand
2022-10-26 12:44 ` Gerald Schaefer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).