From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
David Ahern <dsahern@gmail.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 12/14] perf stat: Create events as disabled
Date: Mon, 7 Dec 2015 19:17:17 -0300 [thread overview]
Message-ID: <1449526639-3667-13-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1449526639-3667-1-git-send-email-acme@kernel.org>
From: Jiri Olsa <jolsa@kernel.org>
Currently we have 2 kinds of stat counters based on when the event is
enabled:
1) tracee command events, which are enable once the
tracee executes exec syscall (enable_on_exec bit)
2) all other events which get alive within the
perf_event_open syscall
And 2) case could raise a problem in case we want additional filter to
be attached for event. In this case we want the event to be enabled
after it's configured with filter.
Changing the behaviour of 2) events, so they all are created as disabled
(disabled bit). Adding extra enable call to make them alive once they
finish setup.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449133606-14429-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-stat.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8ca40deaa728..2e70610649a1 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -168,11 +168,18 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
attr->sample_period = 0;
attr->sample_type = 0;
+ /*
+ * Disabling all counters initially, they will be enabled
+ * either manually by us or by kernel via enable_on_exec
+ * set later.
+ */
+ if (perf_evsel__is_group_leader(evsel))
+ attr->disabled = 1;
+
if (target__has_cpu(&target))
return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));
if (!target__has_task(&target) && perf_evsel__is_group_leader(evsel)) {
- attr->disabled = 1;
if (!initial_delay)
attr->enable_on_exec = 1;
}
@@ -251,12 +258,18 @@ static void process_interval(void)
print_counters(&rs, 0, NULL);
}
-static void handle_initial_delay(void)
+static void enable_counters(void)
{
- if (initial_delay) {
+ if (initial_delay)
usleep(initial_delay * 1000);
+
+ /*
+ * We need to enable counters only if:
+ * - we don't have tracee (attaching to task or cpu)
+ * - we have initial delay configured
+ */
+ if (!target__none(&target) || initial_delay)
perf_evlist__enable(evsel_list);
- }
}
static volatile int workload_exec_errno;
@@ -353,7 +366,7 @@ static int __run_perf_stat(int argc, const char **argv)
if (forks) {
perf_evlist__start_workload(evsel_list);
- handle_initial_delay();
+ enable_counters();
if (interval) {
while (!waitpid(child_pid, &status, WNOHANG)) {
@@ -372,7 +385,7 @@ static int __run_perf_stat(int argc, const char **argv)
if (WIFSIGNALED(status))
psignal(WTERMSIG(status), argv[0]);
} else {
- handle_initial_delay();
+ enable_counters();
while (!done) {
nanosleep(&ts, NULL);
if (interval)
--
2.1.0
next prev parent reply other threads:[~2015-12-07 22:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 22:17 [GIT PULL 00/14] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 01/14] perf machine: Pass correct string to dso__adjust_kmod_long_name Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 02/14] perf test: Use machine__new_host in dwarf unwind test Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 03/14] perf test: Use machine__new_host in mmap thread lookup test Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 04/14] perf test: Use machine__new_host in mmap thread code reading test Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 05/14] perf test: Fix cpus and thread maps reference in error path Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 06/14] perf test: Prevent using bpf-output event in round trip name test Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 07/14] perf test: Create kernel maps properly for hist entries test Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 08/14] perf evsel: Use event maps directly in perf_evsel__enable Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 09/14] perf evsel: Introduce disable() method Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 10/14] perf evlist: Factor perf_evlist__(enable|disable) functions Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 11/14] perf stat: Use perf_evlist__enable in handle_initial_delay Arnaldo Carvalho de Melo
2015-12-07 22:17 ` Arnaldo Carvalho de Melo [this message]
2015-12-07 22:17 ` [PATCH 13/14] perf stat: Move enable_on_exec setup under earlier code Arnaldo Carvalho de Melo
2015-12-07 22:17 ` [PATCH 14/14] perf annotate: ARM support Arnaldo Carvalho de Melo
2015-12-08 4:24 ` [GIT PULL 00/14] perf/core improvements and fixes Ingo Molnar
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=1449526639-3667-13-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.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;
as well as URLs for NNTP newsgroup(s).