Skip to contentSkip to conversation

getrusage03: skip on small RAM system

PATCH In review Li Wang 4 participants 10 messages Feb 7, 2022 – Feb 8, 2022

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 getrusage03: skip on small RAM system

It is easy to get VmSwap increase with a small system, here is run with a 1G RAM kvm guest and TBROK:

    7	tst_test.c:1365: TINFO: Timeout per run is 0h 05m 00s
    8	getrusage03.c:43: TPASS: initial.self ~= child.self
    9	getrusage03.c:57: TPASS: initial.children ~= 100MB
    10	getrusage03.c:66: TPASS: child.children == 0
    11	getrusage03.c:84: TPASS: child.children ~= 300MB
    12	getrusage03.c:104: TPASS: initial.children ~= pre_wait.children
    13	getrusage03.c:112: TPASS: post_wait.children ~= 400MB
    14	getrusage03.h:25: TBROK: VmSwap is not zero
    15	getrusage03.c:133: TPASS: initial.children ~= after_zombie.children
    16	getrusage03.h:25: TBROK: VmSwap is not zero
    17	getrusage03_child.c:57: TPASS: initial.self ~= exec.self
    18	getrusage03_child.c:62: TPASS: initial.children ~= exec.children

---

Notes:
Ps. I also think we might need .min_mem_[avai|total] field but
not sure if it is really necessary to add that.

 testcases/kernel/syscalls/getrusage/getrusage03.c | 9 +++++++++
 1 file changed, 9 insertions(+)
testcases/kernel/syscalls/getrusage/getrusage03.c +9 -0
index bf5127483..5aa0b2326 100644
@@ -173,6 +173,14 @@ static void run(unsigned int i)
 	}
 }
 
+static void setup(void)
+{
+	long long mem_avail = tst_available_mem();
+
+	if (mem_avail < 512L*1024)
+		tst_brk(TCONF, "Needed > 512MB availabe, only have: %ld kB", mem_avail);
+}
+
 static struct tst_test test = {
 	.forks_child = 1,
 	.child_needs_reinit = 1,
@@ -182,6 +190,7 @@ static struct tst_test test = {
 		{"linux-git", "1f10206cf8e9"},
 		{}
 	},
+	.setup = setup,
 	.test = run,
 	.tcnt = ARRAY_SIZE(testfunc_list),
 };
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw

Hi Li,

Quoted 3 lines

Notes:
Ps. I also think we might need .min_mem_[avai|total] field but
not sure if it is really necessary to add that.

Is it just a single test? Than maybe not worth of it, but generally I'm for adding tags like this into the library - it encapsulates code and gives us a documentation in docparse.

...

testcases/kernel/syscalls/getrusage/getrusage03.c static void run(unsigned int i) · line 181

Quoted 6 lines
testcases/kernel/syscalls/getrusage/getrusage03.c +6 -0
+static void setup(void)
+{
+	long long mem_avail = tst_available_mem();
+
+	if (mem_avail < 512L*1024)
+		tst_brk(TCONF, "Needed > 512MB availabe, only have: %ld kB", mem_avail);

typo: s/availabe/available/

Thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#2 lore raw
Quoted 7 lines · Petr Vorel

Hi Li,

Quoted 3 lines

Notes:
Ps. I also think we might need .min_mem_[avai|total] field but
not sure if it is really necessary to add that.

Is it just a single test? Than maybe not worth of it, but generally I'm for

By now I only see sporadic tests have this requirement. (hugeshmat04.c, swapping01.c, getrusage03.c)

Quoted 4 lines

adding tags like this into the library - it encapsulates code and gives us a
documentation in docparse.

Agree, maybe just holding as a future plan for adding that.

Quoted 10 lines

...

testcases/kernel/syscalls/getrusage/getrusage03.c static void run(unsigned int i)

Quoted 6 lines
testcases/kernel/syscalls/getrusage/getrusage03.c +6 -0
+static void setup(void)
+{
+     long long mem_avail = tst_available_mem();
+
+     if (mem_avail < 512L*1024)
+             tst_brk(TCONF, "Needed > 512MB availabe, only have: %ld

kB", mem_avail);
typo: s/availabe/available/

Thanks.

Quoted 9 lines

Thanks!

Kind regards,
Petr

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Hi Li,

Quoted 13 lines · Petr Vorel
Quoted 7 lines

Hi Li,

Quoted 3 lines

Notes:
Ps. I also think we might need .min_mem_[avai|total] field but
not sure if it is really necessary to add that.

Is it just a single test? Than maybe not worth of it, but generally I'm for

By now I only see sporadic tests have this requirement. (hugeshmat04.c, swapping01.c, getrusage03.c)

Quoted 6 lines
Quoted 3 lines

adding tags like this into the library - it encapsulates code and gives us a
documentation in docparse.

Agree, maybe just holding as a future plan for adding that.

IMHO more than two are enough to put it into library, but others might think differently.
Also sure, feel free to merge this fix, library support can be done any time later.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Acked-by on v1 1/1
#4 lore raw
In reply to Li Wang
Quoted 17 lines · Li Wang

It is easy to get VmSwap increase with a small system, here is run with a 1G RAM kvm guest and TBROK:

    7   tst_test.c:1365: TINFO: Timeout per run is 0h 05m 00s
    8   getrusage03.c:43: TPASS: initial.self ~= child.self
    9   getrusage03.c:57: TPASS: initial.children ~= 100MB
    10  getrusage03.c:66: TPASS: child.children == 0
    11  getrusage03.c:84: TPASS: child.children ~= 300MB
    12  getrusage03.c:104: TPASS: initial.children ~= pre_wait.children
    13  getrusage03.c:112: TPASS: post_wait.children ~= 400MB
    14  getrusage03.h:25: TBROK: VmSwap is not zero
    15  getrusage03.c:133: TPASS: initial.children ~= after_zombie.children
    16  getrusage03.h:25: TBROK: VmSwap is not zero
    17  getrusage03_child.c:57: TPASS: initial.self ~= exec.self
    18  getrusage03_child.c:62: TPASS: initial.children ~= exec.children
Quoted 1 line

This should fix the immediate failure, just wondering, would there be any downside of replacing that TBROK with TCONF?

Quoted 43 lines

---

Notes:
Ps. I also think we might need .min_mem_[avai|total] field but
not sure if it is really necessary to add that.

 testcases/kernel/syscalls/getrusage/getrusage03.c | 9 +++++++++
 1 file changed, 9 insertions(+)
testcases/kernel/syscalls/getrusage/getrusage03.c +9 -1
index bf5127483..5aa0b2326 100644
@@ -173,6 +173,14 @@ static void run(unsigned int i)
        }
 }
 
+static void setup(void)
+{
+       long long mem_avail = tst_available_mem();
+
+       if (mem_avail < 512L*1024)
+               tst_brk(TCONF, "Needed > 512MB availabe, only have: %ld kB", mem_avail);
+}
+
 static struct tst_test test = {
        .forks_child = 1,
        .child_needs_reinit = 1,
@@ -182,6 +190,7 @@ static struct tst_test test = {
                {"linux-git", "1f10206cf8e9"},
                {}
        },
+       .setup = setup,
        .test = run,
        .tcnt = ARRAY_SIZE(testfunc_list),
 };
--

2.31.1

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw
Quoted 19 lines · Jan Stancek
Quoted 4 lines · Li Wang

It is easy to get VmSwap increase with a small system, here is run with a 1G RAM kvm guest and TBROK:

Quoted 9 lines
    7   tst_test.c:1365: TINFO: Timeout per run is 0h 05m 00s
    8   getrusage03.c:43: TPASS: initial.self ~= child.self
    9   getrusage03.c:57: TPASS: initial.children ~= 100MB
    10  getrusage03.c:66: TPASS: child.children == 0
    11  getrusage03.c:84: TPASS: child.children ~= 300MB
    12  getrusage03.c:104: TPASS: initial.children ~= pre_wait.children
    13  getrusage03.c:112: TPASS: post_wait.children ~= 400MB
    14  getrusage03.h:25: TBROK: VmSwap is not zero
    15  getrusage03.c:133: TPASS: initial.children ~=

after_zombie.children

Quoted 4 lines
    16  getrusage03.h:25: TBROK: VmSwap is not zero
    17  getrusage03_child.c:57: TPASS: initial.self ~= exec.self
    18  getrusage03_child.c:62: TPASS: initial.children ~= exec.children
Quoted 7 lines
Quoted 1 line

This should fix the immediate failure, just wondering, would there be any downside of replacing that TBROK with TCONF?

I'm not quite sure. Seems it trying to test without swap happened to guarantee less disturbing for the ’->ru_maxrss‘ counting. TCONF looks a bit weak to attention if the regression occurs ATM.

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw
In reply to Jan Stancek

Hi!

Quoted 6 lines
Quoted 1 line

This should fix the immediate failure, just wondering, would there be any downside of replacing that TBROK with TCONF?

I guess that we may end up in a state where the test would TCONF on every run and it would end up being ingnored.

Can't we just change the consume_mb to lock the memory with mlock() in the consume_mb() instead? As long as we add the check for a free memory it should be fine I guess.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#7 lore raw
Quoted 8 lines · Cyril Hrubis

Hi!

Quoted 6 lines
Quoted 1 line

This should fix the immediate failure, just wondering, would there be any downside of replacing that TBROK with TCONF?

Quoted 7 lines

I guess that we may end up in a state where the test would TCONF on every run and it would end up being ingnored.

Can't we just change the consume_mb to lock the memory with mlock() in the consume_mb() instead? As long as we add the check for a free memory it should be fine I guess.

Yes, we can, mlock() should be helpful on that.

I prefer to do that in a separate patch unless Jan has a different perspective.

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#8 lore raw
In reply to Li Wang

Hi!

Quoted 5 lines

---

Notes:
Ps. I also think we might need .min_mem_[avai|total] field but
not sure if it is really necessary to add that.

Actually this would be very useful from the long term perspective. If we ever manage to run tests in parallel the scheduller should make sure that we do not hit OOM due to running more than one processe that consume significant amount of memory at the same time.

Quoted 20 lines
testcases/kernel/syscalls/getrusage/getrusage03.c +8 -0
index bf5127483..5aa0b2326 100644
@@ -173,6 +173,14 @@ static void run(unsigned int i)
 	}
 }
 
+static void setup(void)
+{
+	long long mem_avail = tst_available_mem();
+
+	if (mem_avail < 512L*1024)
+		tst_brk(TCONF, "Needed > 512MB availabe, only have: %ld kB", mem_avail);
+}
+
 static struct tst_test test = {
 	.forks_child = 1,
 	.child_needs_reinit = 1,

testcases/kernel/syscalls/getrusage/getrusage03.c static struct tst_test test = { · line 196

Quoted 7 lines
testcases/kernel/syscalls/getrusage/getrusage03.c +1 -0
@@ -182,6 +190,7 @@ static struct tst_test test = {
 		{"linux-git", "1f10206cf8e9"},
 		{}
 	},
+	.setup = setup,
 	.test = run,
 	.tcnt = ARRAY_SIZE(testfunc_list),
 };

Looks good:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#9 lore raw
Quoted 9 lines · Cyril Hrubis
Quoted 3 lines

Notes:
Ps. I also think we might need .min_mem_[avai|total] field but
not sure if it is really necessary to add that.

Actually this would be very useful from the long term perspective. If we ever manage to run tests in parallel the scheduller should make sure that we do not hit OOM due to running more than one processe that consume significant amount of memory at the same time.

Well, sounds useful to avoid OOM in the parallel run. Hence the .min_mem should gives the requirement of minimal MemAvailable(but not MemTotal) size on test system.

I will view the whole test to add that when I get a chance.

Quoted 4 lines

Looks good:

Pushed (with the typo fix).

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp