All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] move_pages12: end early if runtime gets close to test time
@ 2018-08-27 14:06 Jan Stancek
  2018-08-28  9:00 ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2018-08-27 14:06 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/move_pages/move_pages12.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/move_pages/move_pages12.c b/testcases/kernel/syscalls/move_pages/move_pages12.c
index c0ff27114110..2813097871e4 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages12.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages12.c
@@ -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
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] move_pages12: end early if runtime gets close to test time
  2018-08-27 14:06 [LTP] [PATCH] move_pages12: end early if runtime gets close to test time Jan Stancek
@ 2018-08-28  9:00 ` Li Wang
  2018-08-28 10:18   ` Jan Stancek
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2018-08-28  9:00 UTC (permalink / raw)
  To: ltp

On Mon, Aug 27, 2018 at 10:06 PM, Jan Stancek <jstancek@redhat.com> wrote:

> 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
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
>  testcases/kernel/syscalls/move_pages/move_pages12.c | 20
> ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/move_pages/move_pages12.c
> b/testcases/kernel/syscalls/move_pages/move_pages12.c
> index c0ff27114110..2813097871e4 100644
> --- a/testcases/kernel/syscalls/move_pages/move_pages12.c
> +++ b/testcases/kernel/syscalls/move_pages/move_pages12.c
> @@ -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))
>

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?

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180828/a363d60a/attachment.html>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] move_pages12: end early if runtime gets close to test time
  2018-08-28  9:00 ` Li Wang
@ 2018-08-28 10:18   ` Jan Stancek
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2018-08-28 10:18 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> On Mon, Aug 27, 2018 at 10:06 PM, Jan Stancek <jstancek@redhat.com> wrote:
> 
> > 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
> >
> > Signed-off-by: Jan Stancek <jstancek@redhat.com>
> > ---
> >  testcases/kernel/syscalls/move_pages/move_pages12.c | 20
> > ++++++++++++++------
> >  1 file changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/move_pages/move_pages12.c
> > b/testcases/kernel/syscalls/move_pages/move_pages12.c
> > index c0ff27114110..2813097871e4 100644
> > --- a/testcases/kernel/syscalls/move_pages/move_pages12.c
> > +++ b/testcases/kernel/syscalls/move_pages/move_pages12.c
> > @@ -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))
> >
> 
> 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?

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

> 
> --
> Regards,
> Li Wang
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-28 10:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-27 14:06 [LTP] [PATCH] move_pages12: end early if runtime gets close to test time Jan Stancek
2018-08-28  9:00 ` Li Wang
2018-08-28 10:18   ` Jan Stancek

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.