* [PATCH] selftests: mm: fix map_hugetlb failure on 64K page size systems
@ 2024-01-19 12:57 Nico Pache
2024-01-19 13:11 ` Nico Pache
0 siblings, 1 reply; 2+ messages in thread
From: Nico Pache @ 2024-01-19 12:57 UTC (permalink / raw)
To: linux-kernel, linux-kselftest, linux-mm; +Cc: akpm, shuah, donettom
On systems with 64k page size and 512M huge page sizes, the allocation
and test succeeds but errors out at the munmap. As the comment states,
munmap will failure if its not HUGEPAGE aligned. This is due to the
length of the mapping being 1/2 the size of the hugepage causing the
munmap to not be hugepage aligned. Fix this by making the mapping length
the full hugepage if the hugepage is larger than the length of the
mapping.
Signed-off-by: Nico Pache <npache@redhat.com>
---
tools/testing/selftests/mm/map_hugetlb.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/mm/map_hugetlb.c b/tools/testing/selftests/mm/map_hugetlb.c
index 193281560b61..dcb8095fcd45 100644
--- a/tools/testing/selftests/mm/map_hugetlb.c
+++ b/tools/testing/selftests/mm/map_hugetlb.c
@@ -58,10 +58,16 @@ int main(int argc, char **argv)
{
void *addr;
int ret;
+ size_t maplength;
size_t length = LENGTH;
int flags = FLAGS;
int shift = 0;
+ maplength = default_huge_page_size();
+ /* mmap with fail if the length is not page */
+ if (maplength > length)
+ length = maplength;
+
if (argc > 1)
length = atol(argv[1]) << 20;
if (argc > 2) {
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests: mm: fix map_hugetlb failure on 64K page size systems
2024-01-19 12:57 [PATCH] selftests: mm: fix map_hugetlb failure on 64K page size systems Nico Pache
@ 2024-01-19 13:11 ` Nico Pache
0 siblings, 0 replies; 2+ messages in thread
From: Nico Pache @ 2024-01-19 13:11 UTC (permalink / raw)
To: linux-kernel, linux-kselftest, linux-mm; +Cc: akpm, shuah, donettom
NACK.
I accidentally sent an older version of this patch. Following up with V2.
On Fri, Jan 19, 2024 at 5:58 AM Nico Pache <npache@redhat.com> wrote:
>
> On systems with 64k page size and 512M huge page sizes, the allocation
> and test succeeds but errors out at the munmap. As the comment states,
> munmap will failure if its not HUGEPAGE aligned. This is due to the
> length of the mapping being 1/2 the size of the hugepage causing the
> munmap to not be hugepage aligned. Fix this by making the mapping length
> the full hugepage if the hugepage is larger than the length of the
> mapping.
>
> Signed-off-by: Nico Pache <npache@redhat.com>
> ---
> tools/testing/selftests/mm/map_hugetlb.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/map_hugetlb.c b/tools/testing/selftests/mm/map_hugetlb.c
> index 193281560b61..dcb8095fcd45 100644
> --- a/tools/testing/selftests/mm/map_hugetlb.c
> +++ b/tools/testing/selftests/mm/map_hugetlb.c
> @@ -58,10 +58,16 @@ int main(int argc, char **argv)
> {
> void *addr;
> int ret;
> + size_t maplength;
> size_t length = LENGTH;
> int flags = FLAGS;
> int shift = 0;
>
> + maplength = default_huge_page_size();
> + /* mmap with fail if the length is not page */
> + if (maplength > length)
> + length = maplength;
> +
> if (argc > 1)
> length = atol(argv[1]) << 20;
> if (argc > 2) {
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-19 13:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19 12:57 [PATCH] selftests: mm: fix map_hugetlb failure on 64K page size systems Nico Pache
2024-01-19 13:11 ` Nico Pache
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox