linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Rik van Riel <riel@surriel.com>
Cc: mike.kravetz@oracle.com, muchun.song@linux.dev,
	akpm@linux-foundation.org, Shuah Khan <shuah@kernel.org>,
	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: Thu, 5 Oct 2023 06:38:40 -0700	[thread overview]
Message-ID: <ZR68YM1ImrAGy+ZJ@gmail.com> (raw)
In-Reply-To: <026a75f627bc7ffa45ead3fd6ecb9da7b5bc2692.camel@surriel.com>

On Wed, Oct 04, 2023 at 08:22:08PM -0400, Rik van Riel wrote:
> 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.

Right. I think I don't need this whole "if" clause at all. Let me remove
it.

> > 
> > +       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?

Yes, probably skip the test if we are not able to allocate the memory.
I just found I can use something as `ksft_exit_skip()` for this purpose.

Thanks for the great feedbacks!


      reply	other threads:[~2023-10-05 13:38 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
2023-10-05 13:38     ` Breno Leitao [this message]

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=ZR68YM1ImrAGy+ZJ@gmail.com \
    --to=leitao@debian.org \
    --cc=akpm@linux-foundation.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=riel@surriel.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;
as well as URLs for NNTP newsgroup(s).