aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHitoshi Mitake <[email protected]>2009-11-09 12:31:05 +0900
committerIngo Molnar <[email protected]>2009-11-09 08:14:30 +0100
commit5ff0cfc67f00fe0feaa1da0b2359232ea4aa0ee7 (patch)
treef432370dfa63a7a3b63354d670128764eff534a1
parentbfde82ef51e3ea6ab8634d0fdbf5adcdd1b429cb (diff)
perf bench: Fix bench/sched-pipe.c to wait for child process
Ingo reported this small 'perf bench sched pipe' output problem: | $ ./perf bench sched pipe | (executing 1000000 pipe operations between two tasks) | | Total time:4.898 sec | $ 4.898586 usecs/op | 204140 ops/sec | | the shell prompt came back before the usecs/op and ops/sec line | was printed. Process teardown race, lack of wait() or so? This caused by lack of calling waitpid() by parent process, so I added it. Signed-off-by: Hitoshi Mitake <[email protected]> Cc: Rusty Russell <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jiri Kosina <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
-rw-r--r--tools/perf/bench/sched-pipe.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 3214ed20b1aa..6a29100e9282 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -26,6 +26,7 @@
#include <errno.h>
#include <assert.h>
#include <sys/time.h>
+#include <sys/types.h>
#define LOOPS_DEFAULT 1000000
static int loops = LOOPS_DEFAULT;
@@ -58,8 +59,8 @@ int bench_sched_pipe(int argc, const char **argv,
* discarding returned value of read(), write()
* causes error in building environment for perf
*/
- int ret;
- pid_t pid;
+ int ret, wait_stat;
+ pid_t pid, retpid;
argc = parse_options(argc, argv, options,
bench_sched_pipe_usage, 0);
@@ -87,8 +88,11 @@ int bench_sched_pipe(int argc, const char **argv,
gettimeofday(&stop, NULL);
timersub(&stop, &start, &diff);
- if (pid)
+ if (pid) {
+ retpid = waitpid(pid, &wait_stat, 0);
+ assert((retpid == pid) && WIFEXITED(wait_stat));
return 0;
+ }
if (simple)
printf("%lu.%03lu\n",