diff mbox series

[3/3] selftests: Set overcommit_policy as OVERCOMMIT_ALWAYS

Message ID 20230314042351.13134-4-chaitanyas.prakash@arm.com (mailing list archive)
State Accepted
Commit d6c2789778c59c1768567099eb2fdd32d790c38a
Headers show
Series selftests: Fix virtual address range for arm64 | expand

Commit Message

Chaitanya S Prakash March 14, 2023, 4:23 a.m. UTC
The kernel's default behaviour is to obstruct the allocation of high
virtual address as it handles memory overcommit in a heuristic manner.
Setting the parameter as OVERCOMMIT_ALWAYS, ensures kernel isn't
susceptible to the availability of a platform's physical memory when
denying a memory allocation request.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: linux-mm@kvack.org
Cc: linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Chaitanya S Prakash <chaitanyas.prakash@arm.com>
---
 tools/testing/selftests/mm/run_vmtests.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

David Hildenbrand March 16, 2023, 3:31 p.m. UTC | #1
On 14.03.23 05:23, Chaitanya S Prakash wrote:
> The kernel's default behaviour is to obstruct the allocation of high
> virtual address as it handles memory overcommit in a heuristic manner.
> Setting the parameter as OVERCOMMIT_ALWAYS, ensures kernel isn't
> susceptible to the availability of a platform's physical memory when
> denying a memory allocation request.

Which tests in particular require that?

Subjects should start with "selftests/mm" instead of more generic 
"selftests:"
Chaitanya S Prakash March 20, 2023, 6:47 a.m. UTC | #2
On 3/16/23 21:01, David Hildenbrand wrote:
> On 14.03.23 05:23, Chaitanya S Prakash wrote:
>> The kernel's default behaviour is to obstruct the allocation of high
>> virtual address as it handles memory overcommit in a heuristic manner.
>> Setting the parameter as OVERCOMMIT_ALWAYS, ensures kernel isn't
>> susceptible to the availability of a platform's physical memory when
>> denying a memory allocation request.
> 
> Which tests in particular require that?

This is applicable to the virtual address range selftest.

> 
> Subjects should start with "selftests/mm" instead of more generic 
> "selftests:"

I'll make the necessary changes.
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 8984e0bb58c7..c0f93b668c0c 100644
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -220,7 +220,15 @@  CATEGORY="mremap" run_test ./mremap_test
 CATEGORY="hugetlb" run_test ./thuge-gen
 
 if [ $VADDR64 -ne 0 ]; then
+
+	# set overcommit_policy as OVERCOMMIT_ALWAYS so that kernel
+	# allows high virtual address allocation requests independent
+	# of platform's physical memory.
+
+	prev_policy=$(cat /proc/sys/vm/overcommit_memory)
+	echo 1 > /proc/sys/vm/overcommit_memory
 	CATEGORY="hugevm" run_test ./virtual_address_range
+	echo $prev_policy > /proc/sys/vm/overcommit_memory
 
 	# virtual address 128TB switch test
 	CATEGORY="hugevm" run_test ./va_128TBswitch.sh