Extend logging on TMC start / stop errors
Recent issues with trying to debug TMC timeouts and flush issues shows
a general lack of logging and context around the possible errors
Add logging to general wait for stop coresight routines and return values of
watched registers.
Update TMC to use this logging.
Changes since v2:
1) update coresight_timeout_retval() function to accept NULL for reg return
pointer to simplify coresight_timeout()
2) Increase checks for MemErr bit in TMC status registers on error.
Changes since v1:
Rebase to coresight/next (kernel 6.13-rc2)
Mike Leach (3):
coresight: Update timeout functions to allow return of test register
value
coresight: tmc: Update error logging in tmc common functions
coresight: etf: etr: Update logging around flush_and_stop() errors
drivers/hwtracing/coresight/coresight-core.c | 50 +++++++++++++++----
.../hwtracing/coresight/coresight-tmc-core.c | 44 +++++++++++++---
.../hwtracing/coresight/coresight-tmc-etf.c | 12 +++--
.../hwtracing/coresight/coresight-tmc-etr.c | 8 ++-
drivers/hwtracing/coresight/coresight-tmc.h | 2 +-
include/linux/coresight.h | 2 +
6 files changed, 93 insertions(+), 25 deletions(-)
--
2.25.1
This set extends the configuration management support to allow loading and
unloading of configurations as structured tables.
The existing coresight configuration configfs API is additionally extended
to use this table functionality to load and unload configuration tables
as binary files.
This allows coresight configurations to be loaded at runtime, and independently
of kernel version, without the requirement to re-compile as built in kernel
modules.
Loading configurations in this way provides a method for atomically programming
the trace control elements (e.g. filters and triggers) of multiple connected
CoreSight components as a single system for a trace session when selected on
the command line both when running trace via perf or running trace via sysfs.
All configuration are validated at load time as being compatible with the
CoreSight system in use.
Additional load and unload attributes are provided in the
/config/cs-syscfg subsytem base group to implement the load functionality.
Routines to generate configuration tables are supplied in
./tools/coresight.
Example generator and reader applications are provided.
Tools may be cross compiled or built for use on host system.
Documentation is updated to describe feature usage.
Changes since v6:
1) Rebased to coresight/next - 6.12-rc4
2) Adjusted patches to split the load/unload API from the configfs attribute
declarations
3) As unload order is strictly enforced to ensure dependencies are not broken,
unload is now a simple write to attribute to automatically unload the last
loaded configuration without need for name of configuration.
Changes since v5:
1) Possible memory leak removed.
Reported-by: kernel test robot.
Reported-by: Dan Carpenter
2) Reuse mechanism for reader code revised. (Christoph)
3) Unload mechnism now by name in standard attribute, rather than
entire file
4) Mechanism to check last loaded configuration can be unloaded.
5) Documentation updates.
Changes since v4:
1) Update coresight/next - 6.1-rc3
2) Update to lockdep fixes to avoid read lock race in configfs.
Changes since v3:
1) Rebase & tested on coresight/next - 5.19-rc3 - which includes the
fix patch for earlier configfs works.
2) Lockdep investigations resulted in re-design of some of the code
accessing configfs.
3) moved load and unload attributes to root of cs-syscfg. (Mathieu)
4) Additional minor fixes suggested by Mathieu.
5) Memory for configfs loaded and unloaded configurations is now
explicitly freed.
6) LOCKDEP nesting fix for configfs base code (fs/configfs/dir.c)
Changes since v2:
1) Rebased & tested on coresight/next - 5.18-rc2
2) Moved coresight config generator and reader programs from samples to
tools/coresight. Docs updated to match. (suggested by Mathieu)
3) userspace builds now use userspace headers from tools/...
4) Other minor fixes from Mathieu's review.
Changes since v1:
1) Rebased to coresight/next - 5.16-rc1 with previous coresight config
set applied.
2) Makefile.host fixed to default to all target.
Mike Leach (9):
coresight: config: Add configuration table processing funtionality
coresight: configfs: Update memory allocation / free for configfs
elements
coresight: config: API to dynamically load / unload config tables
coresight: configfs: Add static type for config attributes
coresight: configfs: Add attributes for unload operations
coresight: configfs: Add attribute to load a configuration table
coresight: config: extract shared structures to common header file
coresight: tools: Add configuration table test tools
Documentation: coresight: Docs for configuration table load
.../trace/coresight/coresight-config.rst | 287 ++++++++-
MAINTAINERS | 1 +
drivers/hwtracing/coresight/Makefile | 3 +-
.../coresight/coresight-config-desc.h | 105 ++++
.../coresight/coresight-config-table.c | 431 +++++++++++++
.../coresight/coresight-config-table.h | 151 +++++
.../hwtracing/coresight/coresight-config.h | 98 +--
.../coresight/coresight-syscfg-configfs.c | 577 ++++++++++++++++--
.../hwtracing/coresight/coresight-syscfg.c | 103 +++-
.../hwtracing/coresight/coresight-syscfg.h | 19 +-
tools/coresight/Makefile | 56 ++
tools/coresight/coresight-cfg-bufw.c | 328 ++++++++++
tools/coresight/coresight-cfg-bufw.h | 26 +
tools/coresight/coresight-cfg-example1.c | 62 ++
tools/coresight/coresight-cfg-example2.c | 95 +++
tools/coresight/coresight-cfg-examples.h | 25 +
tools/coresight/coresight-cfg-file-gen.c | 58 ++
tools/coresight/coresight-cfg-file-gen.h | 17 +
tools/coresight/coresight-cfg-file-read.c | 239 ++++++++
tools/coresight/coresight-config-uapi.h | 105 ++++
20 files changed, 2644 insertions(+), 142 deletions(-)
create mode 100644 drivers/hwtracing/coresight/coresight-config-desc.h
create mode 100644 drivers/hwtracing/coresight/coresight-config-table.c
create mode 100644 drivers/hwtracing/coresight/coresight-config-table.h
create mode 100644 tools/coresight/Makefile
create mode 100644 tools/coresight/coresight-cfg-bufw.c
create mode 100644 tools/coresight/coresight-cfg-bufw.h
create mode 100644 tools/coresight/coresight-cfg-example1.c
create mode 100644 tools/coresight/coresight-cfg-example2.c
create mode 100644 tools/coresight/coresight-cfg-examples.h
create mode 100644 tools/coresight/coresight-cfg-file-gen.c
create mode 100644 tools/coresight/coresight-cfg-file-gen.h
create mode 100644 tools/coresight/coresight-cfg-file-read.c
create mode 100644 tools/coresight/coresight-config-uapi.h
--
2.25.1
This change seems to omit devices:
etm3x - which provides support for ETMv3 and PTM, both of which are
valid trace sources in the cs_etm handling code.
stm - can be integrated into the kernel STM via configfs providing a
MIPI source for ftrace.
Mike
On Tue, 3 Dec 2024 at 11:49, Yeoreum Yun <yeoreum.yun(a)arm.com> wrote:
>
> In some coresight drivers, drvdata->spinlock can be held during __schedule()
> by perf_event_task_sched_out()/in().
>
> Since drvdata->spinlock type is spinlock_t and
> perf_event_task_sched_out()/in() is called after acquiring rq_lock,
> which is raw_spinlock_t (an unsleepable lock),
> this poses an issue in PREEMPT_RT kernel where spinlock_t is sleepable.
>
> To address this,change type drvdata->spinlock in some coresight drivers,
> which can be called by perf_event_task_sched_out()/in(),
> from spinlock_t to raw_spinlock_t.
>
> Reviewed-by: James Clark <james.clark(a)linaro.org>
>
> v1 to v2:
> - seperate patchsets to change locktype and apply gurad API.
>
> Levi Yun (9):
> coresight: change coresight_device lock type to raw_spinlock_t
> coresight-etm4x: change etmv4_drvdata spinlock type to raw_spinlock_t
> coresight: change coresight_trace_id_map's lock type to raw_spinlock_t
> coresight-cti: change cti_drvdata spinlock's type to raw_spinlock_t
> coresight-etb10: change etb_drvdata spinlock's type to raw_spinlock_t
> coresight-funnel: change funnel_drvdata spinlock's type to
> raw_spinlock_t
> coresight-replicator: change replicator_drvdata spinlock's type to
> raw_spinlock_t
> coresight-tmc: change tmc_drvdata spinlock's type to raw_spinlock_t
> coresight/ultrasoc: change cti_drvdata spinlock's type to
> raw_spinlock_t
>
> .../hwtracing/coresight/coresight-config.c | 21 +-
> .../hwtracing/coresight/coresight-config.h | 2 +-
> drivers/hwtracing/coresight/coresight-core.c | 2 +-
> .../hwtracing/coresight/coresight-cti-core.c | 65 +-
> .../hwtracing/coresight/coresight-cti-sysfs.c | 135 +++--
> drivers/hwtracing/coresight/coresight-cti.h | 2 +-
> drivers/hwtracing/coresight/coresight-etb10.c | 62 +-
> .../coresight/coresight-etm4x-core.c | 71 ++-
> .../coresight/coresight-etm4x-sysfs.c | 566 +++++++++---------
> drivers/hwtracing/coresight/coresight-etm4x.h | 2 +-
> .../hwtracing/coresight/coresight-funnel.c | 34 +-
> .../coresight/coresight-replicator.c | 36 +-
> .../hwtracing/coresight/coresight-syscfg.c | 75 ++-
> .../hwtracing/coresight/coresight-tmc-core.c | 9 +-
> .../hwtracing/coresight/coresight-tmc-etf.c | 195 +++---
> .../hwtracing/coresight/coresight-tmc-etr.c | 199 +++---
> drivers/hwtracing/coresight/coresight-tmc.h | 2 +-
> .../hwtracing/coresight/coresight-trace-id.c | 93 ++-
> drivers/hwtracing/coresight/ultrasoc-smb.c | 12 +-
> drivers/hwtracing/coresight/ultrasoc-smb.h | 2 +-
> include/linux/coresight.h | 4 +-
> 21 files changed, 751 insertions(+), 838 deletions(-)
>
> --
> LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
>
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
On Wed, 18 Dec 2024 at 09:21, Krzysztof Kozlowski <krzk(a)kernel.org> wrote:
>
> On Tue, Dec 17, 2024 at 02:33:23PM +0800, Mao Jinlong wrote:
> > Current name of coresight component's folder consists of prefix of
> > the device and the id in the device list. When run 'ls' command,
> > we can get the register address of the device. Take CTI for example,
> > if we want to set the config for modem CTI, but we can't know which
> > CTI is modem CTI from all current information.
> >
> > cti_sys0 -> ../../../devices/platform/soc(a)0/138f0000.cti/cti_sys0
> > cti_sys1 -> ../../../devices/platform/soc(a)0/13900000.cti/cti_sys1
> >
> > Add label to show hardware context information of each coresight
> > device. There will be a sysfs node label in each device folder.
> >
> > cat /sys/bus/coresight/devices/cti_sys0/label
> >
> > Signed-off-by: Mao Jinlong <quic_jinlmao(a)quicinc.com>
>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski(a)linaro.org>
>
> Best regards,
> Krzysztof
>
Reviewed-by: Mike Leach <mike.leach(a)linaro.org>
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Previously the sink had to be specified, but now it auto selects one by
default. Including a sink in the examples causes issues when copy
pasting the command because it might not work if that sink isn't
present. Remove the sink from all the basic examples and create a new
section specifically about overriding the default one.
Make the text a but more concise now that it's in the advanced section,
and similarly for removing the old kernel advice.
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Documentation/trace/coresight/coresight.rst | 41 ++++++++-----------
.../userspace-api/perf_ring_buffer.rst | 4 +-
2 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/Documentation/trace/coresight/coresight.rst b/Documentation/trace/coresight/coresight.rst
index d4f93d6a2d63..806699871b80 100644
--- a/Documentation/trace/coresight/coresight.rst
+++ b/Documentation/trace/coresight/coresight.rst
@@ -462,44 +462,35 @@ queried by the perf command line tool:
cs_etm// [Kernel PMU event]
- linaro@linaro-nano:~$
-
Regardless of the number of tracers available in a system (usually equal to the
amount of processor cores), the "cs_etm" PMU will be listed only once.
A Coresight PMU works the same way as any other PMU, i.e the name of the PMU is
-listed along with configuration options within forward slashes '/'. Since a
-Coresight system will typically have more than one sink, the name of the sink to
-work with needs to be specified as an event option.
-On newer kernels the available sinks are listed in sysFS under
+provided along with configuration options within forward slashes '/' (see
+`Config option formats`_).
+
+Advanced Perf framework usage
+-----------------------------
+
+Sink selection
+~~~~~~~~~~~~~~
+
+An appropriate sink will be selected automatically for use with Perf, but since
+there will typically be more than one sink, the name of the sink to use may be
+specified as a special config option prefixed with '@'.
+
+The available sinks are listed in sysFS under
($SYSFS)/bus/event_source/devices/cs_etm/sinks/::
root@localhost:/sys/bus/event_source/devices/cs_etm/sinks# ls
tmc_etf0 tmc_etr0 tpiu0
-On older kernels, this may need to be found from the list of coresight devices,
-available under ($SYSFS)/bus/coresight/devices/::
-
- root:~# ls /sys/bus/coresight/devices/
- etm0 etm1 etm2 etm3 etm4 etm5 funnel0
- funnel1 funnel2 replicator0 stm0 tmc_etf0 tmc_etr0 tpiu0
root@linaro-nano:~# perf record -e cs_etm/@tmc_etr0/u --per-thread program
-As mentioned above in section "Device Naming scheme", the names of the devices could
-look different from what is used in the example above. One must use the device names
-as it appears under the sysFS.
-
-The syntax within the forward slashes '/' is important. The '@' character
-tells the parser that a sink is about to be specified and that this is the sink
-to use for the trace session.
-
More information on the above and other example on how to use Coresight with
the perf tools can be found in the "HOWTO.md" file of the openCSD gitHub
repository [#third]_.
-Advanced perf framework usage
------------------------------
-
AutoFDO analysis using the perf tools
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -508,7 +499,7 @@ perf can be used to record and analyze trace of programs.
Execution can be recorded using 'perf record' with the cs_etm event,
specifying the name of the sink to record to, e.g::
- perf record -e cs_etm/@tmc_etr0/u --per-thread
+ perf record -e cs_etm//u --per-thread
The 'perf report' and 'perf script' commands can be used to analyze execution,
synthesizing instruction and branch events from the instruction trace.
@@ -572,7 +563,7 @@ sort example is from the AutoFDO tutorial (https://gcc.gnu.org/wiki/AutoFDO/Tuto
Bubble sorting array of 30000 elements
5910 ms
- $ perf record -e cs_etm/@tmc_etr0/u --per-thread taskset -c 2 ./sort
+ $ perf record -e cs_etm//u --per-thread taskset -c 2 ./sort
Bubble sorting array of 30000 elements
12543 ms
[ perf record: Woken up 35 times to write data ]
diff --git a/Documentation/userspace-api/perf_ring_buffer.rst b/Documentation/userspace-api/perf_ring_buffer.rst
index bde9d8cbc106..dc71544532ce 100644
--- a/Documentation/userspace-api/perf_ring_buffer.rst
+++ b/Documentation/userspace-api/perf_ring_buffer.rst
@@ -627,7 +627,7 @@ regular ring buffer.
AUX events and AUX trace data are two different things. Let's see an
example::
- perf record -a -e cycles -e cs_etm/@tmc_etr0/ -- sleep 2
+ perf record -a -e cycles -e cs_etm// -- sleep 2
The above command enables two events: one is the event *cycles* from PMU
and another is the AUX event *cs_etm* from Arm CoreSight, both are saved
@@ -766,7 +766,7 @@ only record AUX trace data at a specific time point which users are
interested in. E.g. below gives an example of how to take snapshots
with 1 second interval with Arm CoreSight::
- perf record -e cs_etm/@tmc_etr0/u -S -a program &
+ perf record -e cs_etm//u -S -a program &
PERFPID=$!
while true; do
kill -USR2 $PERFPID
--
2.34.1