From: Peter Zijlstra <peterz@infradead.org>
To: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: "Ingo Molnar" <mingo@elte.hu>,
linux-kernel@vger.kernel.org,
"Arnaldo Carvalho de Melo" <acme@redhat.com>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"Mike Galbraith" <efault@gmx.de>,
"Paul Mackerras" <paulus@samba.org>
Subject: Re: [PATCH 1/1] perf record: We should fork only if a program was specified to run
Date: Fri, 18 Dec 2009 21:52:41 +0100 [thread overview]
Message-ID: <1261169561.20899.630.camel@laptop> (raw)
In-Reply-To: <1261168944-6615-1-git-send-email-acme@infradead.org>
On Fri, 2009-12-18 at 18:42 -0200, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> IOW: Now 'perf record -a' works, this was a bug introduced in:
>
> 856e96608a72412d319e498a3a7c557571f811bd
> "perf record: Properly synchronize child creation"
>
> Reported-by: Pekka Enberg <penberg@cs.helsinki.fi>
> Cc: Frédéric Weisbecker <fweisbec@gmail.com>
> Cc: Mike Galbraith <efault@gmx.de>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Paul Mackerras <paulus@samba.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
> tools/perf/builtin-record.c | 9 +++++----
> 1 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 63136d0..90eedd9 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -402,7 +402,7 @@ static void atexit_header(void)
> perf_header__write(&session->header, output, true);
> }
>
> -static int __cmd_record(int argc __used, const char **argv)
> +static int __cmd_record(int argc, const char **argv)
> {
> int i, counter;
> struct stat st;
> @@ -422,7 +422,8 @@ static int __cmd_record(int argc __used, const char **argv)
> signal(SIGCHLD, sig_handler);
> signal(SIGINT, sig_handler);
>
> - if (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0) {
> + if (target_pid == -1 && argc > 0 &&
> + (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) {
> perror("failed to create pipes");
> exit(-1);
> }
Why bother?
> @@ -483,7 +484,7 @@ static int __cmd_record(int argc __used, const char **argv)
>
> atexit(atexit_header);
>
> - if (target_pid == -1) {
> + if (target_pid == -1 && argc > 0) {
> pid = fork();
> if (pid < 0) {
> perror("failed to fork");
I'd write:
target_pid == -1 && !system_wide
> @@ -667,7 +668,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
>
> argc = parse_options(argc, argv, options, record_usage,
> PARSE_OPT_STOP_AT_NON_OPTION);
> - if (!argc && target_pid == -1 && (!system_wide || profile_cpu == -1))
> + if (!argc && target_pid == -1 && !system_wide)
> usage_with_options(record_usage, options);
>
> symbol__init();
Right, so I was thinking -C would be enough to also start profiling..
clearly messed up the logic though :/
next prev parent reply other threads:[~2009-12-18 20:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-18 20:42 [PATCH 1/1] perf record: We should fork only if a program was specified to run Arnaldo Carvalho de Melo
2009-12-18 20:52 ` Peter Zijlstra [this message]
2009-12-18 20:58 ` Arnaldo Carvalho de Melo
2009-12-18 21:13 ` Peter Zijlstra
2009-12-18 22:03 ` Ingo Molnar
2009-12-18 21:29 ` Peter Zijlstra
2009-12-20 10:31 ` Xiao Guangrong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1261169561.20899.630.camel@laptop \
--to=peterz@infradead.org \
--cc=acme@infradead.org \
--cc=acme@redhat.com \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox