blob: bed84712a15d9751664639c021db423f38c2146a [file] [log] [blame]
Brad Bishop64c979e2019-11-04 13:55:29 -05001From d656a447893dccc310c975a239f482278550c3e0 Mon Sep 17 00:00:00 2001
2From: Jan Stancek <jstancek@redhat.com>
3Date: Tue, 21 May 2019 10:10:44 +0200
4Subject: [PATCH] overcommit_memory: update for "mm: fix false-positive
5 OVERCOMMIT_GUESS failures"
6
7commit 8c7829b04c52 ("mm: fix false-positive OVERCOMMIT_GUESS failures")
8changes logic of __vm_enough_memory(), simplifying it to:
9 When in GUESS mode, catch wild allocations by comparing their request
10 size to total amount of ram and swap in the system.
11
12Testcase currently allocates mem_total + swap_total, which doesn't trigger
13new condition. Make it more extreme, but assuming free_total / 2 will PASS,
14and 2*sum_total will FAIL.
15
16Signed-off-by: Jan Stancek <jstancek@redhat.com>
17Acked-by: Cyril Hrubis <chrubis@suse.cz>
18
19Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/d656a447893dccc310c975a239f482278550c3e0]
20Signed-off-by: He Zhe <zhe.he@windriver.com>
21---
22 testcases/kernel/mem/tunable/overcommit_memory.c | 11 ++++-------
23 1 file changed, 4 insertions(+), 7 deletions(-)
24
25diff --git a/testcases/kernel/mem/tunable/overcommit_memory.c b/testcases/kernel/mem/tunable/overcommit_memory.c
26index 555298f..345764d 100644
27--- a/testcases/kernel/mem/tunable/overcommit_memory.c
28+++ b/testcases/kernel/mem/tunable/overcommit_memory.c
29@@ -36,11 +36,10 @@
30 *
31 * The program is designed to test the two tunables:
32 *
33- * When overcommit_memory = 0, allocatable memory can't overextends
34- * the amount of free memory. I choose the three cases:
35+ * When overcommit_memory = 0, allocatable memory can't overextend
36+ * the amount of total memory:
37 * a. less than free_total: free_total / 2, alloc should pass.
38- * b. greater than free_total: free_total * 2, alloc should fail.
39- * c. equal to sum_total: sum_tatal, alloc should fail
40+ * b. greater than sum_total: sum_total * 2, alloc should fail.
41 *
42 * When overcommit_memory = 1, it can alloc enough much memory, I
43 * choose the three cases:
44@@ -164,9 +163,7 @@ static void overcommit_memory_test(void)
45
46 update_mem();
47 alloc_and_check(free_total / 2, EXPECT_PASS);
48- update_mem();
49- alloc_and_check(free_total * 2, EXPECT_FAIL);
50- alloc_and_check(sum_total, EXPECT_FAIL);
51+ alloc_and_check(sum_total * 2, EXPECT_FAIL);
52
53 /* start to test overcommit_memory=1 */
54 set_sys_tune("overcommit_memory", 1, 1);
55--
562.7.4
57