From: Mike Rapoport <rppt@kernel.org>
To: Guillaume Morin <guillaume@morinfr.org>
Cc: linux-mm@kvack.org, leitao@debian.org
Subject: Re: [PATCH v4] selftests/mm: hugetlb_madv_vs_map: add underflow test
Date: Thu, 10 Sep 2026 09:49:06 +0300 [thread overview]
Message-ID: <aqJS4rVDDTQjxF3N@kernel.org> (raw)
In-Reply-To: <apsdO-IK6p-IDb-a@bender.morinfr.org>
On Fri, Sep 04, 2026 at 09:34:19PM +0200, Guillaume Morin wrote:
> Add a test that checks for underflows when a parent unmaps the page
> first. Also check that when the child exits the reserve count is
> correct.
>
> Link: https://lore.kernel.org/all/alEJkwn5VlTTH_ZX@bender.morinfr.org/
> Signed-off-by: Guillaume Morin <guillaume@morinfr.org
> Cc: Breno Leitao <leitao@debian.org>
> Cc: Mike Rapoport <rppt@kernel.org>
With some small nits below fixed
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> v4: address Mike's comments
> v3: address Mike's comments
> v2: refactor tests into 2 functions
>
> @@ -100,7 +98,7 @@ int main(void)
> -1, 0);
>
> if ((unsigned long)huge_ptr == -1)
> - ksft_exit_fail_msg("Failed to allocate huge page\n");
> + ksft_exit_fail_perror("Failed to allocate huge page\n");
Nit: _perror() does not need "\n".
> pthread_create(&thread1, NULL, madv, NULL);
> pthread_create(&thread2, NULL, touch, NULL);
> @@ -120,5 +118,110 @@ int main(void)
> }
>
> ksft_test_result_pass("No unexpected huge page allocations\n");
> +}
> +
> +/* We create a child process, then unmap the page in the parent while the child
> + * waits and verify that there is no underflow of the reserved count. We also
> + * verify that after the child exits, the reserved count is properly restored.
> + */
> +void test_underflow(void)
> +{
> + pid_t pid;
> + int pipe_fds[2];
> + unsigned long nr_reserved = 0;
> +
> + huge_ptr = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
> +
> + if ((unsigned long)huge_ptr == -1)
> + ksft_exit_fail_perror("Failed to allocate huge page\n");
Ditto.
> +
> + nr_reserved = hugetlb_nr_resv_pages(default_huge_page_size());
> + if (nr_reserved != 1)
> + ksft_exit_fail_msg("Unexpected number of reserved pages: %lu, expected 1\n",
> + nr_reserved);
> +
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-09-10 6:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 19:34 [PATCH v4] selftests/mm: hugetlb_madv_vs_map: add underflow test Guillaume Morin
2026-09-10 6:49 ` Mike Rapoport [this message]
2026-09-10 12:04 ` 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=aqJS4rVDDTQjxF3N@kernel.org \
--to=rppt@kernel.org \
--cc=guillaume@morinfr.org \
--cc=leitao@debian.org \
--cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.