Re: [PATCH 1/1] selftests/mm: new test that steals pages

From: Andrew Morton
Date: Wed Jan 10 2024 - 00:47:43 EST


On Fri, 5 Jan 2024 07:54:19 -0800 Breno Leitao <leitao@xxxxxxxxxx> wrote:

> This test stresses the race between of madvise(DONTNEED), a page fault
> and a parallel huge page mmap, which should fail due to lack of
> available page available for mapping.
>
> This test case must run on a system with one and only one huge page
> available.
>
> # echo 1 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages

Can't the test framework perform this configuration prior to running
the test?

> During setup, the test allocates the only available page, and starts
> three threads:
>
> - thread 1:
> * madvise(MADV_DONTNEED) on the allocated huge page
> - thread 2:
> * Write to the allocated huge page
> - thread 3:
> * Tries to allocated (steal) an extra huge page (which is not
> available)
>
> thread 3 should never succeed in the allocation, since the only huge
> page was never unmapped, and should be reserved.
>
> Touching the old page after thread3 allocation will raise a SIGBUS.
>

It's a bit strange to merge a selftest which is expected to fail
because of a known but unfixed kernel bug. But I'll toss the test
in there anyway, as we deserve to get bug reports ;)