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 7/9] perf tests: Add automated precise term test
Date: Thu, 9 May 2013 15:32:22 +0200 [thread overview]
Message-ID: <1368106344-23383-8-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1368106344-23383-1-git-send-email-jolsa@redhat.com>
Adding automated test for precise term test in event:
'cpu/config=1,precise/'
'cpu/config=2,precise/p'
'cpu/config=3,precise/u'
'instructions:p'
'instructions:pp'
to check proper values of precise_ip driven by sysfs
precise attribute.
Also changing other precise related testcases to follow
new precise sysfs rules.
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/tests/parse-events.c | 170 +++++++++++++++++++++++++++++++++++++---
1 file changed, 161 insertions(+), 9 deletions(-)
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index f75328c..3b2e21c 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -5,6 +5,7 @@
#include "sysfs.h"
#include <lk/debugfs.h>
#include "tests.h"
+#include "util.h"
#include <linux/hw_breakpoint.h>
#define TEST_ASSERT_VAL(text, cond) \
@@ -18,6 +19,21 @@ do { \
#define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
+static int get_precise(void)
+{
+ int precise = perf_precise__get();
+
+ /*
+ * The sysfs precise attribute is not supported,
+ * fill in the 1 as default, check
+ * util/parse-events.c::precise_default function
+ */
+ if (precise == -1)
+ precise = 1;
+
+ return precise;
+}
+
static int test__checkevent_tracepoint(struct perf_evlist *evlist)
{
struct perf_evsel *evsel = perf_evlist__first(evlist);
@@ -228,7 +244,8 @@ static int test__checkevent_raw_modifier(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
return test__checkevent_raw(evlist);
}
@@ -240,7 +257,8 @@ static int test__checkevent_numeric_modifier(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
return test__checkevent_numeric(evlist);
}
@@ -296,7 +314,8 @@ static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
return test__checkevent_genhw(evlist);
}
@@ -337,7 +356,8 @@ static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
TEST_ASSERT_VAL("wrong name",
!strcmp(perf_evsel__name(evsel), "mem:0:r:hp"));
@@ -351,7 +371,8 @@ static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
TEST_ASSERT_VAL("wrong name",
!strcmp(perf_evsel__name(evsel), "mem:0:w:up"));
@@ -365,7 +386,8 @@ static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
TEST_ASSERT_VAL("wrong name",
!strcmp(perf_evsel__name(evsel), "mem:0:rw:kp"));
@@ -421,7 +443,8 @@ static int test__checkevent_list(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
return 0;
}
@@ -447,6 +470,69 @@ static int test__checkevent_pmu_name(struct perf_evlist *evlist)
return 0;
}
+static int test__checkevent_pmu_precise(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+ /* cpu/cycles,precise/ */
+ TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+ TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
+ TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
+ TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
+ TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
+ TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
+ TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+ /* precise is driven by sysfs precise attribute */
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
+ TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
+ TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
+
+ return 0;
+}
+
+static int test__checkevent_pmu_precise1(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+ /* cpu/cycles,precise/p */
+ TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+ TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config);
+ TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
+ TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
+ TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
+ TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
+ TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+ /* precise is driven by 'p' modifier */
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
+ TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
+ TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
+
+ return 0;
+}
+
+static int test__checkevent_pmu_precise2(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+ /* cpu/cycles,precise/u */
+ TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+ TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config);
+ TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
+ TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
+ TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
+ TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
+ TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+ /* precise is driven by sysfs precise attribute */
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
+ TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
+ TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
+
+ return 0;
+}
+
static int test__checkevent_pmu_events(struct perf_evlist *evlist)
{
struct perf_evsel *evsel;
@@ -714,7 +800,8 @@ static int test__group4(struct perf_evlist *evlist __maybe_unused)
/* use of precise requires exclude_guest */
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
@@ -732,7 +819,8 @@ static int test__group4(struct perf_evlist *evlist __maybe_unused)
/* use of precise requires exclude_guest */
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
- TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
@@ -1078,6 +1166,50 @@ static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused)
return 0;
}
+static int test__precise_default1(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel, *leader;
+
+ TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+
+ /* instructions:p - default precise_ip value */
+ evsel = leader = perf_evlist__first(evlist);
+ TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
+ TEST_ASSERT_VAL("wrong config",
+ PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
+ TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
+ TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
+ TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
+ TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
+ TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == get_precise());
+
+ return 0;
+}
+
+static int test__precise_default2(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel, *leader;
+
+ TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
+
+ /* instructions:pp - precise_ip == 2 */
+ evsel = leader = perf_evlist__first(evlist);
+ TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
+ TEST_ASSERT_VAL("wrong config",
+ PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
+ TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
+ TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
+ TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
+ TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
+ TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+ TEST_ASSERT_VAL("wrong precise_ip",
+ evsel->attr.precise_ip == 2);
+
+ return 0;
+}
+
static int count_tracepoints(void)
{
char events_path[PATH_MAX];
@@ -1302,6 +1434,14 @@ static struct evlist_test test__events[] = {
.name = "{instructions,branch-misses}:Su",
.check = test__leader_sample2,
},
+ [40] = {
+ .name = "instructions:p",
+ .check = test__precise_default1,
+ },
+ [41] = {
+ .name = "instructions:pp",
+ .check = test__precise_default2,
+ },
};
static struct evlist_test test__events_pmu[] = {
@@ -1313,6 +1453,18 @@ static struct evlist_test test__events_pmu[] = {
.name = "cpu/config=1,name=krava/u,cpu/config=2/u",
.check = test__checkevent_pmu_name,
},
+ [2] = {
+ .name = "cpu/config=1,precise/",
+ .check = test__checkevent_pmu_precise,
+ },
+ [3] = {
+ .name = "cpu/config=2,precise/p",
+ .check = test__checkevent_pmu_precise1,
+ },
+ [4] = {
+ .name = "cpu/config=3,precise/u",
+ .check = test__checkevent_pmu_precise2,
+ },
};
struct terms_test {
--
1.7.11.7
next prev parent reply other threads:[~2013-05-09 13:33 UTC|newest]
Thread overview: 41+ 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 ` [PATCH 6/9] perf tools: Set maximum precise value for 'precise' term Jiri Olsa
2013-05-09 13:32 ` Jiri Olsa [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2013-01-26 17:27 Jiri Olsa
2013-01-26 17:27 ` [PATCH 7/9] perf tests: Add automated precise term test 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-8-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®