lkml.org 
[lkml]   [2023]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] selftests/mm: Add a new test for madv and hugetlb
From
Date
On Wed, 2023-10-04 at 10:11 -0700, Breno Leitao wrote:
>
> +char *huge_ptr;
> +
> +/* Touch the memory while it is being madvised() */
> +void *touch(void *unused)
> +{
> +       char *ptr = (char *)huge_ptr;
> +
> +       if (!ptr) {
> +               fprintf(stderr, "Failed to allocate memory\n");
> +               perror("");
> +       }

I'm not sure this error message makes a lot of sense
away from where the huge page gets allocated.

>
> +       while (max--) {
> +               huge_ptr = mmap(NULL, MMAP_SIZE, PROT_READ |
> PROT_WRITE,
> +                               MAP_PRIVATE | MAP_ANONYMOUS |
> MAP_HUGETLB, -1, 0);
> +
> +               if ((unsigned long)huge_ptr == -1) {
> +                       perror("Failed to allocate\n");
> +                       continue;
> +               }

Should the test case just exit with an error here, when
the allocation fails?

Looping around when it cannot get memory seems pointless,
but telling the user that the allocation fails, when it
should clearly have succeeded could be useful.

This test case certainly seems to do the trick in showing
whether the race between MADV_DONTNEED and page faults
exists in a particular kernel.


--
All Rights Reversed.
\
 
 \ /
  Last update: 2023-10-05 02:23    [W:0.079 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site