Skip to contentSkip to conversation

mtest06/mmap1: Further limit distant mmap size

PATCH New Thadeu Lima de Souza Cascardo 3 participants 5 messages May 19, 2021 – May 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtest06/mmap1: Further limit distant mmap size

Though on recent kernels (starting with 5.2, commit 8c7829b04c523cdc732cb77f59f03320e09f3386 ("mm: fix false-positive OVERCOMMIT_GUESS failures"), overcommit accounting allows for allocating up to MemTotal memory, older kernels have a much more complicated overcommit guess accounting.

That leads to mmap failing on small enough systems:

mmap1.c:205: TBROK: mmap((nil),2088370176,3,34,-1,0) failed: ENOMEM (12)

Allocating only half of the total memory would generally work on test systems.

---
 testcases/kernel/mem/mtest06/mmap1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/mem/mtest06/mmap1.c +2 -2
index 56588e1ebaff..10c47c35cb02 100644
@@ -186,7 +186,7 @@ static void setup(void)
 {
 	struct sigaction sigptr;
 	size_t distant_mmap_size;
-	long mem_total;
+	size_t mem_total;
 
 	page_sz = getpagesize();
 	mem_total = SAFE_READ_MEMINFO("MemTotal:");
@@ -195,7 +195,7 @@ static void setup(void)
 #ifdef TST_ABI32
 	distant_mmap_size = 256*1024*1024;
 #else
-	distant_mmap_size = (mem_total > 2 * GIGABYTE) ? 2 * GIGABYTE : mem_total;
+	distant_mmap_size = (mem_total > 4 * GIGABYTE) ? 2 * GIGABYTE : mem_total / 2;
 #endif
 	/*
 	 * Used as hint for mmap thread, so it doesn't interfere
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/1 mtest06/mmap1: Further limit distant mmap size

Quoted 7 lines · Thadeu Lima de Souza Cascardo

Though on recent kernels (starting with 5.2, commit 8c7829b04c523cdc732cb77f59f03320e09f3386 ("mm: fix false-positive OVERCOMMIT_GUESS failures"), overcommit accounting allows for allocating up to MemTotal memory, older kernels have a much more complicated overcommit guess accounting.

Quoted 8 lines

That leads to mmap failing on small enough systems:

mmap1.c:205: TBROK: mmap((nil),2088370176,3,34,-1,0) failed: ENOMEM (12)

Allocating only half of the total memory would generally work on test systems.

Thanks for patch.

#2 lore raw

PATCH 1/1 mtest06/mmap1: Further limit distant mmap size

Hi!

Quoted 10 lines
Quoted 10 lines

Though on recent kernels (starting with 5.2, commit 8c7829b04c523cdc732cb77f59f03320e09f3386 ("mm: fix false-positive OVERCOMMIT_GUESS failures"), overcommit accounting allows for allocating up to MemTotal memory, older kernels have a much more complicated overcommit guess accounting.

That leads to mmap failing on small enough systems:

mmap1.c:205: TBROK: mmap((nil),2088370176,3,34,-1,0) failed: ENOMEM (12)

Quoted 8 lines
Quoted 4 lines

Allocating only half of the total memory would generally work on test systems.

Thanks for patch.

Looks safe enough for the release, as far as I can tell the test shouldn't care at all where we map the block of memory.

Jan looks like you originaly wrote the test, do you agree that this should go in now?

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 1/1 mtest06/mmap1: Further limit distant mmap size

Quoted 19 lines · Cyril Hrubis

Hi!

Quoted 17 lines
Quoted 6 lines

Though on recent kernels (starting with 5.2, commit 8c7829b04c523cdc732cb77f59f03320e09f3386 ("mm: fix false-positive OVERCOMMIT_GUESS failures"), overcommit accounting allows for allocating up to MemTotal memory, older kernels have a much more complicated overcommit guess accounting.

Quoted 8 lines

That leads to mmap failing on small enough systems:

mmap1.c:205: TBROK: mmap((nil),2088370176,3,34,-1,0) failed: ENOMEM (12)

Allocating only half of the total memory would generally work on test systems.

Thanks for patch.

Quoted 7 lines
Quoted 1 line

Looks safe enough for the release, as far as I can tell the test shouldn't care at all where we map the block of memory.

Jan looks like you originaly wrote the test, do you agree that this should go in now?

That's fine by me. As you said, the change in size doesn't matter that much for the test.

Quoted 5 lines

--
Cyril Hrubis
[email protected]