From: Jiri Olsa <jolsa@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Jiri Olsa <jolsa@redhat.com>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>, Namhyung Kim <namhyung@kernel.org>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Andi Kleen <ak@linux.intel.com>, David Ahern <dsahern@gmail.com>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 6/9] perf tools: Set maximum precise value for 'precise' term
Date: Thu, 9 May 2013 15:32:21 +0200 [thread overview]
Message-ID: <1368106344-23383-7-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1368106344-23383-1-git-send-email-jolsa@redhat.com>
Currently if the term is specified without any value like
-e 'cpu/...,precise,../', the number '1' is assigned as
its default value.
Adding special treatment for 'precise' term to use the
maximum allowed precise value in such case using the
perf_precise__get function.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
---
tools/perf/util/parse-events.c | 29 ++++++++++++++++++++++++++---
tools/perf/util/parse-events.h | 2 ++
tools/perf/util/parse-events.y | 2 +-
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6be4599..5297c44 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -590,9 +590,14 @@ do { \
break;
case PARSE_EVENTS__TERM_TYPE_PRECISE:
CHECK_TYPE_VAL(NUM);
- if ((unsigned)term->val.num > 2)
- return -EINVAL;
- attr->precise_ip = term->val.num;
+ /* No value specified, try to get it from sysfs. */
+ if (term->val.num == (u64) -1)
+ attr->precise_ip = precise_default();
+ else {
+ if ((unsigned)term->val.num > 2)
+ return -EINVAL;
+ attr->precise_ip = term->val.num;
+ }
break;
default:
return -EINVAL;
@@ -1245,6 +1250,24 @@ int parse_events_term__num(struct parse_events_term **term,
config, NULL, num);
}
+int parse_events_term__num_default(struct parse_events_term **term,
+ int type_term, char *config)
+{
+ /*
+ * If no value is specified for term, we use 1 as default.
+ * The PRECISE term is an exception, because we force special
+ * functionality when there's no value specified for it,
+ * so we need to recognize it.
+ */
+ u64 num = 1;
+
+ if (type_term == PARSE_EVENTS__TERM_TYPE_PRECISE)
+ num = (u64) -1;
+
+ return new_term(term, PARSE_EVENTS__TERM_TYPE_NUM, type_term,
+ config, NULL, num);
+}
+
int parse_events_term__str(struct parse_events_term **term,
int type_term, char *config, char *str)
{
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 13d7c66..6810397 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -75,6 +75,8 @@ struct parse_events_terms {
int parse_events__is_hardcoded_term(struct parse_events_term *term);
int parse_events_term__num(struct parse_events_term **_term,
int type_term, char *config, u64 num);
+int parse_events_term__num_default(struct parse_events_term **term,
+ int type_term, char *config);
int parse_events_term__str(struct parse_events_term **_term,
int type_term, char *config, char *str);
int parse_events_term__sym_hw(struct parse_events_term **term,
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index afc44c1..da77510 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -408,7 +408,7 @@ PE_TERM
{
struct parse_events_term *term;
- ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1));
+ ABORT_ON(parse_events_term__num_default(&term, (int)$1, NULL));
$$ = term;
}
--
1.7.11.7
next prev parent reply other threads:[~2013-05-09 13:33 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-09 13:32 [PATCH 0/9] perf: Adding better precise_ip field handling Jiri Olsa
2013-05-09 13:32 ` [PATCH 1/9] perf x86: Add precise sysfs cpu pmu attribute Jiri Olsa
2013-05-09 13:32 ` [PATCH 2/9] perf tools: Add precise object to interface sysfs precise Jiri Olsa
2013-05-10 1:34 ` Namhyung Kim
2013-05-10 9:06 ` Jiri Olsa
2013-05-09 13:32 ` [PATCH 3/9] perf tests: Add precise event automated test Jiri Olsa
2013-05-09 13:32 ` [PATCH 4/9] perf tools: Add a precise event qualifier Jiri Olsa
2013-05-10 1:43 ` Namhyung Kim
2013-05-10 9:10 ` Jiri Olsa
2013-05-09 13:32 ` [PATCH 5/9] perf tools: Set maximum precise value for event 'p' modifier Jiri Olsa
2013-05-09 19:43 ` David Ahern
2013-05-10 9:12 ` Jiri Olsa
2013-05-10 1:53 ` Namhyung Kim
2013-05-10 9:16 ` Jiri Olsa
2013-05-09 13:32 ` Jiri Olsa [this message]
2013-05-09 13:32 ` [PATCH 7/9] perf tests: Add automated precise term test Jiri Olsa
2013-05-09 13:32 ` [PATCH 8/9] perf: Document the ABI for 'precise' sysfs attribute Jiri Olsa
2013-05-10 1:57 ` Namhyung Kim
2013-05-09 13:32 ` [PATCH 9/9] perf: Document the ABI for 'rdpmc' " Jiri Olsa
2013-05-09 15:07 ` [PATCH 0/9] perf: Adding better precise_ip field handling Peter Zijlstra
2013-05-09 15:20 ` Jiri Olsa
2013-05-10 9:27 ` Peter Zijlstra
2013-05-10 9:40 ` Jiri Olsa
2013-05-10 9:53 ` Peter Zijlstra
2013-05-10 10:18 ` Ingo Molnar
2013-05-10 10:22 ` Peter Zijlstra
2013-05-10 10:31 ` Ingo Molnar
2013-05-10 10:34 ` Peter Zijlstra
2013-05-10 10:55 ` Ingo Molnar
2013-05-10 11:27 ` Peter Zijlstra
2013-05-11 7:50 ` Ingo Molnar
2013-05-13 9:36 ` Peter Zijlstra
2013-05-13 19:43 ` Ingo Molnar
2013-05-14 7:22 ` Peter Zijlstra
2013-05-14 8:37 ` Ingo Molnar
2013-05-14 8:36 ` Gleb Natapov
2013-05-15 13:27 ` Stephane Eranian
2013-05-28 9:54 ` Ingo Molnar
2013-05-10 9:29 ` Peter Zijlstra
2013-05-10 9:43 ` Jiri Olsa
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=1368106344-23383-7-git-send-email-jolsa@redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=namhyung@kernel.org \
--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
all inboxes | Powered by JetHome®