On Fri, Jul 26, 2024 at 07:00:55PM +0300, Adrian Hunter wrote:
> On 26/07/24 17:41, Arnaldo Carvalho de Melo wrote:
> > On Thu, Jul 18, 2024 at 06:06:16PM +0300, Adrian Hunter wrote:
> >> On 18/07/24 15:58, Peter Zijlstra wrote:
> >>> On Thu, Jul 18, 2024 at 01:51:26PM +0200, Peter Zijlstra wrote:
> >>>
> >>>> OK, let me do that and make a few more edits and see if I can stare at
> >>>> that next patch some.
> >>>
> >>> I pushed out a stack of patches into queue.git perf/core
> >>> Could you please double check I didn't wreck anything?
> >>
> >> Looks fine, and seems to work OK in a brief test.
> >>
> >> Thank you! :-)
> >
> > So should I go ahead and pick the tooling patches since the kernel bits
> > are merged?
>
> Not exactly merged. Probably should wait until it is in tip at least.
Ok, so I get just these, as you asked on another message:
acme@x1:~/git/perf-tools-next$ git log --oneline -5 perf-tools-next/tmp.perf-tools-next
9140fec01b2de8d3 (HEAD -> perf-tools-next, perf-tools-next/tmp.perf-tools-next, perf-tools-next.korg/tmp.perf-tools-next, number/perf-tools-next, acme.korg/tmp.perf-tools-next) perf tools: Enable evsel__is_aux_event() to work for S390_CPUMSF
c3b7dba6ea81a5b1 perf tools: Enable evsel__is_aux_event() to work for ARM/ARM64
866400c0b08ef9d9 perf scripts python cs-etm: Restore first sample log in verbose mode
08ee74eb03e37191 perf cs-etm: Output 0 instead of 0xdeadbeef when exception packets are flushed
c22dd7ec2b2808b2 perf inject: Convert comma to semicolon
acme@x1:~/git/perf-tools-next$
It'll go to perf-tools-next once 6.11-rc1 is out.
- Arnaldo
This will allow sessions with more than CORESIGHT_TRACE_IDS_MAX ETMs
as long as there are fewer than that many ETMs connected to each sink.
Each sink owns its own trace ID map, and any Perf session connecting to
that sink will allocate from it, even if the sink is currently in use by
other users. This is similar to the existing behavior where the dynamic
trace IDs are constant as long as there is any concurrent Perf session
active. It's not completely optimal because slightly more IDs will be
used than necessary, but the optimal solution involves tracking the PIDs
of each session and allocating ID maps based on the session owner. This
is difficult to do with the combination of per-thread and per-cpu modes
and some scheduling issues. The complexity of this isn't likely to worth
it because even with multiple users they'd just see a difference in the
ordering of ID allocations rather than hitting any limits (unless the
hardware does have too many ETMs connected to one sink).
Per-thread mode works but only until there are any overlapping IDs, at
which point Perf will error out. Both per-thread mode and sysfs mode are
left to future changes, but both can be added on top of this initial
implementation and only sysfs mode requires further driver changes.
The HW_ID version field hasn't been bumped in order to not break Perf
which already has an error condition for other values of that field.
Instead a new minor version has been added which signifies that there
are new fields but the old fields are backwards compatible.
Changes since v5:
* Hide queue number printout behind -v option
* Style change in cs_etm__process_aux_output_hw_id()
* Move new format enum to an earlier commit to reduce churn
Changes since v4:
* Fix compilation failure when TRACE_ID_DEBUG is set
* Expand comment about not freeing individual trace IDs in
free_event_data()
Changes since v3:
* Fix issue where trace IDs were overwritten by possibly invalid ones
by Perf in unformatted mode. Now the HW_IDs are also used for
unformatted mode unless the kernel didn't emit any.
* Add a commit to check the OpenCSD version.
* Add a commit to not save invalid IDs in the Perf header.
* Replace cs_etm_queue's formatted and formatted_set members with a
single enum which is easier to use.
* Drop CORESIGHT_TRACE_ID_UNUSED_FLAG as it's no longer needed.
* Add a commit to print the queue number in the raw dump.
* Don't assert on the number of unformatted decoders if decoders == 0.
Changes since v2:
* Rebase on coresight-next 6.10-rc2 (b9b25c8496).
* Fix double free of csdev if device registration fails.
* Fix leak of coresight_trace_id_perf_start() if trace ID allocation
fails.
* Don't resend HW_ID for sink changes in per-thread mode. The existing
CPU field on AUX records can be used to track this instead.
* Tidy function doc for coresight_trace_id_release_all()
* Drop first two commits now that they are in coresight-next
* Add a commit to make the trace ID spinlock local to the map
Changes since V1:
* Rename coresight_device.perf_id_map to perf_sink_id_map.
* Instead of outputting a HW_ID for each reachable ETM, output
the sink ID and continue to output only the HW_ID once for
each mapping.
* Keep the first two Perf patches so that it applies cleanly
on coresight-next, although they have been applied on perf-tools-next
* Add new *_map() functions to the trace ID public API instead of
modifying existing ones.
* Collapse "coresight: Pass trace ID map into source enable" into
"coresight: Use per-sink trace ID maps for Perf sessions" because the
first commit relied on the default map being accessible which is no
longer necessary due to the previous bullet point.
James Clark (17):
perf: cs-etm: Create decoders after both AUX and HW_ID search passes
perf: cs-etm: Allocate queues for all CPUs
perf: cs-etm: Move traceid_list to each queue
perf: cs-etm: Create decoders based on the trace ID mappings
perf: cs-etm: Only save valid trace IDs into files
perf: cs-etm: Support version 0.1 of HW_ID packets
perf: cs-etm: Print queue number in raw trace dump
perf: cs-etm: Add runtime version check for OpenCSD
coresight: Remove unused ETM Perf stubs
coresight: Clarify comments around the PID of the sink owner
coresight: Move struct coresight_trace_id_map to common header
coresight: Expose map arguments in trace ID API
coresight: Make CPU id map a property of a trace ID map
coresight: Use per-sink trace ID maps for Perf sessions
coresight: Remove pending trace ID release mechanism
coresight: Emit sink ID in the HW_ID packets
coresight: Make trace ID map spinlock local to the map
drivers/hwtracing/coresight/coresight-core.c | 37 +-
drivers/hwtracing/coresight/coresight-dummy.c | 3 +-
.../hwtracing/coresight/coresight-etm-perf.c | 43 +-
.../hwtracing/coresight/coresight-etm-perf.h | 18 -
.../coresight/coresight-etm3x-core.c | 9 +-
.../coresight/coresight-etm4x-core.c | 9 +-
drivers/hwtracing/coresight/coresight-priv.h | 1 +
drivers/hwtracing/coresight/coresight-stm.c | 3 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 3 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 5 +-
drivers/hwtracing/coresight/coresight-tmc.h | 5 +-
drivers/hwtracing/coresight/coresight-tpdm.c | 3 +-
.../hwtracing/coresight/coresight-trace-id.c | 138 ++--
.../hwtracing/coresight/coresight-trace-id.h | 70 +-
include/linux/coresight-pmu.h | 17 +-
include/linux/coresight.h | 21 +-
tools/build/feature/test-libopencsd.c | 4 +-
tools/include/linux/coresight-pmu.h | 17 +-
tools/perf/Makefile.config | 2 +-
tools/perf/arch/arm/util/cs-etm.c | 11 +-
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 49 +-
.../perf/util/cs-etm-decoder/cs-etm-decoder.h | 3 +-
.../util/cs-etm-decoder/cs-etm-min-version.h | 13 +
tools/perf/util/cs-etm.c | 629 +++++++++++-------
tools/perf/util/cs-etm.h | 12 +-
25 files changed, 650 insertions(+), 475 deletions(-)
create mode 100644 tools/perf/util/cs-etm-decoder/cs-etm-min-version.h
--
2.34.1
On Tue, Jul 23, 2024 at 12:09:46PM +0300, Adrian Hunter wrote:
> On 23/07/24 11:26, Leo Yan wrote:
> > On 7/15/2024 5:07 PM, Adrian Hunter wrote:
> >>
> >> evsel__is_aux_event() identifies AUX area tracing selected events.
> >>
> >> S390_CPUMSF uses a raw event type (PERF_TYPE_RAW - refer
> >> s390_cpumsf_evsel_is_auxtrace()) not a PMU type value that could be checked
> >> in evsel__is_aux_event(). However it sets needs_auxtrace_mmap (refer
> >> auxtrace_record__init()), so check that first.
> >>
> >> Currently, the features that use evsel__is_aux_event() are used only by
> >> Intel PT, but that may change in the future.
> >>
> >> Signed-off-by: Adrian Hunter <adrian.hunter(a)intel.com>
> >> Acked-by: Ian Rogers <irogers(a)google.com>
> >> Reviewed-by: Andi Kleen <ak(a)linux.intel.com>
> >
> > Reviewed-by: Leo Yan <leo.yan(a)arm.com>
>
> Namhyung, could we get patches 5 and 6 from this series
> applied? They are independent and Leo's new patch set is
> dependent on patch 5.
I'm getting those two into tmp.perf-tools-next, probably should pick the
rest as peterz has the kernel bits already in his queue.git/perf/core,
right?
- Arnaldo
> >
> >> ---
> >> tools/perf/util/pmu.c | 6 +++++-
> >> 1 file changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> >> index 986166bc7c78..0b38c51bd6eb 100644
> >> --- a/tools/perf/util/pmu.c
> >> +++ b/tools/perf/util/pmu.c
> >> @@ -1199,8 +1199,12 @@ void perf_pmu__warn_invalid_formats(struct perf_pmu *pmu)
> >>
> >> bool evsel__is_aux_event(const struct evsel *evsel)
> >> {
> >> - struct perf_pmu *pmu = evsel__find_pmu(evsel);
> >> + struct perf_pmu *pmu;
> >>
> >> + if (evsel->needs_auxtrace_mmap)
> >> + return true;
> >> +
> >> + pmu = evsel__find_pmu(evsel);
> >> return pmu && pmu->auxtrace;
> >> }
> >>
> >> --
> >> 2.34.1
> >>
> >>
On Thu, Jul 18, 2024 at 06:06:16PM +0300, Adrian Hunter wrote:
> On 18/07/24 15:58, Peter Zijlstra wrote:
> > On Thu, Jul 18, 2024 at 01:51:26PM +0200, Peter Zijlstra wrote:
> >
> >> OK, let me do that and make a few more edits and see if I can stare at
> >> that next patch some.
> >
> > I pushed out a stack of patches into queue.git perf/core
> > Could you please double check I didn't wreck anything?
>
> Looks fine, and seems to work OK in a brief test.
>
> Thank you! :-)
So should I go ahead and pick the tooling patches since the kernel bits
are merged?
- Arnaldo
On Tue, Jul 23, 2024 at 05:05:09PM +0100, Leo Yan wrote:
> On 7/23/2024 2:28 PM, James Clark wrote:
> >
> > The linked commit moved the early return on the first sample to before
> > the verbose log, so move the log earlier too. Now the first sample is
> > also logged and not skipped.
> >
> > Fixes: 2d98dbb4c9c5 ("perf scripts python arm-cs-trace-disasm.py: Do not ignore disam first sample")
> > Signed-off-by: James Clark <james.clark(a)linaro.org>
>
> Reviewed-by: Leo Yan <leo.yan(a)arm.com>
Thanks, applied to tmp.perf-tools-next,
- Arnaldo
> > ---
> > tools/perf/scripts/python/arm-cs-trace-disasm.py | 9 ++++-----
> > 1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py
> > index d973c2baed1c..7aff02d84ffb 100755
> > --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py
> > +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py
> > @@ -192,17 +192,16 @@ def process_event(param_dict):
> > ip = sample["ip"]
> > addr = sample["addr"]
> >
> > + if (options.verbose == True):
> > + print("Event type: %s" % name)
> > + print_sample(sample)
> > +
> > # Initialize CPU data if it's empty, and directly return back
> > # if this is the first tracing event for this CPU.
> > if (cpu_data.get(str(cpu) + 'addr') == None):
> > cpu_data[str(cpu) + 'addr'] = addr
> > return
> >
> > -
> > - if (options.verbose == True):
> > - print("Event type: %s" % name)
> > - print_sample(sample)
> > -
> > # If cannot find dso so cannot dump assembler, bail out
> > if (dso == '[unknown]'):
> > return
> > --
> > 2.34.1
> >
I noticed this when looking into Ganapat's fix to arm-cs-trace-disasm.py.
I assumed that seeing this in the output was a bug and went to
investigate why it happened in some cases and not others.
It turned out to not actually be a bug, but I think it doesn't look right.
In the end this change doesn't really accomplish anything and I'm not
sure if it's worth putting it in or not?
Maybe it will save someone doing the same thing as me, or maybe it will
actually break something if someones script is looking for 0xdeadbeef?
James Clark (1):
perf cs-etm: Output 0 instead of 0xdeadbeef when exception packets are
flushed
tools/perf/util/cs-etm.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--
2.34.1
On 24/07/2024 4:00 pm, Leo Yan wrote:
> On 7/24/2024 3:33 PM, James Clark wrote:
>>
>> The example shows the vmlinux path being given to the script, but this
>> only works when running on the target. If the script is run off the
>> target, then confusingly the vmlinux argument also needs to be given to
>> Perf as well.
>>
>> Without going into too much detail in the example about when it is or
>> isn't required, just include it. It doesn't do any harm even when
>> running on the target. Now the example command works in both places.
>>
>> Signed-off-by: James Clark <james.clark(a)linaro.org>
>
> The change makes senses to me. Just check a bit, does it need to add the same
> option for the command "only source line and symbols"?
>
> Thanks,
> Leo
>
I assumed that because that one didn't have vmlinux at all then it's
just for userspace tracing. I think it's good to have an example without
vmlinux to show that it's not a strict requirement.
>> ---
>> tools/perf/scripts/python/arm-cs-trace-disasm.py | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py
>> index 7aff02d84ffb..4aeb9b497f7a 100755
>> --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py
>> +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py
>> @@ -19,10 +19,10 @@ from perf_trace_context import perf_set_itrace_options, \
>> # Below are some example commands for using this script.
>> #
>> # Output disassembly with objdump:
>> -# perf script -s scripts/python/arm-cs-trace-disasm.py \
>> +# perf script -k path/to/vmlinux -s scripts/python/arm-cs-trace-disasm.py \
>> # -- -d objdump -k path/to/vmlinux
>> # Output disassembly with llvm-objdump:
>> -# perf script -s scripts/python/arm-cs-trace-disasm.py \
>> +# perf script -k path/to/vmlinux -s scripts/python/arm-cs-trace-disasm.py \
>> # -- -d llvm-objdump-11 -k path/to/vmlinux
>> # Output only source line and symbols:
>> # perf script -s scripts/python/arm-cs-trace-disasm.py
>> --
>> 2.34.1
>>
The example shows the vmlinux path being given to the script, but this
only works when running on the target. If the script is run off the
target, then confusingly the vmlinux argument also needs to be given to
Perf as well.
Without going into too much detail in the example about when it is or
isn't required, just include it. It doesn't do any harm even when
running on the target. Now the example command works in both places.
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
tools/perf/scripts/python/arm-cs-trace-disasm.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py
index 7aff02d84ffb..4aeb9b497f7a 100755
--- a/tools/perf/scripts/python/arm-cs-trace-disasm.py
+++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py
@@ -19,10 +19,10 @@ from perf_trace_context import perf_set_itrace_options, \
# Below are some example commands for using this script.
#
# Output disassembly with objdump:
-# perf script -s scripts/python/arm-cs-trace-disasm.py \
+# perf script -k path/to/vmlinux -s scripts/python/arm-cs-trace-disasm.py \
# -- -d objdump -k path/to/vmlinux
# Output disassembly with llvm-objdump:
-# perf script -s scripts/python/arm-cs-trace-disasm.py \
+# perf script -k path/to/vmlinux -s scripts/python/arm-cs-trace-disasm.py \
# -- -d llvm-objdump-11 -k path/to/vmlinux
# Output only source line and symbols:
# perf script -s scripts/python/arm-cs-trace-disasm.py
--
2.34.1