From: Shuah Khan <skhan@linuxfoundation.org>
To: David Hildenbrand <david@redhat.com>, linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>,
Mario Casquero <mcasquer@redhat.com>,
Breno Leitao <leitao@debian.org>,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v1 1/2] selftests/mm: hugetlb_fault_after_madv: use default hguetlb page size
Date: Thu, 26 Sep 2024 10:03:50 -0600 [thread overview]
Message-ID: <5d9c8052-e7ca-4819-bd0c-d7f88905c7a1@linuxfoundation.org> (raw)
In-Reply-To: <20240926152044.2205129-2-david@redhat.com>
On 9/26/24 09:20, David Hildenbrand wrote:
> We currently assume that the hugetlb page size is 2 MiB, which is
> why we mmap() a 2 MiB range.
>
> Is the default hugetlb size is larger, mmap() will fail because the
> range is not suitable. If the default hugetlb size is smaller (e.g.,
> s390x), mmap() will fail because we would need more than one hugetlb
> page, but just asserted that we have exactly one.
>
> So let's simply use the default hugetlb page size instead of hard-coded
> 2 MiB, so the test isn't unconditionally skipped on architectures like
> s390x.
>
> Before this patch on s390x:
> $ ./hugetlb_fault_after_madv
> 1..0 # SKIP Failed to allocated huge page
>
> With this change on s390x:
> $ ./hugetlb_fault_after_madv
>
> While at it, make "huge_ptr" static.
>
> Reported-by: Mario Casquero <mcasquer@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> .../selftests/mm/hugetlb_fault_after_madv.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/hugetlb_fault_after_madv.c b/tools/testing/selftests/mm/hugetlb_fault_after_madv.c
> index 73b81c632366..ff3ba675278d 100644
> --- a/tools/testing/selftests/mm/hugetlb_fault_after_madv.c
> +++ b/tools/testing/selftests/mm/hugetlb_fault_after_madv.c
> @@ -9,10 +9,10 @@
> #include "vm_util.h"
> #include "../kselftest.h"
>
> -#define MMAP_SIZE (1 << 21)
> #define INLOOP_ITER 100
>
> -char *huge_ptr;
> +static char *huge_ptr;
> +static size_t huge_page_size;
>
> /* Touch the memory while it is being madvised() */
> void *touch(void *unused)
> @@ -30,7 +30,7 @@ void *madv(void *unused)
> usleep(rand() % 10);
>
> for (int i = 0; i < INLOOP_ITER; i++)
> - madvise(huge_ptr, MMAP_SIZE, MADV_DONTNEED);
> + madvise(huge_ptr, huge_page_size, MADV_DONTNEED);
Magical effects of hard-coded values :)
Thank you for fixing this
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
next prev parent reply other threads:[~2024-09-26 16:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-26 15:20 [PATCH v1 0/2] selftests/mm: hugetlb_fault_after_madv improvements David Hildenbrand
2024-09-26 15:20 ` [PATCH v1 1/2] selftests/mm: hugetlb_fault_after_madv: use default hguetlb page size David Hildenbrand
2024-09-26 15:22 ` David Hildenbrand
2024-09-26 16:03 ` Shuah Khan [this message]
2024-09-30 10:01 ` Breno Leitao
2024-09-26 15:20 ` [PATCH v1 2/2] selftests/mm: hugetlb_fault_after_madv: improve test output David Hildenbrand
2024-09-30 10:05 ` Breno Leitao
2024-09-30 10:55 ` David Hildenbrand
2024-10-01 10:31 ` [PATCH v1 0/2] selftests/mm: hugetlb_fault_after_madv improvements Mario Casquero
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d9c8052-e7ca-4819-bd0c-d7f88905c7a1@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcasquer@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox