From: SeongJae Park <sj@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: SeongJae Park <sj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Anthony Yznaga <anthony.yznaga@oracle.com>,
Mark Brown <broonie@kernel.org>,
Sarthak Sharma <sarthak.sharma@arm.com>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Aishwarya TCV <Aishwarya.TCV@arm.com>
Subject: Re: [PATCH] selftests: mm: fix and speedup "droppable" test
Date: Thu, 11 Jun 2026 18:29:10 -0700 [thread overview]
Message-ID: <20260612012910.84424-1-sj@kernel.org> (raw)
In-Reply-To: <20260611-droppable_test-v1-1-b6a73d99f658@kernel.org>
On Thu, 11 Jun 2026 12:01:55 +0200 "David Hildenbrand (Arm)" <david@kernel.org> wrote:
> The droppable test currently relies on creating memory pressure in a
> child process to trigger dropping the droppable pages.
>
> That not only takes a long time on some machines (allocating and filling
> all that memory), on large machines this will not work as we hardcode the
> area size to 134217728 bytes.
>
> ... further, we rely on timeouts to detect that memory was not dropped,
> which is really suboptimal.
>
> Instead, let's just use MADV_PAGEOUT on a 2 MiB region. MADV_PAGEOUT works
> with droppable memory even without swap.
>
> There is the low chance of MADV_PAGEOUT failing to drop a page because
> of speculative references. We'll wait 1s and retry 10 times to
> rule that unlikely case out as best as we can.
>
> On a machine without swap:
>
> $ ./droppable
> TAP version 13
> 1..1
> ok 1 madvise(MADV_PAGEOUT) behavior
> # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>
> Reported-by: Aishwarya TCV <Aishwarya.TCV@arm.com>
> Fixes: 9651fcedf7b9 ("mm: add MAP_DROPPABLE for designating always lazily freeable mappings")
Because this is a fix for a test, I think not Cc-ing stable@ is ok. Further,
arguably this is not a fix but an improvement? No strong opinion, just
thinking loud.
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: SeongJae Park <sj@kernel.org>
> ---
> tools/testing/selftests/mm/droppable.c | 46 +++++++++++++++++++---------------
> 1 file changed, 26 insertions(+), 20 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/droppable.c b/tools/testing/selftests/mm/droppable.c
> index 30c8be37fcb9..57e1b6fc5569 100644
> --- a/tools/testing/selftests/mm/droppable.c
> +++ b/tools/testing/selftests/mm/droppable.c
> @@ -17,10 +17,10 @@
>
> int main(int argc, char *argv[])
> {
> - size_t alloc_size = 134217728;
> - size_t page_size = getpagesize();
> + const size_t alloc_size = 2 * 1024 * 1024;
> + int retry_count = 10;
> + bool dropped;
> void *alloc;
> - pid_t child;
>
> ksft_print_header();
> ksft_set_plan(1);
> @@ -35,26 +35,32 @@ int main(int argc, char *argv[])
> exit(KSFT_FAIL);
> }
> memset(alloc, 'A', alloc_size);
> - for (size_t i = 0; i < alloc_size; i += page_size)
> - assert(*(uint8_t *)(alloc + i));
> -
> - child = fork();
> - assert(child >= 0);
> - if (!child) {
> - for (;;)
> - *(char *)malloc(page_size) = 'B';
> - }
>
> - for (bool done = false; !done;) {
> - for (size_t i = 0; i < alloc_size; i += page_size) {
> - if (!*(uint8_t *)(alloc + i)) {
> - done = true;
> - break;
> + while (retry_count--) {
> + if (madvise(alloc, alloc_size, MADV_PAGEOUT)) {
> + if (errno == EINVAL) {
> + ksft_test_result_skip("madvise(MADV_PAGEOUT) not supported\n");
> + exit(KSFT_SKIP);
This check is for a case that this test is running against an old kernel that
doesn't have MADV_PAGEOUT?
Assuming so, I was first thinking this check might not really needed, assuming
the test runner would pick the kselftest code from the running kernel's source
code. But I recalled some people do get kselftest code from random place. So
this check seems nice to me.
Just thinking loud.
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-06-12 1:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 10:01 [PATCH] selftests: mm: fix and speedup "droppable" test David Hildenbrand (Arm)
2026-06-11 11:07 ` Sarthak Sharma
2026-06-11 11:26 ` David Hildenbrand (Arm)
2026-06-11 11:32 ` Lance Yang
2026-06-11 12:13 ` Sarthak Sharma
2026-06-11 11:15 ` Lance Yang
2026-06-11 11:19 ` Dev Jain
2026-06-11 11:26 ` David Hildenbrand (Arm)
2026-06-11 11:28 ` Dev Jain
2026-06-12 1:29 ` SeongJae Park [this message]
2026-06-12 7:35 ` David Hildenbrand (Arm)
2026-06-12 7:58 ` Lorenzo Stoakes
2026-06-12 8:00 ` David Hildenbrand (Arm)
2026-06-12 8:26 ` Lorenzo Stoakes
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=20260612012910.84424-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=Aishwarya.TCV@arm.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=anthony.yznaga@oracle.com \
--cc=broonie@kernel.org \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=sarthak.sharma@arm.com \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@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 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.