lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZR68YM1ImrAGy+ZJ@gmail.com>
Date:   Thu, 5 Oct 2023 06:38:40 -0700
From:   Breno Leitao <leitao@...ian.org>
To:     Rik van Riel <riel@...riel.com>
Cc:     mike.kravetz@...cle.com, muchun.song@...ux.dev,
        akpm@...ux-foundation.org, Shuah Khan <shuah@...nel.org>,
        linux-mm@...ck.org, open list <linux-kernel@...r.kernel.org>,
        "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH 2/2] selftests/mm: Add a new test for madv and hugetlb

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!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ