Re: [PATCH] perf stat: Set child_pid afterperf_evlist__prepare_workload()

From: Arnaldo Carvalho de Melo
Date: Tue Oct 01 2013 - 12:51:47 EST


Em Mon, Sep 30, 2013 at 07:47:25AM -0600, David Ahern escreveu:
> On 9/30/13 3:01 AM, Namhyung Kim wrote:
> >From: Namhyung Kim <namhyung.kim@xxxxxxx>
> >
> >The commit acf2892270dc ("perf stat: Use perf_evlist__prepare/
> >start_workload()") converted to use the function but forgot to update
> >child_pid. Fix it.
> >
> >Cc: David Ahern <dsahern@xxxxxxxxx>
> >Cc: Stephane Eranian <eranian@xxxxxxxxxx>
> >Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> >---
> > tools/perf/builtin-stat.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> >diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> >index f686d5ff594e..5098f144b92d 100644
> >--- a/tools/perf/builtin-stat.c
> >+++ b/tools/perf/builtin-stat.c
> >@@ -457,6 +457,7 @@ static int __run_perf_stat(int argc, const char **argv)
> > perror("failed to prepare workload");
> > return -1;
> > }
> >+ child_pid = evsel_list->workload.pid;
> > }
> >
> > if (group)
> >
>
> Interesting. I can't find a test case where is matters ... perhaps a
> convenience of waitpid taking -1.

Yeah, the interval part initially used the fork return, then after
acf2892270dc used the default value of child_pid, -1, which is ok as it
waits for any children, but I wonder what would happen in workloads with
multiple children.

But for correctness acf2892270dc should have kept the existing
semantics, even if using -1 could in the end be ok.

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