linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@surriel.com>
To: Breno Leitao <leitao@debian.org>,
	mike.kravetz@oracle.com,  muchun.song@linux.dev,
	akpm@linux-foundation.org, Shuah Khan <shuah@kernel.org>
Cc: linux-mm@kvack.org, open list <linux-kernel@vger.kernel.org>,
	"open list:KERNEL SELFTEST FRAMEWORK"
	<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH 2/2] selftests/mm: Add a new test for madv and hugetlb
Date: Wed, 04 Oct 2023 20:22:08 -0400	[thread overview]
Message-ID: <026a75f627bc7ffa45ead3fd6ecb9da7b5bc2692.camel@surriel.com> (raw)
In-Reply-To: <20231004171127.106056-2-leitao@debian.org>

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.

  reply	other threads:[~2023-10-05  0:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 17:11 [PATCH 1/2] selftests/mm: export get_free_hugepages() Breno Leitao
2023-10-04 17:11 ` [PATCH 2/2] selftests/mm: Add a new test for madv and hugetlb Breno Leitao
2023-10-05  0:22   ` Rik van Riel [this message]
2023-10-05 13:38     ` Breno Leitao

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=026a75f627bc7ffa45ead3fd6ecb9da7b5bc2692.camel@surriel.com \
    --to=riel@surriel.com \
    --cc=akpm@linux-foundation.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=muchun.song@linux.dev \
    --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;
as well as URLs for NNTP newsgroup(s).