All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests: mm: fix and speedup "droppable" test
@ 2026-06-11 10:01 David Hildenbrand (Arm)
  2026-06-11 11:07 ` Sarthak Sharma
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-11 10:01 UTC (permalink / raw)
  To: Andrew Morton, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Shuah Khan,
	Jason A. Donenfeld, Anthony Yznaga, Mark Brown, Sarthak Sharma
  Cc: linux-mm, linux-kselftest, linux-kernel, Aishwarya TCV,
	David Hildenbrand (Arm)

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")
Signed-off-by: David Hildenbrand (Arm) <david@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);
 			}
+			ksft_test_result_fail("madvise(MADV_PAGEOUT) error: %s\n", strerror(errno));
+			exit(KSFT_FAIL);
 		}
+
+		dropped = memchr(alloc, 'A', alloc_size) == NULL;
+
+		/*
+		 * Speculative reference can temporarily prevent some
+		 * pages from getting dropped. So sleep and retry.
+		 *
+		 * If a page is not droppable for 10s, something
+		 * is seriously messed up and we want to fail.
+		 */
+		if (dropped)
+			break;
+		sleep(1);
 	}
-	kill(child, SIGTERM);
 
-	ksft_test_result_pass("MAP_DROPPABLE: PASS\n");
-	exit(KSFT_PASS);
+	ksft_test_result(dropped, "madvise(MADV_PAGEOUT) behavior\n");
+
+	ksft_finished();
 }

---

base-commit: d401506a8ee8ac6bc4a7767c17da036e9434a4a3

change-id: 20260611-droppable_test-3737bd791dfb

--

Cheers,

David



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] selftests: mm: fix and speedup "droppable" test
  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:15 ` Lance Yang
  2026-06-11 11:19 ` Dev Jain
  2 siblings, 1 reply; 9+ messages in thread
From: Sarthak Sharma @ 2026-06-11 11:07 UTC (permalink / raw)
  To: David Hildenbrand (Arm), Andrew Morton, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Jason A. Donenfeld,
	Anthony Yznaga, Mark Brown
  Cc: linux-mm, linux-kselftest, linux-kernel, Aishwarya TCV



On 6/11/26 3:31 PM, David Hildenbrand (Arm) 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")
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> ---

I ran this test before and after applying the patch and recorded the
execution time over 5 runs on an Orion O6 board.

Before the patch, average execution time = 3.87 s
After the patch, average execution time = 0.02 s

Test results remain unaffected after this patch is applied and speedup
is observed.

Tested-by: Sarthak Sharma <sarthak.sharma@arm.com>

>  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);
>  			}
> +			ksft_test_result_fail("madvise(MADV_PAGEOUT) error: %s\n", strerror(errno));
> +			exit(KSFT_FAIL);
>  		}
> +
> +		dropped = memchr(alloc, 'A', alloc_size) == NULL;
> +
> +		/*
> +		 * Speculative reference can temporarily prevent some
> +		 * pages from getting dropped. So sleep and retry.
> +		 *
> +		 * If a page is not droppable for 10s, something
> +		 * is seriously messed up and we want to fail.
> +		 */
> +		if (dropped)
> +			break;
> +		sleep(1);
>  	}
> -	kill(child, SIGTERM);
>  
> -	ksft_test_result_pass("MAP_DROPPABLE: PASS\n");
> -	exit(KSFT_PASS);
> +	ksft_test_result(dropped, "madvise(MADV_PAGEOUT) behavior\n");
> +
> +	ksft_finished();
>  }
> 
> ---
> 
> base-commit: d401506a8ee8ac6bc4a7767c17da036e9434a4a3
> 
> change-id: 20260611-droppable_test-3737bd791dfb
> 
> --
> 
> Cheers,
> 
> David
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] selftests: mm: fix and speedup "droppable" test
  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:15 ` Lance Yang
  2026-06-11 11:19 ` Dev Jain
  2 siblings, 0 replies; 9+ messages in thread
From: Lance Yang @ 2026-06-11 11:15 UTC (permalink / raw)
  To: david
  Cc: akpm, ljs, liam, vbabka, rppt, surenb, mhocko, shuah, Jason,
	anthony.yznaga, broonie, sarthak.sharma, linux-mm,
	linux-kselftest, linux-kernel, Aishwarya.TCV, Lance Yang


On Thu, Jun 11, 2026 at 12:01:55PM +0200, David Hildenbrand (Arm) 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")
>Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
>---

Cool! Tested with swap both off and on, and it passed either way :D

That's what I'd expect, VM_DROPPABLE folios stay anon + non-swapbacked,
so reclaim can discard them instead of swapping them out :)

Tested-by: Lance Yang <lance.yang@linux.dev>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] selftests: mm: fix and speedup "droppable" test
  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:15 ` Lance Yang
@ 2026-06-11 11:19 ` Dev Jain
  2026-06-11 11:26   ` David Hildenbrand (Arm)
  2 siblings, 1 reply; 9+ messages in thread
From: Dev Jain @ 2026-06-11 11:19 UTC (permalink / raw)
  To: David Hildenbrand (Arm), Andrew Morton, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Jason A. Donenfeld,
	Anthony Yznaga, Mark Brown, Sarthak Sharma
  Cc: linux-mm, linux-kselftest, linux-kernel, Aishwarya TCV



On 11/06/26 3:31 pm, David Hildenbrand (Arm) 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")
> Signed-off-by: David Hildenbrand (Arm) <david@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);
>  			}
> +			ksft_test_result_fail("madvise(MADV_PAGEOUT) error: %s\n", strerror(errno));
> +			exit(KSFT_FAIL);
>  		}
> +
> +		dropped = memchr(alloc, 'A', alloc_size) == NULL;
> +
> +		/*
> +		 * Speculative reference can temporarily prevent some
> +		 * pages from getting dropped. So sleep and retry.
> +		 *
> +		 * If a page is not droppable for 10s, something
> +		 * is seriously messed up and we want to fail.
> +		 */
> +		if (dropped)
> +			break;
> +		sleep(1);
>  	}
> -	kill(child, SIGTERM);
>  
> -	ksft_test_result_pass("MAP_DROPPABLE: PASS\n");
> -	exit(KSFT_PASS);
> +	ksft_test_result(dropped, "madvise(MADV_PAGEOUT) behavior\n");

You meant "MAP_DROPPABLE" behaviour? Perhaps that can be folded in.

Otherwise LGTM.

Reviewed-by: Dev Jain <dev.jain@arm.com>


> +
> +	ksft_finished();
>  }
> 
> ---
> 
> base-commit: d401506a8ee8ac6bc4a7767c17da036e9434a4a3
> 
> change-id: 20260611-droppable_test-3737bd791dfb
> 
> --
> 
> Cheers,
> 
> David
> 
> 



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] selftests: mm: fix and speedup "droppable" test
  2026-06-11 11:19 ` Dev Jain
@ 2026-06-11 11:26   ` David Hildenbrand (Arm)
  2026-06-11 11:28     ` Dev Jain
  0 siblings, 1 reply; 9+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-11 11:26 UTC (permalink / raw)
  To: Dev Jain, Andrew Morton, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Shuah Khan, Jason A. Donenfeld, Anthony Yznaga, Mark Brown,
	Sarthak Sharma
  Cc: linux-mm, linux-kselftest, linux-kernel, Aishwarya TCV

>> +		/*
>> +		 * Speculative reference can temporarily prevent some
>> +		 * pages from getting dropped. So sleep and retry.
>> +		 *
>> +		 * If a page is not droppable for 10s, something
>> +		 * is seriously messed up and we want to fail.
>> +		 */
>> +		if (dropped)
>> +			break;
>> +		sleep(1);
>>  	}
>> -	kill(child, SIGTERM);
>>  
>> -	ksft_test_result_pass("MAP_DROPPABLE: PASS\n");
>> -	exit(KSFT_PASS);
>> +	ksft_test_result(dropped, "madvise(MADV_PAGEOUT) behavior\n");
> 
> You meant "MAP_DROPPABLE" behaviour? Perhaps that can be folded in.

No, I did mean "madvise(MADV_PAGEOUT)" behaves as expected with droppable pages.

Reasoning being that we might want to add some other tests in the future that
trigger reclaim differently.

Thanks!

-- 
Cheers,

David

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] selftests: mm: fix and speedup "droppable" test
  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
  0 siblings, 2 replies; 9+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-11 11:26 UTC (permalink / raw)
  To: Sarthak Sharma, Andrew Morton, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Shuah Khan, Jason A. Donenfeld, Anthony Yznaga, Mark Brown
  Cc: linux-mm, linux-kselftest, linux-kernel, Aishwarya TCV

On 6/11/26 13:07, Sarthak Sharma wrote:
> 
> 
> On 6/11/26 3:31 PM, David Hildenbrand (Arm) 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")
>> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
>> ---
> 
> I ran this test before and after applying the patch and recorded the
> execution time over 5 runs on an Orion O6 board.
> 

Thanks!

> Before the patch, average execution time = 3.87 s

Out of interest, how much memory did your machine have?

I ran into this myself on a 200gig machine, and there was essentially no
progress ...

-- 
Cheers,

David

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] selftests: mm: fix and speedup "droppable" test
  2026-06-11 11:26   ` David Hildenbrand (Arm)
@ 2026-06-11 11:28     ` Dev Jain
  0 siblings, 0 replies; 9+ messages in thread
From: Dev Jain @ 2026-06-11 11:28 UTC (permalink / raw)
  To: David Hildenbrand (Arm), Andrew Morton, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Jason A. Donenfeld,
	Anthony Yznaga, Mark Brown, Sarthak Sharma
  Cc: linux-mm, linux-kselftest, linux-kernel, Aishwarya TCV



On 11/06/26 4:56 pm, David Hildenbrand (Arm) wrote:
>>> +		/*
>>> +		 * Speculative reference can temporarily prevent some
>>> +		 * pages from getting dropped. So sleep and retry.
>>> +		 *
>>> +		 * If a page is not droppable for 10s, something
>>> +		 * is seriously messed up and we want to fail.
>>> +		 */
>>> +		if (dropped)
>>> +			break;
>>> +		sleep(1);
>>>  	}
>>> -	kill(child, SIGTERM);
>>>  
>>> -	ksft_test_result_pass("MAP_DROPPABLE: PASS\n");
>>> -	exit(KSFT_PASS);
>>> +	ksft_test_result(dropped, "madvise(MADV_PAGEOUT) behavior\n");
>>
>> You meant "MAP_DROPPABLE" behaviour? Perhaps that can be folded in.
> 
> No, I did mean "madvise(MADV_PAGEOUT)" behaves as expected with droppable pages.
> 
> Reasoning being that we might want to add some other tests in the future that
> trigger reclaim differently.

Makes sense.


> 
> Thanks!
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] selftests: mm: fix and speedup "droppable" test
  2026-06-11 11:26   ` David Hildenbrand (Arm)
@ 2026-06-11 11:32     ` Lance Yang
  2026-06-11 12:13     ` Sarthak Sharma
  1 sibling, 0 replies; 9+ messages in thread
From: Lance Yang @ 2026-06-11 11:32 UTC (permalink / raw)
  To: david
  Cc: sarthak.sharma, akpm, ljs, liam, vbabka, rppt, surenb, mhocko,
	shuah, Jason, anthony.yznaga, broonie, linux-mm, linux-kselftest,
	linux-kernel, Aishwarya.TCV, Lance Yang


On Thu, Jun 11, 2026 at 01:26:57PM +0200, David Hildenbrand (Arm) wrote:
>On 6/11/26 13:07, Sarthak Sharma wrote:
>> 
>> 
>> On 6/11/26 3:31 PM, David Hildenbrand (Arm) 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")
>>> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
>>> ---
>> 
>> I ran this test before and after applying the patch and recorded the
>> execution time over 5 runs on an Orion O6 board.
>> 
>
>Thanks!
>
>> Before the patch, average execution time = 3.87 s
>
>Out of interest, how much memory did your machine have?
>
>I ran into this myself on a 200gig machine, and there was essentially no
>progress ...

Same here ... With the old test, I waited a quite a while and didn't see
any progress ...  on a 512 GiB machine.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] selftests: mm: fix and speedup "droppable" test
  2026-06-11 11:26   ` David Hildenbrand (Arm)
  2026-06-11 11:32     ` Lance Yang
@ 2026-06-11 12:13     ` Sarthak Sharma
  1 sibling, 0 replies; 9+ messages in thread
From: Sarthak Sharma @ 2026-06-11 12:13 UTC (permalink / raw)
  To: David Hildenbrand (Arm), Andrew Morton, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Jason A. Donenfeld,
	Anthony Yznaga, Mark Brown
  Cc: linux-mm, linux-kselftest, linux-kernel, Aishwarya TCV



On 6/11/26 4:56 PM, David Hildenbrand (Arm) wrote:
> On 6/11/26 13:07, Sarthak Sharma wrote:
>>
>>
>> On 6/11/26 3:31 PM, David Hildenbrand (Arm) 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")
>>> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
>>> ---
>>
>> I ran this test before and after applying the patch and recorded the
>> execution time over 5 runs on an Orion O6 board.
>>
> 
> Thanks!
> 
>> Before the patch, average execution time = 3.87 s
> 
> Out of interest, how much memory did your machine have?
> 
> I ran into this myself on a 200gig machine, and there was essentially no
> progress ...
> 

My board has about 15 GiB of RAM.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-06-11 12:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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.