From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754791Ab1IBS7L (ORCPT ); Fri, 2 Sep 2011 14:59:11 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:36070 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754738Ab1IBS7H (ORCPT ); Fri, 2 Sep 2011 14:59:07 -0400 Date: Fri, 2 Sep 2011 15:58:57 -0300 From: Arnaldo Carvalho de Melo To: Jim Cromie Cc: Ingo Molnar , linux-kernel@vger.kernel.org, a.p.zijlstra@chello.nl, paulus@samba.org Subject: Re: [PATCH 1/2] perf stat: add -l option to redirect stderr elsewhere Message-ID: <20110902185857.GE17970@ghostprotocols.net> References: <1305968203-14240-1-git-send-email-jim.cromie@gmail.com> <1305968203-14240-2-git-send-email-jim.cromie@gmail.com> <20110521103418.GB23651@elte.hu> <20110521204148.GB10330@ghostprotocols.net> <20110902143549.GA17970@ghostprotocols.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Sep 02, 2011 at 12:04:03PM -0600, Jim Cromie escreveu: > On Fri, Sep 2, 2011 at 8:35 AM, Arnaldo Carvalho de Melo > wrote: > > Em Thu, Sep 01, 2011 at 03:58:13PM -0600, Jim Cromie escreveu: > >> On Sat, May 21, 2011 at 2:41 PM, Arnaldo Carvalho de Melo > >> wrote: > >> > Em Sat, May 21, 2011 at 12:34:18PM +0200, Ingo Molnar escreveu: > >> >> * Jim Cromie wrote: > >> >> > >> >> > This perf stat option emulates valgrind's --log-fd option, allowing the > >> >> > user to send perf results elsewhere, and leaving stderr for use by the > >> >> > program under test. > >> >> > > >> >> >   3>results perf stat -l 3 -- > >> >> > > >> >> > The perl distro's make test.valgrind target uses valgrinds --log-fd > >> >> > option, I've adapted it to invoke perf also, and tested this patch there. > >> >> > > >> >> > Signed-off-by: Jim Cromie > >> >> > >> >> Makes sense! > >> >> > >> >> Arnaldo, if you are fine with it, do you want to pick it up - or should i? If > >> >> you pick it up: > >> >> > >> >> Acked-by: Ingo Molnar > >> > > >> > Its ok with me: > >> > > >> > Acked-by: Arnaldo Carvalho de Melo > >> > > >> > I will pick it this weekend, if you don't merge it till then. > > > >> Did this ever happen ? > >> Can you point me to the git-url where it did/will end up ? > > > > Fell thru the cracks, then Stephane implemented --output: > > > > http://git.kernel.org/?p=linux/kernel/git/tip/linux-tip.git;a=commitdiff;h=4aa9015f8bfd2c8d7cc33a360275b71a9d708b37 > > > > That introduces an output FILE pointer as in your patch (logfp), so I > > adjusted your patch, that ended up like below. I removed -l and made it > > --log-fd, just like valgrind and added the Documentation bits about the > > new cmdline option, ok? > > > > absolutely. > theres one comment I added (just above output_fd decl) > that mentions -I, it should be updated to --log-fd > > And probably --output and --log-fd should be mutually exclusive. With the current implementation if --output is used --log-fd will be ignored if present, perhaps we should print a warning or plain fail if the user tries to specify both? > > I'll look at the other 3 patch series that came after, will fix up and > > post here for your consideration. > > those are the output format refactoring ? > > ah, your new message just arrived. > I'll take another go at them.. Ok, please apply this reworked --log-fd before, of course :) > thanks > > > > > - Arnaldo > > > > diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt > > index 08394c4..b6bfd1e 100644 > > --- a/tools/perf/Documentation/perf-stat.txt > > +++ b/tools/perf/Documentation/perf-stat.txt > > @@ -101,6 +101,9 @@ Print the output into the designated file. > >  --append:: > >  Append to the output file designated with the -o option. Ignored if -o is not specified. > > > > +--log-fd:: > > +Log output to fd, instead of stderr. > > stderr / outputfile ?? > > > + > >  EXAMPLES > >  -------- > > > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > > index bec64a9..c991d66 100644 > > --- a/tools/perf/builtin-stat.c > > +++ b/tools/perf/builtin-stat.c > > @@ -196,6 +196,8 @@ static bool                 csv_output                      = false; > >  static bool                    group                           = false; > >  static const char              *output_name                    = NULL; > >  static FILE                    *output                         = NULL; > > +/* stderr by default, override with -l */ > > with --log-fd Can you rework it and put as the first on your new patchset? Thanks, - Arnaldo > > +static int                     output_fd                       = 2; > > > >  static volatile int done = 0; > > > > @@ -1080,6 +1082,8 @@ static const struct option options[] = { > >        OPT_STRING('o', "output", &output_name, "file", > >                    "output file name"), > >        OPT_BOOLEAN(0, "append", &append_file, "append to the output file"), > > +       OPT_INTEGER(0, "log-fd", &output_fd, > > +                   "log output to fd, instead of stderr"), > >        OPT_END() > >  }; > > > > @@ -1177,6 +1181,12 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) > >                } > >                clock_gettime(CLOCK_REALTIME, &tm); > >                fprintf(output, "# started on %s\n", ctime(&tm.tv_sec)); > > +       } else if (output_fd != 2) { > > +               output = fdopen(output_fd, "w"); > > +               if (!output) { > > +                       perror("Failed opening logfd"); > > +                       return -errno; > > +               } > >        } > > > >        if (csv_sep) > >