public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf bench: Flush stdout before starting bench suite
@ 2013-01-08  9:39 Namhyung Kim
  2013-01-08 13:59 ` Hitoshi Mitake
  2013-01-25 11:32 ` [tip:perf/core] " tip-bot for Namhyung Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Namhyung Kim @ 2013-01-08  9:39 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim,
	Hitoshi Mitake

From: Namhyung Kim <namhyung.kim@lge.com>

perf bench prints header message for bench suite before starting the
benchmark.  However if the stdout is redirected to a file and bench
suite forks child processes this (and possibly other debugging
messages too) will be repeated multiple times.

  $ perf bench sched messaging
  # Running sched/messaging benchmark...
  # 20 sender and receiver processes per group
  # 10 groups == 400 processes run

       Total time: 0.100 [sec]

  $ perf bench sched messaging > result.txt
  $ wc -l result.txt
  391

In this file, there were so many "Running sched/messaging benchmark..."
lines.  This was because stdout is converted to fully-buffered due to
the redirection and inherited child processes.  Other lines are printed
after reaping all those tasks.

So fix it by flushing stdout before starting bench suites.

Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-bench.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index cae9a5fd2ecf..afd1255a632f 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -159,6 +159,7 @@ static void all_suite(struct bench_subsys *subsys)	  /* FROM HERE */
 		printf("# Running %s/%s benchmark...\n",
 		       subsys->name,
 		       suites[i].name);
+		fflush(stdout);
 
 		argv[1] = suites[i].name;
 		suites[i].fn(1, argv, NULL);
@@ -225,6 +226,7 @@ int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
 				printf("# Running %s/%s benchmark...\n",
 				       subsystems[i].name,
 				       subsystems[i].suites[j].name);
+			fflush(stdout);
 			status = subsystems[i].suites[j].fn(argc - 1,
 							    argv + 1, prefix);
 			goto end;
-- 
1.7.11.7


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

* Re: [PATCH] perf bench: Flush stdout before starting bench suite
  2013-01-08  9:39 [PATCH] perf bench: Flush stdout before starting bench suite Namhyung Kim
@ 2013-01-08 13:59 ` Hitoshi Mitake
  2013-01-25 11:32 ` [tip:perf/core] " tip-bot for Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Hitoshi Mitake @ 2013-01-08 13:59 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Paul Mackerras,
	Ingo Molnar, LKML, Namhyung Kim, Hitoshi Mitake

At Tue,  8 Jan 2013 18:39:26 +0900,
Namhyung Kim wrote:
> 
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> perf bench prints header message for bench suite before starting the
> benchmark.  However if the stdout is redirected to a file and bench
> suite forks child processes this (and possibly other debugging
> messages too) will be repeated multiple times.
> 
>   $ perf bench sched messaging
>   # Running sched/messaging benchmark...
>   # 20 sender and receiver processes per group
>   # 10 groups == 400 processes run
> 
>        Total time: 0.100 [sec]
> 
>   $ perf bench sched messaging > result.txt
>   $ wc -l result.txt
>   391
> 
> In this file, there were so many "Running sched/messaging benchmark..."
> lines.  This was because stdout is converted to fully-buffered due to
> the redirection and inherited child processes.  Other lines are printed
> after reaping all those tasks.
> 
> So fix it by flushing stdout before starting bench suites.

Thanks a lot, I couldn't notice this problem.

Acked-by: Hitoshi Mitake <h.mitake@gmail.com>

> 
> Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/builtin-bench.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
> index cae9a5fd2ecf..afd1255a632f 100644
> --- a/tools/perf/builtin-bench.c
> +++ b/tools/perf/builtin-bench.c
> @@ -159,6 +159,7 @@ static void all_suite(struct bench_subsys *subsys)	  /* FROM HERE */
>  		printf("# Running %s/%s benchmark...\n",
>  		       subsys->name,
>  		       suites[i].name);
> +		fflush(stdout);
>  
>  		argv[1] = suites[i].name;
>  		suites[i].fn(1, argv, NULL);
> @@ -225,6 +226,7 @@ int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
>  				printf("# Running %s/%s benchmark...\n",
>  				       subsystems[i].name,
>  				       subsystems[i].suites[j].name);
> +			fflush(stdout);
>  			status = subsystems[i].suites[j].fn(argc - 1,
>  							    argv + 1, prefix);
>  			goto end;
> -- 
> 1.7.11.7
> 
> 

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

* [tip:perf/core] perf bench: Flush stdout before starting bench suite
  2013-01-08  9:39 [PATCH] perf bench: Flush stdout before starting bench suite Namhyung Kim
  2013-01-08 13:59 ` Hitoshi Mitake
@ 2013-01-25 11:32 ` tip-bot for Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-01-25 11:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, mitake,
	namhyung.kim, h.mitake, namhyung, tglx

Commit-ID:  9b494ea2f5638184bc203a30062b32b9a9a05d9e
Gitweb:     http://git.kernel.org/tip/9b494ea2f5638184bc203a30062b32b9a9a05d9e
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Tue, 8 Jan 2013 18:39:26 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 24 Jan 2013 16:40:19 -0300

perf bench: Flush stdout before starting bench suite

perf bench prints header message for bench suite before starting the
benchmark.  However if the stdout is redirected to a file and bench
suite forks child processes this (and possibly other debugging
messages too) will be repeated multiple times.

  $ perf bench sched messaging
  # Running sched/messaging benchmark...
  # 20 sender and receiver processes per group
  # 10 groups == 400 processes run

       Total time: 0.100 [sec]

  $ perf bench sched messaging > result.txt
  $ wc -l result.txt
  391

In this file, there were so many "Running sched/messaging benchmark..."
lines.  This was because stdout is converted to fully-buffered due to
the redirection and inherited child processes.  Other lines are printed
after reaping all those tasks.

So fix it by flushing stdout before starting bench suites.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1357637966-8216-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-bench.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index cae9a5f..afd1255 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -159,6 +159,7 @@ static void all_suite(struct bench_subsys *subsys)	  /* FROM HERE */
 		printf("# Running %s/%s benchmark...\n",
 		       subsys->name,
 		       suites[i].name);
+		fflush(stdout);
 
 		argv[1] = suites[i].name;
 		suites[i].fn(1, argv, NULL);
@@ -225,6 +226,7 @@ int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
 				printf("# Running %s/%s benchmark...\n",
 				       subsystems[i].name,
 				       subsystems[i].suites[j].name);
+			fflush(stdout);
 			status = subsystems[i].suites[j].fn(argc - 1,
 							    argv + 1, prefix);
 			goto end;

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

end of thread, other threads:[~2013-01-25 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-08  9:39 [PATCH] perf bench: Flush stdout before starting bench suite Namhyung Kim
2013-01-08 13:59 ` Hitoshi Mitake
2013-01-25 11:32 ` [tip:perf/core] " tip-bot for Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox