Hi Greg
Please find a couple of fixes for v6.4 for the coresight self-hosted tracing
subsystem.
Kindly pull.
Suzuki
The following changes since commit ac9a78681b921877518763ba0e89202254349d1b:
Linux 6.4-rc1 (2023-05-07 13:34:35 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux.git tags/coresight-fixes-v6.4
for you to fetch changes up to 04ac7f98b92181179ea84439642493f3826d04a2:
coresight: perf: Release Coresight path when alloc trace id failed (2023-05-11 11:18:21 +0100)
----------------------------------------------------------------
coresight: Fixes for v6.4
Couple of fixes for coresight self-hosted tracing subsystem for v6.4.
These include :
- Fix signedness bug in tmc_etr_buf_insert_barrier_packet()
- Fix memory leak with failing to release the path if trace-id allocation fails
Signed-off-by: Suzuki K Poulose <suzuki.poulose(a)arm.com>
----------------------------------------------------------------
Dan Carpenter (1):
coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet()
Ruidong Tian (1):
coresight: perf: Release Coresight path when alloc trace id failed
drivers/hwtracing/coresight/coresight-etm-perf.c | 1 +
drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
Pre 5.11 kernels don't support 'contextid1' and 'contextid2' so
validation would be skipped. By adding an additional check for
'contextid', old kernels will still have validation done even though
contextid would either be contextid1 or contextid2.
Additionally now that it's possible to override options, an existing bug
in the validation is revealed. 'val' is overwritten by the contextid1
validation, and re-used for contextid2 validation causing it to always
fail. '!val || val != 0x4' is the same as 'val != 0x4' because 0 is also
!= 4, so that expression can be simplified and the temp variable not
overwritten.
Fixes: 35c51f83dd1e ("perf cs-etm: Validate options after applying them")
Reviewed-by: Leo Yan <leo.yan(a)linaro.org>
Link: https://lore.kernel.org/all/20230501073452.GA4660@leoy-yangtze.lan
Signed-off-by: James Clark <james.clark(a)arm.com>
---
tools/perf/arch/arm/util/cs-etm.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c
index 77cb03e6ff87..9ca040bfb1aa 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -78,9 +78,9 @@ static int cs_etm_validate_context_id(struct auxtrace_record *itr,
char path[PATH_MAX];
int err;
u32 val;
- u64 contextid =
- evsel->core.attr.config &
- (perf_pmu__format_bits(&cs_etm_pmu->format, "contextid1") |
+ u64 contextid = evsel->core.attr.config &
+ (perf_pmu__format_bits(&cs_etm_pmu->format, "contextid") |
+ perf_pmu__format_bits(&cs_etm_pmu->format, "contextid1") |
perf_pmu__format_bits(&cs_etm_pmu->format, "contextid2"));
if (!contextid)
@@ -114,8 +114,7 @@ static int cs_etm_validate_context_id(struct auxtrace_record *itr,
* 0b00100 Maximum of 32-bit Context ID size.
* All other values are reserved.
*/
- val = BMVAL(val, 5, 9);
- if (!val || val != 0x4) {
+ if (BMVAL(val, 5, 9) != 0x4) {
pr_err("%s: CONTEXTIDR_EL1 isn't supported, disable with %s/contextid1=0/\n",
CORESIGHT_ETM_PMU_NAME, CORESIGHT_ETM_PMU_NAME);
return -EINVAL;
--
2.34.1
Hi Ian,
On Mon, May 08, 2023 at 02:31:28PM -0700, Ian Rogers wrote:
> Change "../cs-etm.h" to just "cs-etm.h" as ../cs-etm.h doesn't exist.
>
> Signed-off-by: Ian Rogers <irogers(a)google.com>
> ---
> tools/perf/arch/arm/util/pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c
> index 860a8b42b4b5..46154c226fbb 100644
> --- a/tools/perf/arch/arm/util/pmu.c
> +++ b/tools/perf/arch/arm/util/pmu.c
> @@ -12,7 +12,7 @@
> #include "arm-spe.h"
> #include "hisi-ptt.h"
> #include "../../../util/pmu.h"
> -#include "../cs-etm.h"
This code is a bit tricky. Here it deliberately uses "../cs-etm.h" to
avoid including the header file in the same folder, alternatively, the
compiler option "-I/home/leoy/Work/linux/tools/perf/util/include" will
lead the C file to include "tools/perf/util/include/../cs-etm.h".
> +#include "cs-etm.h"
So with this change, perf will fail to build actually :)
We need to change to:
#include "../../../util/cs-etm.h"
With above change:
Reviewed-by: Leo Yan <leo.yan(a)linaro.org>
Thanks for code improvement!
> struct perf_event_attr
> *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
> --
> 2.40.1.521.gf1e218fcd8-goog
>
The first commit contains a fix for a recently introduced regression,
but was always a shortcoming in the Coresight code anyway.
The following commits are a tidyup in preparation for the last commit,
which is a fairly major change to the decode logic that's also
indirectly related to the regression so I thought it would be good time
to fix that now.
Applies to perf/core (9be6ab181b7b)
James Clark (7):
perf: cs-etm: Fix timeless decode mode detection
perf tools: Add util function for overriding user set config values
perf: cs-etm: Don't test full_auxtrace because it's always set
perf: cs-etm: Validate options after applying them
perf: cs-etm: Allow user to override timestamp and contextid settings
perf: cs-etm: Use bool type for boolean values
perf: cs-etm: Add separate decode paths for timeless and per-thread
modes
tools/perf/arch/arm/util/cs-etm.c | 223 +++++++++---------
tools/perf/arch/arm/util/pmu.c | 2 +
tools/perf/arch/arm64/util/arm-spe.c | 26 +-
tools/perf/arch/x86/util/intel-pt.c | 22 +-
tools/perf/tests/shell/test_arm_coresight.sh | 24 ++
.../perf/util/cs-etm-decoder/cs-etm-decoder.h | 8 +-
tools/perf/util/cs-etm.c | 200 +++++++++++-----
tools/perf/util/cs-etm.h | 6 +-
tools/perf/util/evsel.c | 29 +++
tools/perf/util/evsel.h | 3 +
10 files changed, 325 insertions(+), 218 deletions(-)
--
2.34.1