From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756421Ab3AHN7p (ORCPT ); Tue, 8 Jan 2013 08:59:45 -0500 Received: from mail-pb0-f51.google.com ([209.85.160.51]:55980 "EHLO mail-pb0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756308Ab3AHN7o (ORCPT ); Tue, 8 Jan 2013 08:59:44 -0500 Date: Tue, 08 Jan 2013 22:59:36 +0900 Message-ID: <87r4lv93nb.wl%h.mitake@gmail.com> From: Hitoshi Mitake To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Paul Mackerras , Ingo Molnar , LKML , Namhyung Kim , Hitoshi Mitake Subject: Re: [PATCH] perf bench: Flush stdout before starting bench suite In-Reply-To: <1357637966-8216-1-git-send-email-namhyung@kernel.org> References: <1357637966-8216-1-git-send-email-namhyung@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-2022-JP-2?B?R29qGyQoRCtXGyhC?=) APEL/10.8 Emacs/24.2 (x86_64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Tue, 8 Jan 2013 18:39:26 +0900, Namhyung Kim wrote: > > From: Namhyung Kim > > 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 > > Cc: Hitoshi Mitake > Signed-off-by: Namhyung Kim > --- > 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 > >