Re: [PATCH 10/14] perf tests: Spawn child for each test

2014-05-27 Thread Jiri Olsa
On Tue, May 27, 2014 at 10:08:25AM +0900, Namhyung Kim wrote:
> On Thu, 15 May 2014 19:23:31 +0200, Jiri Olsa wrote:
> > In upcoming tests we will setup process limits, which
> > might affect other tests. Spawning child for each test
> > to prevent this.
> 
> But you can restore original limits after the test using soft limits?
> But I think it's better to run the tests in a child anyway. :)

right.. I also recalled that Ingo recommended this before,
I'll queue this one separately..

thanks,
jirka

> 
> Thanks,
> Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 10/14] perf tests: Spawn child for each test

2014-05-27 Thread Jiri Olsa
On Tue, May 27, 2014 at 10:08:25AM +0900, Namhyung Kim wrote:
 On Thu, 15 May 2014 19:23:31 +0200, Jiri Olsa wrote:
  In upcoming tests we will setup process limits, which
  might affect other tests. Spawning child for each test
  to prevent this.
 
 But you can restore original limits after the test using soft limits?
 But I think it's better to run the tests in a child anyway. :)

right.. I also recalled that Ingo recommended this before,
I'll queue this one separately..

thanks,
jirka

 
 Thanks,
 Namhyung
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 10/14] perf tests: Spawn child for each test

2014-05-26 Thread Namhyung Kim
On Thu, 15 May 2014 19:23:31 +0200, Jiri Olsa wrote:
> In upcoming tests we will setup process limits, which
> might affect other tests. Spawning child for each test
> to prevent this.

But you can restore original limits after the test using soft limits?
But I think it's better to run the tests in a child anyway. :)

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 10/14] perf tests: Spawn child for each test

2014-05-26 Thread Namhyung Kim
On Thu, 15 May 2014 19:23:31 +0200, Jiri Olsa wrote:
 In upcoming tests we will setup process limits, which
 might affect other tests. Spawning child for each test
 to prevent this.

But you can restore original limits after the test using soft limits?
But I think it's better to run the tests in a child anyway. :)

Thanks,
Namhyung
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/14] perf tests: Spawn child for each test

2014-05-15 Thread Jiri Olsa
In upcoming tests we will setup process limits, which
might affect other tests. Spawning child for each test
to prevent this.

Cc: Arnaldo Carvalho de Melo 
Cc: Corey Ashford 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jean Pihet 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Signed-off-by: Jiri Olsa 
---
 tools/perf/tests/builtin-test.c | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 0d5afaf..fe46f3e 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -3,6 +3,8 @@
  *
  * Builtin regression testing command: ever growing number of sanity tests
  */
+#include 
+#include 
 #include "builtin.h"
 #include "intlist.h"
 #include "tests.h"
@@ -164,6 +166,34 @@ static bool perf_test__matches(int curr, int argc, const 
char *argv[])
return false;
 }
 
+static int run_test(struct test *test)
+{
+   int status, err = -1, child = fork();
+
+   if (child < 0) {
+   pr_err("failed to fork test: %s\n", strerror(errno));
+   return -1;
+   }
+
+   if (!child) {
+   pr_debug("test child forked, pid %d\n", getpid());
+   err = test->func();
+   exit(err);
+   }
+
+   wait();
+
+   if (WIFEXITED(status)) {
+   err = WEXITSTATUS(status);
+   pr_debug("test child finished with %d\n", err);
+   } else if (WIFSIGNALED(status)) {
+   err = -1;
+   pr_debug("test child interrupted\n");
+   }
+
+   return err;
+}
+
 static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 {
int i = 0;
@@ -192,7 +222,7 @@ static int __cmd_test(int argc, const char *argv[], struct 
intlist *skiplist)
}
 
pr_debug("\n--- start ---\n");
-   err = tests[curr].func();
+   err = run_test([curr]);
pr_debug(" end \n%s:", tests[curr].desc);
 
switch (err) {
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/14] perf tests: Spawn child for each test

2014-05-15 Thread Jiri Olsa
In upcoming tests we will setup process limits, which
might affect other tests. Spawning child for each test
to prevent this.

Cc: Arnaldo Carvalho de Melo a...@kernel.org
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jean Pihet jean.pi...@linaro.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Signed-off-by: Jiri Olsa jo...@kernel.org
---
 tools/perf/tests/builtin-test.c | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 0d5afaf..fe46f3e 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -3,6 +3,8 @@
  *
  * Builtin regression testing command: ever growing number of sanity tests
  */
+#include unistd.h
+#include string.h
 #include builtin.h
 #include intlist.h
 #include tests.h
@@ -164,6 +166,34 @@ static bool perf_test__matches(int curr, int argc, const 
char *argv[])
return false;
 }
 
+static int run_test(struct test *test)
+{
+   int status, err = -1, child = fork();
+
+   if (child  0) {
+   pr_err(failed to fork test: %s\n, strerror(errno));
+   return -1;
+   }
+
+   if (!child) {
+   pr_debug(test child forked, pid %d\n, getpid());
+   err = test-func();
+   exit(err);
+   }
+
+   wait(status);
+
+   if (WIFEXITED(status)) {
+   err = WEXITSTATUS(status);
+   pr_debug(test child finished with %d\n, err);
+   } else if (WIFSIGNALED(status)) {
+   err = -1;
+   pr_debug(test child interrupted\n);
+   }
+
+   return err;
+}
+
 static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 {
int i = 0;
@@ -192,7 +222,7 @@ static int __cmd_test(int argc, const char *argv[], struct 
intlist *skiplist)
}
 
pr_debug(\n--- start ---\n);
-   err = tests[curr].func();
+   err = run_test(tests[curr]);
pr_debug( end \n%s:, tests[curr].desc);
 
switch (err) {
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/