On Thu, Aug 27, 2020 at 03:34:08PM +0100, Mike Leach wrote:
Adds handling for the cs_etm/cs_config directory that contains loaded configurations that may be selected by the perf command line using the @name syntax.
Adds flag to mark the hash ID found as a configuration name rather than a sink name.
Signed-off-by: Mike Leach mike.leach@linaro.org
include/linux/coresight-pmu.h | 3 +++ tools/include/linux/coresight-pmu.h | 3 +++ tools/perf/arch/arm/util/cs-etm.c | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h index b0e35eec6499..9bb0fb46f576 100644 --- a/include/linux/coresight-pmu.h +++ b/include/linux/coresight-pmu.h @@ -22,6 +22,9 @@ #define ETM4_CFG_BIT_TS 11 #define ETM4_CFG_BIT_RETSTK 12 +/* Coresight config select bit - mark sink ID as a config ID */ +#define CSSYS_BIT_CONFIG_SEL 36
static inline int coresight_get_trace_id(int cpu) { /* diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h index b0e35eec6499..9bb0fb46f576 100644 --- a/tools/include/linux/coresight-pmu.h +++ b/tools/include/linux/coresight-pmu.h @@ -22,6 +22,9 @@ #define ETM4_CFG_BIT_TS 11 #define ETM4_CFG_BIT_RETSTK 12 +/* Coresight config select bit - mark sink ID as a config ID */ +#define CSSYS_BIT_CONFIG_SEL 36
I would make this bit 32 and the presets 33-36. That way if we need more presets then we don't have to mess around with anything else. Note that this needs to be communicated to perf using the PMU_FORMAT_ATTR() macro in cs-etm-perf.c, as you did for the presets.
static inline int coresight_get_trace_id(int cpu) { /* diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index cad7bf783413..4c46448396f1 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -219,6 +219,7 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu, struct evsel_config_term *term; int ret = -EINVAL; u32 hash;
- u64 config_sel = 0;
if (evsel->core.attr.config2 & GENMASK(31, 0)) return 0; @@ -228,9 +229,21 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu, continue; sink = term->val.str;
s/sink/str
Otherwise the code becomes confusing and harder to maintain.
snprintf(path, PATH_MAX, "sinks/%s", sink);
/* re-using @val for config select - check for config first */
snprintf(path, PATH_MAX, "cs_config/%s", sink);
This is already in the cs_etm directory so it could just be "configs" to follow the "sinks".
ret = perf_pmu__scan_file(pmu, path, "%x", &hash);
if (ret != 1) {
/* not config, look for sink */
snprintf(path, PATH_MAX, "sinks/%s", sink);
ret = perf_pmu__scan_file(pmu, path, "%x", &hash);
} else {
/* is a config - mark as such */
config_sel = BIT(CSSYS_BIT_CONFIG_SEL);
}
- if (ret != 1) { pr_err("failed to set sink "%s" on event %s with %d (%s)\n", sink, evsel__name(evsel), errno,
The error message will need to be changed based on whether we have a configuration or a sink. I would also change the name of the function, as cs_etm_set_sink_attr() isn't accurate anymore. Something like cs_etm_set_session_attr() would be better.
@@ -238,7 +251,7 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu, return ret; }
evsel->core.attr.config2 |= hash;
return 0; }evsel->core.attr.config2 |= hash | config_sel;
2.17.1