Skip to contentSkip to conversation

move_pages12: end early if runtime gets close to test time

PATCH New Jan Stancek 2 participants 3 messages Aug 27, 2018 – Aug 28, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 move_pages12: end early if runtime gets close to test time

Most systems can complete this reproducer in standard test time. Small groups of systems (e.g. aarch64 with 512M hugepages) can hit a timeout.

Add a check for elapsed time and end test early if we are getting close (80%).

Fixes #387
---
 testcases/kernel/syscalls/move_pages/move_pages12.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +14 -6
index c0ff27114110..2813097871e4 100644
@@ -40,6 +40,7 @@
 #include <sys/wait.h>
 
 #include "tst_test.h"
+#include "tst_timer.h"
 #include "move_pages_support.h"
 #include "lapi/mmap.h"
 
@@ -51,6 +52,7 @@
 #define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
 #define TEST_PAGES	2
 #define TEST_NODES	2
+#define TEST_TIMEOUT	300
 
 static int pgsz, hpsz;
 static long orig_hugepages = -1;
@@ -102,6 +104,8 @@ static void do_test(void)
 	pid_t cpid = -1;
 	int status;
 
+	tst_timer_start(CLOCK_MONOTONIC);
+
 	addr = SAFE_MMAP(NULL, TEST_PAGES * hpsz, PROT_READ | PROT_WRITE,
 		MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
 
@@ -123,14 +127,15 @@ static void do_test(void)
 		memset(addr, 0, TEST_PAGES * hpsz);
 
 		SAFE_MUNMAP(addr, TEST_PAGES * hpsz);
-	}
 
-	if (i == LOOPS) {
-		SAFE_KILL(cpid, SIGKILL);
-		SAFE_WAITPID(cpid, &status, 0);
-		if (!WIFEXITED(status))
-			tst_res(TPASS, "Bug not reproduced");
+		if (tst_timer_expired_ms(TEST_TIMEOUT))
+			break;
 	}
+
+	SAFE_KILL(cpid, SIGKILL);
+	SAFE_WAITPID(cpid, &status, 0);
+	if (!WIFEXITED(status))
+		tst_res(TPASS, "Bug not reproduced");
 }
 
 static void alloc_free_huge_on_node(unsigned int node, size_t size)
@@ -183,6 +188,8 @@ static void setup(void)
 	int ret;
 	long memfree;
 
+	tst_timer_check(CLOCK_MONOTONIC);
+
 	check_config(TEST_NODES);
 
 	if (access(PATH_HUGEPAGES, F_OK))
@@ -265,6 +272,7 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = do_test,
+	.timeout = (TEST_TIMEOUT / 5) * 6,
 };
 
 #else
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 move_pages12: end early if runtime gets close to test time

Quoted 50 lines · Jan Stancek

Most systems can complete this reproducer in standard test time. Small groups of systems (e.g. aarch64 with 512M hugepages) can hit a timeout.

Add a check for elapsed time and end test early if we are getting close (80%).

Fixes:
#387

---
 testcases/kernel/syscalls/move_pages/move_pages12.c | 20
++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +4 -0
index c0ff27114110..2813097871e4 100644
@@ -40,6 +40,7 @@
 #include <sys/wait.h>
 
 #include "tst_test.h"
+#include "tst_timer.h"
 #include "move_pages_support.h"
 #include "lapi/mmap.h"
 
@@ -51,6 +52,7 @@
 #define PATH_HUGEPAGES "/sys/kernel/mm/hugepages/"
 #define TEST_PAGES     2
 #define TEST_NODES     2
+#define TEST_TIMEOUT   300
 
 static int pgsz, hpsz;
 static long orig_hugepages = -1;
@@ -102,6 +104,8 @@ static void do_test(void)
        pid_t cpid = -1;
        int status;
 
+       tst_timer_start(CLOCK_MONOTONIC);
+
        addr = SAFE_MMAP(NULL, TEST_PAGES * hpsz, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
 
@@ -123,14 +127,15 @@ static void do_test(void)
                memset(addr, 0, TEST_PAGES * hpsz);
 
                SAFE_MUNMAP(addr, TEST_PAGES * hpsz);

testcases/kernel/syscalls/move_pages/move_pages12.c static void do_test(void) · line 133

Quoted 10 lines
testcases/kernel/syscalls/move_pages/move_pages12.c +1 -6
-       }
 
-       if (i == LOOPS) {
-               SAFE_KILL(cpid, SIGKILL);
-               SAFE_WAITPID(cpid, &status, 0);
-               if (!WIFEXITED(status))
-                       tst_res(TPASS, "Bug not reproduced");
+               if (tst_timer_expired_ms(
 TEST_TIMEOUT))
 

This is a good way for solving
#387 issue, but that will make the
LTP_TIMEOUT_MUL out of action even if someone set a value to it. because test will always stop on
TEST_TIMEOUT expired every time.

Shouldn't we consider this situation?

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180828/a363d60a/attachment.html>
#2 lore raw

PATCH 1/1 move_pages12: end early if runtime gets close to test time

----- Original Message -----

Quoted 69 lines · Jan Stancek
Quoted 51 lines

Most systems can complete this reproducer in standard test time. Small groups of systems (e.g. aarch64 with 512M hugepages) can hit a timeout.

Add a check for elapsed time and end test early if we are getting close (80%).

Fixes:
#387

---
 testcases/kernel/syscalls/move_pages/move_pages12.c | 20
++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +4 -0
index c0ff27114110..2813097871e4 100644
@@ -40,6 +40,7 @@
 #include <sys/wait.h>
 
 #include "tst_test.h"
+#include "tst_timer.h"
 #include "move_pages_support.h"
 #include "lapi/mmap.h"
 
@@ -51,6 +52,7 @@
 #define PATH_HUGEPAGES "/sys/kernel/mm/hugepages/"
 #define TEST_PAGES     2
 #define TEST_NODES     2
+#define TEST_TIMEOUT   300
 
 static int pgsz, hpsz;
 static long orig_hugepages = -1;
@@ -102,6 +104,8 @@ static void do_test(void)
        pid_t cpid = -1;
        int status;
 
+       tst_timer_start(CLOCK_MONOTONIC);
+
        addr = SAFE_MMAP(NULL, TEST_PAGES * hpsz, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
 
@@ -123,14 +127,15 @@ static void do_test(void)
                memset(addr, 0, TEST_PAGES * hpsz);
 
                SAFE_MUNMAP(addr, TEST_PAGES * hpsz);

testcases/kernel/syscalls/move_pages/move_pages12.c static void do_test(void) · line 133

Quoted 10 lines
testcases/kernel/syscalls/move_pages/move_pages12.c +1 -6
-       }
 
-       if (i == LOOPS) {
-               SAFE_KILL(cpid, SIGKILL);
-               SAFE_WAITPID(cpid, &status, 0);
-               if (!WIFEXITED(status))
-                       tst_res(TPASS, "Bug not reproduced");
+               if (tst_timer_expired_ms(
 TEST_TIMEOUT))
 

This is a good way for solving
#387 issue, but that will make the
LTP_TIMEOUT_MUL out of action even if someone set a value to it. because test will always stop on
TEST_TIMEOUT expired every time.

Quoted 1 line

Shouldn't we consider this situation?

In most cases timeout is upper bound of test runtime, but here it could mean also time we allow test to run while it's trying to do something.

We'll never hit timeout, but for latter case, it would make sense to respect LTP_TIMEOUT_MUL. I'll send v2.

Thanks,
Jan

Quoted 5 lines

--
Regards,
Li Wang