lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1359221275-24254-6-git-send-email-jolsa@redhat.com>
Date:	Sat, 26 Jan 2013 18:27:51 +0100
From:	Jiri Olsa <jolsa@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Jiri Olsa <jolsa@...hat.com>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...e.hu>,
	Namhyung Kim <namhyung@...nel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Andi Kleen <ak@...ux.intel.com>,
	David Ahern <dsahern@...il.com>
Subject: [PATCH 5/9] perf tools: Read maximal precise value for 'precise' term

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@...hat.com>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: David Ahern <dsahern@...il.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 217ce56..a92c403 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -570,9 +570,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 = perf_precise__get();
+		else {
+			if ((unsigned)term->val.num > 2)
+				return -EINVAL;
+			attr->precise_ip = term->val.num;
+		}
 		break;
 	default:
 		return -EINVAL;
@@ -1210,6 +1215,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 9d526cf..a5c6d65 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -74,6 +74,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 9d43c86..376e9b4 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -399,7 +399,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

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ