From: Arnaldo Carvalho de Melo <acme@kernel•org>
To: Ingo Molnar <mingo@kernel•org>
Cc: Mark Rutland <mark.rutland@arm•com>,
Clark Williams <williams@redhat•com>,
Heiko Carstens <heiko.carstens@de•ibm.com>,
Alexei Starovoitov <ast@kernel•org>,
Adrian Hunter <adrian.hunter@intel•com>,
"H . Peter Anvin" <hpa@zytor•com>, Jiri Olsa <jolsa@redhat•com>,
linux-s390@vger•kernel.org,
Alexander Shishkin <alexander.shishkin@linux•intel.com>,
Suzuki K Poulouse <suzuki.poulose@arm•com>,
Will Deacon <will.deacon@arm•com>,
Arnaldo Carvalho de Melo <acme@redhat•com>,
Namhyung Kim <namhyung@kernel•org>,
Thomas Gleixner <tglx@linutronix•de>,
linux-arm-kernel@lists•infradead.org,
Mathieu Poirier <mathieu.poirier@linaro•org>,
Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
linux-kernel@vger•kernel.org, linux-perf-users@vger•kernel.org,
Peter Zijlstra <peterz@infradead•org>,
Jiri Olsa <jolsa@kernel•org>,
Martin Schwidefsky <schwidefsky@de•ibm.com>
Subject: [PATCH 24/53] perf arm cs-etm: Use event attributes to send sink information to kernel
Date: Wed, 6 Feb 2019 15:48:34 -0300 [thread overview]
Message-ID: <20190206184903.24054-25-acme@kernel.org> (raw)
In-Reply-To: <20190206184903.24054-1-acme@kernel.org>
From: Mathieu Poirier <mathieu.poirier@linaro•org>
The communication of sink information for a trace session doesn't work
when more than on CPU is involved in the scenario due to the static
nature of sysfs. As such communicate the sink information to each event
by using the perf_event::attr:config2 attribute. The information sent
to the kernel is an hash of the sink's name, which is unique in a
system.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro•org>
Acked-by: Suzuki K Poulouse <suzuki.poulose@arm•com>
Cc: Adrian Hunter <adrian.hunter@intel•com>
Cc: Alexander Shishkin <alexander.shishkin@linux•intel.com>
Cc: Alexei Starovoitov <ast@kernel•org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
Cc: H. Peter Anvin <hpa@zytor•com>
Cc: Heiko Carstens <heiko.carstens@de•ibm.com>
Cc: Jiri Olsa <jolsa@redhat•com>
Cc: Mark Rutland <mark.rutland@arm•com>
Cc: Martin Schwidefsky <schwidefsky@de•ibm.com>
Cc: Namhyung Kim <namhyung@kernel•org>
Cc: Peter Zijlstra <peterz@infradead•org>
Cc: Thomas Gleixner <tglx@linutronix•de>
Cc: Will Deacon <will.deacon@arm•com>
Cc: linux-arm-kernel@lists•infradead.org
Cc: linux-s390@vger•kernel.org
Link: http://lkml.kernel.org/r/20190131184714.20388-6-mathieu.poirier@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat•com>
---
tools/perf/arch/arm/util/cs-etm.c | 44 +++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c
index 2f595cd73da6..4f31cf0d1e6d 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -5,6 +5,7 @@
*/
#include <api/fs/fs.h>
+#include <linux/bits.h>
#include <linux/bitops.h>
#include <linux/compiler.h>
#include <linux/coresight-pmu.h>
@@ -22,6 +23,7 @@
#include "../../util/thread_map.h"
#include "../../util/cs-etm.h"
+#include <errno.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -60,10 +62,48 @@ static int cs_etm_parse_snapshot_options(struct auxtrace_record *itr,
return 0;
}
+static int cs_etm_set_sink_attr(struct perf_pmu *pmu,
+ struct perf_evsel *evsel)
+{
+ char msg[BUFSIZ], path[PATH_MAX], *sink;
+ struct perf_evsel_config_term *term;
+ int ret = -EINVAL;
+ u32 hash;
+
+ if (evsel->attr.config2 & GENMASK(31, 0))
+ return 0;
+
+ list_for_each_entry(term, &evsel->config_terms, list) {
+ if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG)
+ continue;
+
+ sink = term->val.drv_cfg;
+ snprintf(path, PATH_MAX, "sinks/%s", sink);
+
+ ret = perf_pmu__scan_file(pmu, path, "%x", &hash);
+ if (ret != 1) {
+ pr_err("failed to set sink \"%s\" on event %s with %d (%s)\n",
+ sink, perf_evsel__name(evsel), errno,
+ str_error_r(errno, msg, sizeof(msg)));
+ return ret;
+ }
+
+ evsel->attr.config2 |= hash;
+ return 0;
+ }
+
+ /*
+ * No sink was provided on the command line - for _now_ treat
+ * this as an error.
+ */
+ return ret;
+}
+
static int cs_etm_recording_options(struct auxtrace_record *itr,
struct perf_evlist *evlist,
struct record_opts *opts)
{
+ int ret;
struct cs_etm_recording *ptr =
container_of(itr, struct cs_etm_recording, itr);
struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu;
@@ -92,6 +132,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
if (!cs_etm_evsel)
return 0;
+ ret = cs_etm_set_sink_attr(cs_etm_pmu, cs_etm_evsel);
+ if (ret)
+ return ret;
+
if (opts->use_clockid) {
pr_err("Cannot use clockid (-k option) with %s\n",
CORESIGHT_ETM_PMU_NAME);
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-02-06 18:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190206184903.24054-1-acme@kernel.org>
2019-02-06 18:48 ` [PATCH 20/53] perf/aux: Make perf_event accessible to setup_aux() Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 21/53] coresight: perf: Add "sinks" group to PMU directory Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 22/53] coresight: Use event attributes for sink selection Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 23/53] perf pmu: Move EVENT_SOURCE_DEVICE_PATH to PMU header file Arnaldo Carvalho de Melo
2019-02-06 18:48 ` Arnaldo Carvalho de Melo [this message]
2019-02-06 18:48 ` [PATCH 25/53] perf coresight: Remove set_drv_config() API Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 26/53] perf pmu: Remove set_drv_config API Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 36/53] perf cs-etm: Add last instruction information in packet Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 37/53] perf cs-etm: Set sample flags for instruction range packet Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 38/53] perf cs-etm: Set sample flags for trace discontinuity Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 39/53] perf cs-etm: Add exception number in exception packet Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 40/53] perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 41/53] perf cs-etm: Add traceID in packet Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 42/53] perf cs-etm: Set sample flags for exception packet Arnaldo Carvalho de Melo
2019-02-06 18:48 ` [PATCH 43/53] perf cs-etm: Set sample flags for exception return packet Arnaldo Carvalho de Melo
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=20190206184903.24054-25-acme@kernel.org \
--to=acme@kernel$(echo .)org \
--cc=acme@redhat$(echo .)com \
--cc=adrian.hunter@intel$(echo .)com \
--cc=alexander.shishkin@linux$(echo .)intel.com \
--cc=ast@kernel$(echo .)org \
--cc=gregkh@linuxfoundation$(echo .)org \
--cc=heiko.carstens@de$(echo .)ibm.com \
--cc=hpa@zytor$(echo .)com \
--cc=jolsa@kernel$(echo .)org \
--cc=jolsa@redhat$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-perf-users@vger$(echo .)kernel.org \
--cc=linux-s390@vger$(echo .)kernel.org \
--cc=mark.rutland@arm$(echo .)com \
--cc=mathieu.poirier@linaro$(echo .)org \
--cc=mingo@kernel$(echo .)org \
--cc=namhyung@kernel$(echo .)org \
--cc=peterz@infradead$(echo .)org \
--cc=schwidefsky@de$(echo .)ibm.com \
--cc=suzuki.poulose@arm$(echo .)com \
--cc=tglx@linutronix$(echo .)de \
--cc=will.deacon@arm$(echo .)com \
--cc=williams@redhat$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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