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] [thread-next>] [day] [month] [year] [list]
Message-ID: <026a75f627bc7ffa45ead3fd6ecb9da7b5bc2692.camel@surriel.com>
Date:   Wed, 04 Oct 2023 20:22:08 -0400
From:   Rik van Riel <riel@...riel.com>
To:     Breno Leitao <leitao@...ian.org>, mike.kravetz@...cle.com,
        muchun.song@...ux.dev, akpm@...ux-foundation.org,
        Shuah Khan <shuah@...nel.org>
Cc:     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, 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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ