From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Eric B Munson <ebmunson@us.ibm.com>
Cc: a.p.zijlstra@chello.nl, paulus@samba.org, mingo@elte.hu,
linux-kernel@vger.kernel.org, David Miller <davem@davemloft.net>
Subject: Re: [PATCH] Enable the enable_on_exec flag if record forks the target
Date: Wed, 3 Mar 2010 20:46:10 -0300 [thread overview]
Message-ID: <20100303234610.GA17271@ghostprotocols.net> (raw)
In-Reply-To: <1267653987-11022-1-git-send-email-ebmunson@us.ibm.com>
Em Wed, Mar 03, 2010 at 10:06:27PM +0000, Eric B Munson escreveu:
> When forking its target, perf record can capture data from before the target
> application is started. Perf stat uses the enable_on_exec flag in the event
> attributes to keep from displaying events from before the target program
> starts, this patch adds the same functionality to perf record when it is will
> fork the target process.
Good catch, Dave, this will help that case too, or at least avoid
exercising that bug you fixed by flushing maps when a comm is received
:-)
Eric, I'll test your patches for handling multiple counters in 'perf
report'and integrate then, most likely tomorrow, thanks!
- Arnaldo
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
> ---
> tools/perf/builtin-record.c | 13 ++++++++-----
> 1 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 771533c..625076e 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -224,7 +224,7 @@ static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int n
> return h_attr;
> }
>
> -static void create_counter(int counter, int cpu, pid_t pid)
> +static void create_counter(int counter, int cpu, pid_t pid, bool forks)
> {
> char *filter = filters[counter];
> struct perf_event_attr *attr = attrs + counter;
> @@ -273,6 +273,9 @@ static void create_counter(int counter, int cpu, pid_t pid)
> attr->inherit = inherit;
> attr->disabled = 1;
>
> + if (forks)
> + attr->enable_on_exec = 1;
> +
> try_again:
> fd[nr_cpu][counter] = sys_perf_event_open(attr, pid, cpu, group_fd, 0);
>
> @@ -376,13 +379,13 @@ try_again:
> ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_ENABLE);
> }
>
> -static void open_counters(int cpu, pid_t pid)
> +static void open_counters(int cpu, pid_t pid, bool forks)
> {
> int counter;
>
> group_fd = -1;
> for (counter = 0; counter < nr_counters; counter++)
> - create_counter(counter, cpu, pid);
> + create_counter(counter, cpu, pid, forks);
>
> nr_cpu++;
> }
> @@ -542,10 +545,10 @@ static int __cmd_record(int argc, const char **argv)
>
>
> if ((!system_wide && !inherit) || profile_cpu != -1) {
> - open_counters(profile_cpu, target_pid);
> + open_counters(profile_cpu, target_pid, forks);
> } else {
> for (i = 0; i < nr_cpus; i++)
> - open_counters(i, target_pid);
> + open_counters(i, target_pid, forks);
> }
>
> if (file_new) {
> --
> 1.6.3.3
prev parent reply other threads:[~2010-03-03 23:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-03 22:06 [PATCH] Enable the enable_on_exec flag if record forks the target Eric B Munson
2010-03-03 23:46 ` Arnaldo Carvalho de Melo [this message]
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=20100303234610.GA17271@ghostprotocols.net \
--to=acme@ghostprotocols.net \
--cc=a.p.zijlstra@chello.nl \
--cc=davem@davemloft.net \
--cc=ebmunson@us.ibm.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