lkml.org 
[lkml]   [2019]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 5/8] perf tools: Get precise_ip from the pmu config
Date
Getting precise_ip field from the perf_pmu::max_precise
config read from sysfs. If it's not available falling
back to current detection function.

This fixes perf c2c usage of 'P' modifier on memory events,
where the standard detection fails, because of way too many
new perf_event_attr features added recently.

Use PYTHON_MOD to distinguish python perf module build
to exclude pmu.o object call being compiled in. There's
the flex/bison (and other) object dependencies, that
we'd need to teach setup.py about.

Link: http://lkml.kernel.org/n/tip-zyegnaq8xlkhh4sgfl4tnvui@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/evsel.c | 28 +++++++++++++++++++++++++++-
tools/perf/util/setup.py | 2 +-
2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index dfe2958e6287..eec542bab815 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -870,6 +870,32 @@ static bool is_dummy_event(struct perf_evsel *evsel)
(evsel->attr.config == PERF_COUNT_SW_DUMMY);
}

+#ifndef PYTHON_MOD
+static int pmu_get_precise(const char *pmu_name)
+{
+ struct perf_pmu *pmu = pmu_name ? perf_pmu__find(pmu_name) : NULL;
+
+ /* If unsupported pmu->max_precise is -1. */
+ return pmu ? pmu->max_precise : -1;
+}
+#else
+static int pmu_get_precise(const char *pmu_name __maybe_unused)
+{
+ return 0;
+}
+#endif
+
+static void perf_evsel__set_max_precise_ip(struct perf_evsel *evsel)
+{
+ int max_precise = pmu_get_precise(evsel->pmu_name);
+ struct perf_event_attr *attr = &evsel->attr;
+
+ if (max_precise >= 0)
+ attr->precise_ip = max_precise;
+ else
+ perf_event_attr__set_max_precise_ip(attr);
+}
+
/*
* The enable_on_exec/disabled value strategy:
*
@@ -1091,7 +1117,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
}

if (evsel->precise_max)
- perf_event_attr__set_max_precise_ip(attr);
+ perf_evsel__set_max_precise_ip(evsel);

if (opts->all_user) {
attr->exclude_kernel = 1;
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 5b5a167b43ce..9eee3467ac5d 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -37,7 +37,7 @@ class install_lib(_install_lib):

cflags = getenv('CFLAGS', '').split()
# switch off several checks (need to be at the end of cflags list)
-cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls' ]
+cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls', '-DPYTHON_MOD' ]
if cc != "clang":
cflags += ['-Wno-cast-function-type' ]

--
2.17.2
\
 
 \ /
  Last update: 2019-03-05 16:27    [W:0.087 / U:2.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site