[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-bedbfdea31daf3880745001d56450c683959ee7e@git.kernel.org>
Date: Mon, 15 Mar 2010 15:15:35 GMT
From: tip-bot for Eric B Munson <ebmunson@...ibm.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, paulus@...ba.org, acme@...hat.com,
hpa@...or.com, mingo@...hat.com, a.p.zijlstra@...llo.nl,
fweisbec@...il.com, ebmunson@...ibm.com, tglx@...utronix.de,
mingo@...e.hu
Subject: [tip:perf/core] perf record: Enable the enable_on_exec flag if record forks the target
Commit-ID: bedbfdea31daf3880745001d56450c683959ee7e
Gitweb: http://git.kernel.org/tip/bedbfdea31daf3880745001d56450c683959ee7e
Author: Eric B Munson <ebmunson@...ibm.com>
AuthorDate: Mon, 15 Mar 2010 11:46:57 -0300
Committer: Ingo Molnar <mingo@...e.hu>
CommitDate: Mon, 15 Mar 2010 16:08:22 +0100
perf record: Enable the enable_on_exec flag if record forks the target
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.
Signed-off-by: Eric B Munson <ebmunson@...ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Frederic Weisbecker <fweisbec@...il.com>
LKML-Reference: <1268664418-28328-1-git-send-email-acme@...radead.org>
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
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 bed175d..962cdbf 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -225,7 +225,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;
@@ -277,6 +277,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);
@@ -381,13 +384,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++;
}
@@ -547,11 +550,11 @@ 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 {
nr_cpus = read_cpu_map();
for (i = 0; i < nr_cpus; i++)
- open_counters(cpumap[i], target_pid);
+ open_counters(cpumap[i], target_pid, forks);
}
if (file_new) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists