* [LTP] [PATCH] mem/overcommit_memory.c: Fix "CommitLimit < Committed_AS" error in some situations
@ 2018-10-19 8:44 Xiao Yang
2018-12-03 20:27 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Xiao Yang @ 2018-10-19 8:44 UTC (permalink / raw)
To: ltp
By default, system with overcommit_memory=2 will ensure "CommitLimit >=
Committed_AS" when setting overcommit_ratio. But we change overcommit_ratio
to a random value forcely, so it's possible to decrease CommitLimit less
than current Committed_AS when setting overcommit_ratio to a quite small
value(e.g. 0).
For example, there are 5G physical memory, 4G swap and 5G allocated memory
(i.e. Committed_AS) on system, and then running overcommit_memory02(i.e.
overcommit_memory -R 0) always triggers the "CommitLimit < Committed_AS"
error:
----------------------------------------------------------------------
mem.c:839: INFO: set overcommit_ratio to 0
mem.c:839: INFO: set overcommit_memory to 2
overcommit_memory.c:235: INFO: CommitLimit is 4194300, Committed_AS is 5405908
overcommit_memory.c:237: BROK: Unexpected error: CommitLimit < Committed_AS
----------------------------------------------------------------------
We try to skip test if setting a small value of overcommit_ratio results in
"CommitLimit < Committed_AS".
Fix: #215
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
.../kernel/mem/tunable/overcommit_memory.c | 30 ++++++++++++-------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/testcases/kernel/mem/tunable/overcommit_memory.c b/testcases/kernel/mem/tunable/overcommit_memory.c
index 82ceac5f6..b92232b8d 100644
--- a/testcases/kernel/mem/tunable/overcommit_memory.c
+++ b/testcases/kernel/mem/tunable/overcommit_memory.c
@@ -92,6 +92,7 @@ static long commit_left;
static int heavy_malloc(long size);
static void alloc_and_check(long size, int expect_result);
static void update_mem(void);
+static void update_mem_commit(void);
static void setup(void)
{
@@ -151,10 +152,10 @@ static void overcommit_memory_test(void)
/* start to test overcommit_memory=2 */
set_sys_tune("overcommit_memory", 2, 1);
- update_mem();
+ update_mem_commit();
alloc_and_check(commit_left * 2, EXPECT_FAIL);
alloc_and_check(commit_limit, EXPECT_FAIL);
- update_mem();
+ update_mem_commit();
alloc_and_check(commit_left / 2, EXPECT_PASS);
/* start to test overcommit_memory=0 */
@@ -219,23 +220,32 @@ static void alloc_and_check(long size, int expect_result)
static void update_mem(void)
{
long mem_free, swap_free;
- long committed;
mem_free = SAFE_READ_MEMINFO("MemFree:");
swap_free = SAFE_READ_MEMINFO("SwapFree:");
free_total = mem_free + swap_free;
+}
+
+static void update_mem_commit(void)
+{
+ long committed;
+
commit_limit = SAFE_READ_MEMINFO("CommitLimit:");
+ committed = SAFE_READ_MEMINFO("Committed_AS:");
+ commit_left = commit_limit - committed;
- if (get_sys_tune("overcommit_memory") == 2) {
- committed = SAFE_READ_MEMINFO("Committed_AS:");
- commit_left = commit_limit - committed;
+ if (commit_left < 0) {
+ tst_res(TINFO, "CommitLimit is %ld, Committed_AS is %ld",
+ commit_limit, committed);
- if (commit_left < 0) {
- tst_res(TINFO, "CommitLimit is %ld, Committed_AS"
- " is %ld", commit_limit, committed);
+ if (overcommit_ratio > old_overcommit_ratio) {
tst_brk(TBROK, "Unexpected error: "
- "CommitLimit < Committed_AS");
+ "CommitLimit < Committed_AS");
}
+
+ tst_brk(TCONF, "Specified overcommit_ratio %ld < default %ld, "
+ "so it's possible for CommitLimit < Committed_AS and "
+ "skip test", overcommit_ratio, old_overcommit_ratio);
}
}
--
2.17.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] mem/overcommit_memory.c: Fix "CommitLimit < Committed_AS" error in some situations
2018-10-19 8:44 [LTP] [PATCH] mem/overcommit_memory.c: Fix "CommitLimit < Committed_AS" error in some situations Xiao Yang
@ 2018-12-03 20:27 ` Petr Vorel
2018-12-20 10:42 ` Cristian Marussi
0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2018-12-03 20:27 UTC (permalink / raw)
To: ltp
Hi Xiao,
> By default, system with overcommit_memory=2 will ensure "CommitLimit >=
> Committed_AS" when setting overcommit_ratio. But we change overcommit_ratio
> to a random value forcely, so it's possible to decrease CommitLimit less
> than current Committed_AS when setting overcommit_ratio to a quite small
> value(e.g. 0).
> For example, there are 5G physical memory, 4G swap and 5G allocated memory
> (i.e. Committed_AS) on system, and then running overcommit_memory02(i.e.
> overcommit_memory -R 0) always triggers the "CommitLimit < Committed_AS"
> error:
> ----------------------------------------------------------------------
> mem.c:839: INFO: set overcommit_ratio to 0
> mem.c:839: INFO: set overcommit_memory to 2
> overcommit_memory.c:235: INFO: CommitLimit is 4194300, Committed_AS is 5405908
> overcommit_memory.c:237: BROK: Unexpected error: CommitLimit < Committed_AS
> ----------------------------------------------------------------------
> We try to skip test if setting a small value of overcommit_ratio results in
> "CommitLimit < Committed_AS".
> Fix: #215
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> ---
> .../kernel/mem/tunable/overcommit_memory.c | 30 ++++++++++++-------
> 1 file changed, 20 insertions(+), 10 deletions(-)
Kind regards,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] mem/overcommit_memory.c: Fix "CommitLimit < Committed_AS" error in some situations
2018-12-03 20:27 ` Petr Vorel
@ 2018-12-20 10:42 ` Cristian Marussi
2018-12-20 12:03 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Cristian Marussi @ 2018-12-20 10:42 UTC (permalink / raw)
To: ltp
Hi
On 03/12/2018 20:27, Petr Vorel wrote:
> Hi Xiao,
>
>> By default, system with overcommit_memory=2 will ensure "CommitLimit >=
>> Committed_AS" when setting overcommit_ratio. But we change overcommit_ratio
>> to a random value forcely, so it's possible to decrease CommitLimit less
>> than current Committed_AS when setting overcommit_ratio to a quite small
>> value(e.g. 0).
>
>> For example, there are 5G physical memory, 4G swap and 5G allocated memory
>> (i.e. Committed_AS) on system, and then running overcommit_memory02(i.e.
>> overcommit_memory -R 0) always triggers the "CommitLimit < Committed_AS"
>> error:
>> ----------------------------------------------------------------------
>> mem.c:839: INFO: set overcommit_ratio to 0
>> mem.c:839: INFO: set overcommit_memory to 2
>> overcommit_memory.c:235: INFO: CommitLimit is 4194300, Committed_AS is 5405908
>> overcommit_memory.c:237: BROK: Unexpected error: CommitLimit < Committed_AS
>> ----------------------------------------------------------------------
>
>> We try to skip test if setting a small value of overcommit_ratio results in
>> "CommitLimit < Committed_AS".
>
>> Fix: #215
>
>> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
Any chance this reviewed/fixed patch will be merged soon ?
Thanks
Cristian
>
>> ---
>> .../kernel/mem/tunable/overcommit_memory.c | 30 ++++++++++++-------
>> 1 file changed, 20 insertions(+), 10 deletions(-)
>
>
> Kind regards,
> Petr
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] mem/overcommit_memory.c: Fix "CommitLimit < Committed_AS" error in some situations
2018-12-20 10:42 ` Cristian Marussi
@ 2018-12-20 12:03 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2018-12-20 12:03 UTC (permalink / raw)
To: ltp
Hi Xiao, Cristian,
> Any chance this reviewed/fixed patch will be merged soon ?
Thanks for pointing out. Pushed, with following diff bellow.
(TCONF is for <=, not <).
> Thanks
> Cristian
Kind regards,
Petr
diff --git testcases/kernel/mem/tunable/overcommit_memory.c testcases/kernel/mem/tunable/overcommit_memory.c
index b92232b8d..07f824328 100644
--- testcases/kernel/mem/tunable/overcommit_memory.c
+++ testcases/kernel/mem/tunable/overcommit_memory.c
@@ -243,9 +243,9 @@ static void update_mem_commit(void)
"CommitLimit < Committed_AS");
}
- tst_brk(TCONF, "Specified overcommit_ratio %ld < default %ld, "
- "so it's possible for CommitLimit < Committed_AS and "
- "skip test", overcommit_ratio, old_overcommit_ratio);
+ tst_brk(TCONF, "Specified overcommit_ratio %ld <= default %ld, "
+ "so it's possible for CommitLimit < Committed_AS and skip test",
+ overcommit_ratio, old_overcommit_ratio);
}
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-20 12:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-19 8:44 [LTP] [PATCH] mem/overcommit_memory.c: Fix "CommitLimit < Committed_AS" error in some situations Xiao Yang
2018-12-03 20:27 ` Petr Vorel
2018-12-20 10:42 ` Cristian Marussi
2018-12-20 12:03 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox