* [LTP] [PATCH] swapping01: set .max_runtime to 90 seconds
@ 2022-06-17 5:56 Li Wang
2022-06-17 10:09 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2022-06-17 5:56 UTC (permalink / raw)
To: ltp
This fix can significantly improve timeouts on slower systems:
# free -h
total used free shared buff/cache available
Mem: 2.9Gi 1.1Gi 1.1Gi 20Mi 732Mi 1.5Gi
Swap: 2.0Gi 0B 2.0Gi
# time ./swapping01
tst_kconfig.c:82: TINFO: Parsing kernel config '/boot/config-4.18.0-309.el8.x86_64+debug'
tst_test.c:1528: TINFO: Timeout per run is 0h 02m 00s
swapping01.c:110: TINFO: available physical memory: 1545 MB
swapping01.c:113: TINFO: try to allocate: 2008 MB
swapping01.c:152: TPASS: no heavy swapping detected, 218 MB swapped.
...
real 0m34.241s
user 0m0.386s
sys 0m16.040s
Signed-off-by: Li Wang <liwang@redhat.com>
---
testcases/kernel/mem/swapping/swapping01.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index f6133cc0d..73bad5d6a 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -159,6 +159,7 @@ static struct tst_test test = {
.needs_root = 1,
.forks_child = 1,
.min_mem_avail = 10,
+ .max_runtime = 90,
.test_all = test_swapping,
.needs_kconfigs = (const char *[]) {
"CONFIG_SWAP=y",
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] swapping01: set .max_runtime to 90 seconds
2022-06-17 5:56 [LTP] [PATCH] swapping01: set .max_runtime to 90 seconds Li Wang
@ 2022-06-17 10:09 ` Cyril Hrubis
2022-06-20 6:23 ` Li Wang
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2022-06-17 10:09 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi!
> # time ./swapping01
> tst_kconfig.c:82: TINFO: Parsing kernel config '/boot/config-4.18.0-309.el8.x86_64+debug'
> tst_test.c:1528: TINFO: Timeout per run is 0h 02m 00s
> swapping01.c:110: TINFO: available physical memory: 1545 MB
> swapping01.c:113: TINFO: try to allocate: 2008 MB
> swapping01.c:152: TPASS: no heavy swapping detected, 218 MB swapped.
> ...
>
> real 0m34.241s
> user 0m0.386s
> sys 0m16.040s
I did play with the test for a bit and it's even more unpredictable for
me, it tooks a minute or two on my workstation but there were outliners
that took nearly four minutes as well.
Hence I would propose to go even further and default to 10 minutes for
max_runtime. At the same time I would limit the loop that waits for the
swap usage to settle to run for a reminder of max_runtime/2 instead of
the hardcoded 30 seconds. Something as:
diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index f6133cc0d..40395b1d3 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -58,6 +58,7 @@ static long swap_free_init;
static long mem_over;
static long mem_over_max;
static pid_t pid;
+static unsigned int start_runtime;
static void test_swapping(void)
{
@@ -67,6 +68,8 @@ static void test_swapping(void)
FILE *file;
char line[PATH_MAX];
+ start_runtime = tst_remaining_runtime();
+
file = SAFE_FOPEN("/proc/swaps", "r");
while (fgets(line, sizeof(line), file)) {
if (strstr(line, "/dev/zram")) {
@@ -122,7 +125,7 @@ static void do_alloc(int allow_raise)
static void check_swapping(void)
{
- int status, i;
+ int status;
long swap_free_now, swapped;
/* wait child stop */
@@ -131,14 +134,13 @@ static void check_swapping(void)
tst_brk(TBROK, "child was not stopped.");
/* Still occupying memory, loop for a while */
- i = 0;
- while (i < 30) {
+ while (tst_remaining_runtime() > start_runtime/2) {
swap_free_now = SAFE_READ_MEMINFO("SwapFree:");
sleep(1);
- if (labs(swap_free_now - SAFE_READ_MEMINFO("SwapFree:")) < 10)
+ long diff = labs(swap_free_now - SAFE_READ_MEMINFO("SwapFree:"));
+ if (diff < 10)
break;
-
- i++;
+ tst_res(TINFO, "SwapFree difference %li", diff);
}
swapped = SAFE_READ_PROC_STATUS(pid, "VmSwap:");
@@ -159,6 +161,7 @@ static struct tst_test test = {
.needs_root = 1,
.forks_child = 1,
.min_mem_avail = 10,
+ .max_runtime = 600,
.test_all = test_swapping,
.needs_kconfigs = (const char *[]) {
"CONFIG_SWAP=y",
After this patch the test works for me as:
$ time ./swapping01
tst_kconfig.c:82: TINFO: Parsing kernel config '/usr/src/linux/.config'
tst_test.c:1526: TINFO: Timeout per run is 0h 10m 30s
swapping01.c:112: TINFO: available physical memory: 15389 MB
swapping01.c:116: TINFO: try to allocate: 20006 MB
swapping01.c:143: TINFO: SwapFree difference 1280
swapping01.c:143: TINFO: SwapFree difference 512
swapping01.c:143: TINFO: SwapFree difference 256
swapping01.c:143: TINFO: SwapFree difference 256
swapping01.c:143: TINFO: SwapFree difference 256
swapping01.c:153: TPASS: no heavy swapping detected, 4612 MB swapped.
Summary:
passed 1
failed 0
broken 0
skipped 0
warnings 0
real 1m46.942s
user 0m1.860s
sys 0m20.429s
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] swapping01: set .max_runtime to 90 seconds
2022-06-17 10:09 ` Cyril Hrubis
@ 2022-06-20 6:23 ` Li Wang
0 siblings, 0 replies; 3+ messages in thread
From: Li Wang @ 2022-06-20 6:23 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: LTP List
[-- Attachment #1.1: Type: text/plain, Size: 1130 bytes --]
On Fri, Jun 17, 2022 at 6:07 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
> > # time ./swapping01
> > tst_kconfig.c:82: TINFO: Parsing kernel config
> '/boot/config-4.18.0-309.el8.x86_64+debug'
> > tst_test.c:1528: TINFO: Timeout per run is 0h 02m 00s
> > swapping01.c:110: TINFO: available physical memory: 1545 MB
> > swapping01.c:113: TINFO: try to allocate: 2008 MB
> > swapping01.c:152: TPASS: no heavy swapping detected, 218 MB swapped.
> > ...
> >
> > real 0m34.241s
> > user 0m0.386s
> > sys 0m16.040s
>
> I did play with the test for a bit and it's even more unpredictable for
> me, it tooks a minute or two on my workstation but there were outliners
> that took nearly four minutes as well.
>
> Hence I would propose to go even further and default to 10 minutes for
> max_runtime. At the same time I would limit the loop that waits for the
> swap usage to settle to run for a reminder of max_runtime/2 instead of
> the hardcoded 30 seconds. Something as:
>
Fair enough!
max_runtime/2 is about 5mins which is the previous default time of timeout
that works well.
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 1932 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-20 6:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 5:56 [LTP] [PATCH] swapping01: set .max_runtime to 90 seconds Li Wang
2022-06-17 10:09 ` Cyril Hrubis
2022-06-20 6:23 ` Li Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.