The current method for allocating trace source ID values to sources is
to use a fixed algorithm for CPU based sources of (cpu_num * 2 + 0x10).
The STM is allocated ID 0x1.
This fixed algorithm is used in both the CoreSight driver code, and by
perf when writing the trace metadata in the AUXTRACE_INFO record.
The method needs replacing as currently:-
1. It is inefficient in using available IDs.
2. Does not scale to larger systems with many cores and the algorithm
has no limits so will generate invalid trace IDs for cpu number > 44.
Additionally requirements to allocate additional system IDs on some
systems have been seen.
This patch set introduces an API that allows the allocation of trace IDs
in a dynamic manner.
Architecturally reserved IDs are never allocated, and the system is
limited to allocating only valid IDs.
Each of the current trace sources ETM3.x, ETM4.x and STM is updated to use
the new API.
For the ETMx.x devices IDs are allocated on certain events
a) When using sysfs, an ID will be allocated on hardware enable, or a read of
sysfs TRCTRACEID register and freed when the sysfs reset is written.
b) When using perf, ID is allocated on during setup AUX event, and freed on
event free. IDs are communicated using the AUX_OUTPUT_HW_ID packet.
The ID allocator is notified when perf sessions start and stop
so CPU based IDs are kept constant throughout any perf session.
Note: This patchset breaks some backward compatibility for perf record and
perf report.
The version of the AUXTRACE_INFO has been updated to reflect the fact that
the trace source IDs are generated differently. This will
mean older versions of perf report cannot decode the newer file.
Applies to coresight/next [4d45bc82df66]
Tested on DB410c
Changes since v2:
1) Improved backward compatibility: (requested by James)
Using the new version of perf on an old kernel will generate a usable file
legacy metadata values are set by the new perf and will be used if mew
ID packets are not present in the file.
Using an older version of perf / simpleperf on an updated kernel may still
work. The trace ID allocator has been updated to use the legacy ID values
where possible, so generated file and used trace IDs will match up to the
point where the legacy algorithm is broken anyway.
2) Various changes to the ID allocator and ID packet format.
(suggested by Suzuki)
3) per CPU ID info in allocator now stored as atomic type to allow a passive read
without taking the allocator spinlock. perf flow now allocates and releases ID
values in setup_aux / free_event. Device enable and event enable use the passive
read to set the allocated values. This simplifies the locking mechanisms on the
perf run and fixes issues that arose with locking dependencies.
Changes since v1:
(after feedback & discussion with Mathieu & Suzuki).
1) API has changed. The global trace ID map is managed internally, so it
is no longer passed in to the API functions.
2) perf record does not use sysfs to find the trace IDs. These are now
output as AUX_OUTPUT_HW_ID events. The drivers, perf record, and perf report
have been updated accordingly to generate and handle these events.
Mike Leach (13):
coresight: trace-id: Add API to dynamically assign Trace ID values
coresight: Remove obsolete Trace ID unniqueness checks
coresight: stm: Update STM driver to use Trace ID API
coresight: etm4x: Update ETM4 driver to use Trace ID API
coresight: etm3x: Update ETM3 driver to use Trace ID API
coresight: etmX.X: stm: Remove trace_id() callback
coresight: perf: traceid: Add perf notifiers for Trace ID
perf: cs-etm: Move mapping of Trace ID and cpu into helper function
perf: cs-etm: Update record event to use new Trace ID protocol
kernel: events: Export perf_report_aux_output_id()
perf: cs-etm: Handle PERF_RECORD_AUX_OUTPUT_HW_ID packet
coresight: events: PERF_RECORD_AUX_OUTPUT_HW_ID used for Trace ID
coresight: trace-id: Add debug & test macros to Trace ID allocation
drivers/hwtracing/coresight/Makefile | 2 +-
drivers/hwtracing/coresight/coresight-core.c | 49 +--
.../hwtracing/coresight/coresight-etm-perf.c | 23 ++
drivers/hwtracing/coresight/coresight-etm.h | 3 +-
.../coresight/coresight-etm3x-core.c | 92 +++--
.../coresight/coresight-etm3x-sysfs.c | 27 +-
.../coresight/coresight-etm4x-core.c | 79 ++++-
.../coresight/coresight-etm4x-sysfs.c | 27 +-
drivers/hwtracing/coresight/coresight-etm4x.h | 3 +
drivers/hwtracing/coresight/coresight-stm.c | 49 +--
.../hwtracing/coresight/coresight-trace-id.c | 266 ++++++++++++++
.../hwtracing/coresight/coresight-trace-id.h | 78 +++++
include/linux/coresight-pmu.h | 35 +-
include/linux/coresight.h | 3 -
kernel/events/core.c | 1 +
tools/include/linux/coresight-pmu.h | 48 ++-
tools/perf/arch/arm/util/cs-etm.c | 21 +-
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 7 +
tools/perf/util/cs-etm.c | 331 +++++++++++++++---
tools/perf/util/cs-etm.h | 14 +-
20 files changed, 933 insertions(+), 225 deletions(-)
create mode 100644 drivers/hwtracing/coresight/coresight-trace-id.c
create mode 100644 drivers/hwtracing/coresight/coresight-trace-id.h
--
2.17.1
The current method for allocating trace source ID values to sources is
to use a fixed algorithm for CPU based sources of (cpu_num * 2 + 0x10).
The STM is allocated ID 0x1.
This fixed algorithm is used in both the CoreSight driver code, and by
perf when writing the trace metadata in the AUXTRACE_INFO record.
The method needs replacing as currently:-
1. It is inefficient in using available IDs.
2. Does not scale to larger systems with many cores and the algorithm
has no limits so will generate invalid trace IDs for cpu number > 44.
Additionally requirements to allocate additional system IDs on some
systems have been seen.
This patch set introduces an API that allows the allocation of trace IDs
in a dynamic manner.
Architecturally reserved IDs are never allocated, and the system is
limited to allocating only valid IDs.
Each of the current trace sources ETM3.x, ETM4.x and STM is updated to use
the new API.
For the ETMx.x devices IDs are allocated on certain events
a) When using sysfs, an ID will be allocated on hardware enable, or a read of
sysfs TRCTRACEID register and freed when the sysfs reset is written.
b) When using perf, ID is allocated on during setup AUX event, and freed on
event free. IDs are communicated using the AUX_OUTPUT_HW_ID packet.
The ID allocator is notified when perf sessions start and stop
so CPU based IDs are kept constant throughout any perf session.
Note: This patchset breaks some backward compatibility for perf record and
perf report.
The version of the AUXTRACE_INFO has been updated to reflect the fact that
the trace source IDs are generated differently. This will
mean older versions of perf report cannot decode the newer file.
Applies to coresight/next [4d45bc82df66]
Tested on DB410c
Changes since v3:
1) Fixed aarch32 build error in ETM3.x driver.
Reported-by: kernel test robot <lkp(a)intel.com>
Changes since v2:
1) Improved backward compatibility: (requested by James)
Using the new version of perf on an old kernel will generate a usable file
legacy metadata values are set by the new perf and will be used if mew
ID packets are not present in the file.
Using an older version of perf / simpleperf on an updated kernel may still
work. The trace ID allocator has been updated to use the legacy ID values
where possible, so generated file and used trace IDs will match up to the
point where the legacy algorithm is broken anyway.
2) Various changes to the ID allocator and ID packet format.
(suggested by Suzuki)
3) per CPU ID info in allocator now stored as atomic type to allow a passive read
without taking the allocator spinlock. perf flow now allocates and releases ID
values in setup_aux / free_event. Device enable and event enable use the passive
read to set the allocated values. This simplifies the locking mechanisms on the
perf run and fixes issues that arose with locking dependencies.
Changes since v1:
(after feedback & discussion with Mathieu & Suzuki).
1) API has changed. The global trace ID map is managed internally, so it
is no longer passed in to the API functions.
2) perf record does not use sysfs to find the trace IDs. These are now
output as AUX_OUTPUT_HW_ID events. The drivers, perf record, and perf report
have been updated accordingly to generate and handle these events.
Mike Leach (13):
coresight: trace-id: Add API to dynamically assign Trace ID values
coresight: Remove obsolete Trace ID unniqueness checks
coresight: stm: Update STM driver to use Trace ID API
coresight: etm4x: Update ETM4 driver to use Trace ID API
coresight: etm3x: Update ETM3 driver to use Trace ID API
coresight: etmX.X: stm: Remove trace_id() callback
coresight: perf: traceid: Add perf notifiers for Trace ID
perf: cs-etm: Move mapping of Trace ID and cpu into helper function
perf: cs-etm: Update record event to use new Trace ID protocol
kernel: events: Export perf_report_aux_output_id()
perf: cs-etm: Handle PERF_RECORD_AUX_OUTPUT_HW_ID packet
coresight: events: PERF_RECORD_AUX_OUTPUT_HW_ID used for Trace ID
coresight: trace-id: Add debug & test macros to Trace ID allocation
drivers/hwtracing/coresight/Makefile | 2 +-
drivers/hwtracing/coresight/coresight-core.c | 49 +--
.../hwtracing/coresight/coresight-etm-perf.c | 23 ++
drivers/hwtracing/coresight/coresight-etm.h | 3 +-
.../coresight/coresight-etm3x-core.c | 92 +++--
.../coresight/coresight-etm3x-sysfs.c | 27 +-
.../coresight/coresight-etm4x-core.c | 79 ++++-
.../coresight/coresight-etm4x-sysfs.c | 27 +-
drivers/hwtracing/coresight/coresight-etm4x.h | 3 +
drivers/hwtracing/coresight/coresight-stm.c | 49 +--
.../hwtracing/coresight/coresight-trace-id.c | 266 ++++++++++++++
.../hwtracing/coresight/coresight-trace-id.h | 78 +++++
include/linux/coresight-pmu.h | 35 +-
include/linux/coresight.h | 3 -
kernel/events/core.c | 1 +
tools/include/linux/coresight-pmu.h | 48 ++-
tools/perf/arch/arm/util/cs-etm.c | 21 +-
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 7 +
tools/perf/util/cs-etm.c | 331 +++++++++++++++---
tools/perf/util/cs-etm.h | 14 +-
20 files changed, 933 insertions(+), 225 deletions(-)
create mode 100644 drivers/hwtracing/coresight/coresight-trace-id.c
create mode 100644 drivers/hwtracing/coresight/coresight-trace-id.h
--
2.17.1
Add support for UltraSoc System Memory Buffer.
Change since v8:
- Insert a blank line at the end of the config tag in Kconfig.
- Fix the "llseek" initialization.
- Link: https://lore.kernel.org/linux-arm-kernel/20220816131634.38195-1-hejunhao3@h…
Change since v7:
- Use the macros for register bit flags and numbers of resource.
- Fix punctuation.
- Update the Date tag and the KernelVersion tag in the document.
- Link: https://lore.kernel.org/lkml/20220712091353.34540-1-hejunhao3@huawei.com/
Change since v6:
- Modify the code style and driver description according to Suzuki's comment.
- Modify configuration of "drvdata->reading", to void problems in open/read
concurrency scenario.
- Rename the macro of "SMB_FLOW_MASK".
- Use the "handle->head" to determine the page number and offset.
- Link: https://lore.kernel.org/linux-arm-kernel/20220606130223.57354-1-liuqi115@hu…
Change since v5:
- Address the comments from Suzuki, add some comments in SMB document, and modify
configuration of "drvdata->reading", to void problems in multi-core concurrency scenario
- Link: https://lore.kernel.org/linux-arm-kernel/20220416083953.52610-1-liuqi115@hu…
Change since v4:
- Add a simple document of SMB driver according to Suzuki's comment.
- Address the comments from Suzuki.
- Link: https://lore.kernel.org/linux-arm-kernel/20220128061755.31909-1-liuqi115@hu…
Change since v3:
- Modify the file header according to community specifications.
- Address the comments from Mathieu.
- Link: https://lore.kernel.org/linux-arm-kernel/20211118110016.40398-1-liuqi115@hu…
Change since v2:
- Move ultrasoc driver to drivers/hwtracing/coresight.
- Link: https://lists.linaro.org/pipermail/coresight/2021-November/007310.html
Change since v1:
- Drop the document of UltraSoc according to Mathieu's comment.
- Add comments to explain some private hardware settings.
- Address the comments from Mathieu.
- Link: https://lists.linaro.org/pipermail/coresight/2021-August/006842.html
Change since RFC:
- Move driver to drivers/hwtracing/coresight/ultrasoc.
- Remove ultrasoc-axi-com.c, as AXI-COM doesn't need to be configured in
basic tracing function.
- Remove ultrasoc.c as SMB does not need to register with the ultrasoc core.
- Address the comments from Mathieu and Suzuki.
- Link: https://lists.linaro.org/pipermail/coresight/2021-June/006535.html
Qi Liu (2):
drivers/coresight: Add UltraSoc System Memory Buffer driver
Documentation: Add document for UltraSoc SMB drivers
.../sysfs-bus-coresight-devices-ultra_smb | 31 +
.../trace/coresight/ultrasoc-smb.rst | 80 +++
drivers/hwtracing/coresight/Kconfig | 11 +
drivers/hwtracing/coresight/Makefile | 1 +
drivers/hwtracing/coresight/ultrasoc-smb.c | 636 ++++++++++++++++++
drivers/hwtracing/coresight/ultrasoc-smb.h | 115 ++++
6 files changed, 874 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-bus-coresight-devices-ultra_smb
create mode 100644 Documentation/trace/coresight/ultrasoc-smb.rst
create mode 100644 drivers/hwtracing/coresight/ultrasoc-smb.c
create mode 100644 drivers/hwtracing/coresight/ultrasoc-smb.h
--
2.33.0
Hi Christoph
On Thu, 11 Aug 2022 at 16:09, Christoph Hellwig <hch(a)lst.de> wrote:
>
> On Fri, Aug 05, 2022 at 03:15:53PM +0100, Mike Leach wrote:
> > You are correct - in this patchset we are adding the use of a binary
> > attribute to load and unload Coresight configurations and features -
> > which action has a side effect of adding and removing entries in
> > particular sub-directories in our configfs sub-system.
>
> I don't think configfs was designed to be that dynamic. Especially
> the fact that a write to a binary attribute, which is intended to
> be just for passthrough to hardware is a bit concerning.
>
configfs may not have originally been intended to be used in quite
this way, but the system is robust and well designed, and the APIs
work perfectly well in the this way.
The model of user programming a configuration item for kernel backed
elements that have a userspace lifetime (as described in configfs.rst)
is precisely the model we need to successfully leverage the coresight
subsystem. Our requirements are more complex than the ACPI tables or
USB gadget drivers that use configfs, as we are potentially
configuring multiple coresight devices. What the user sees in the
configfs directories for the configurations are only the user
adjustable features of these configurations. The rest of the
programming is set on the relevant devices.
> From your further description it sounds like this binary attribute
> is loading structured data interpreted by the kernel, which really
> isn't how binary attributes in configfs or sysfs are intended to
> be used.
If you look at the ACPI configfs, then this is in fact loading an ACPI
table structure into the kernel, through a binary attribute, that is
validated and added to a list of tables, if it passes the validation.
This is also an example of using a binary attribute to pass structured
data into the kernel for subsequent interpretation - and this example
is why I chose to use binary attributes in this way.
The data passed through the coresight 'load' binary attribute is
validated, and then only if valid loaded into the coresight subsystem
for use when coresight trace is activated and the user decides to use
the configuration. (coresight configurations are loaded, but are only
used if specifically selected during a trace session).
Regards
Mike
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Changes since v1:
* Keep existing signed offset value types until the very last commit
and then remove them all at once
* Also split out usages of read_pair() and read32() into separate
functions in the last commit
* Whitespace fixes
* Replaced any touched scnprintf() with sysfs_emit()
======
The intent of this change is to reduce the large number identical of
functions created by macros for sysfs accessors. It's possible to re-use
the same function but pass in the register to access as an argument.
This reduces the size of the coresight modules folder by 244KB.
The first two patches are refactors to simplify and remove some dead
code, and the second two are the changes to use a shared function.
Testing
=======
No changes in any of the outputs:
cat /sys/bus/coresight/devices/*/mgmt/* > before.txt
cat /sys/bus/coresight/devices/*/mgmt/* > after.txt
diff before.txt after.txt
With the following modules loaded:
ls /sys/bus/coresight/devices/
etm0 etm2 funnel0 funnel2 replicator0 tmc_etf0 tmc_etf2 tpiu0
etm1 etm3 funnel1 funnel3 stm0 tmc_etf1 tmc_etr0
James Clark (5):
coresight: Remove unused function parameter
coresight: Simplify sysfs accessors by using csdev_access abstraction
coresight: Re-use same function for similar sysfs register accessors
coresight: cti-sysfs: Re-use same functions for similar sysfs register
accessors
coresight: Make new csdev_access offsets unsigned
drivers/hwtracing/coresight/coresight-catu.c | 27 +--
drivers/hwtracing/coresight/coresight-catu.h | 8 +-
drivers/hwtracing/coresight/coresight-core.c | 28 +++
.../hwtracing/coresight/coresight-cti-sysfs.c | 213 +++++++-----------
drivers/hwtracing/coresight/coresight-etb10.c | 28 +--
.../coresight/coresight-etm3x-sysfs.c | 34 +--
drivers/hwtracing/coresight/coresight-priv.h | 74 +++---
.../coresight/coresight-replicator.c | 10 +-
drivers/hwtracing/coresight/coresight-stm.c | 40 +---
.../hwtracing/coresight/coresight-tmc-core.c | 48 ++--
drivers/hwtracing/coresight/coresight-tmc.h | 4 +-
include/linux/coresight.h | 23 ++
12 files changed, 227 insertions(+), 310 deletions(-)
--
2.28.0
On 26/08/2022 20:55, Mathieu Poirier wrote:
> On Tue, Aug 23, 2022 at 05:06:48PM +0100, James Clark wrote:
>> I've taken over this one from German because he's moved to a different
>> team. I gave it a quick check and bumped the version number in the docs
>> for the next release, but the month is an estimate.
>>
>> Thanks
>>
>> Changes since v2:
>>
>> * Rebased onto coresight/next (b99ee26a1a)
>> * Bumped release version to 6.1
>
> I have applied this set. Usually I'd let Suzuki handle it since he is already
> familiar with the work but 1) he is currently away and 2) the patchset is fairly
> simple.
Thanks Mathieu
>
> Thanks,
> Mathieu
>
>>
>> Changes since v1:
>>
>> * Inline etmv4_to_ts_source() function.
>> * Collect review tag from Leo.
>>
>> German Gomez (2):
>> coresight: etm4x: Expose default timestamp source in sysfs
>> coresight: etm4x: docs: Add documentation for 'ts_source' sysfs
>> interface
>>
>> .../testing/sysfs-bus-coresight-devices-etm4x | 8 +++++
>> .../coresight/coresight-etm4x-reference.rst | 14 +++++++++
>> arch/arm64/include/asm/sysreg.h | 1 +
>> .../coresight/coresight-etm4x-sysfs.c | 29 +++++++++++++++++++
>> 4 files changed, 52 insertions(+)
>>
>> --
>> 2.28.0
>>
On 24/08/2022 03:54, Bagas Sanjaya wrote:
> On 8/23/22 23:06, James Clark wrote:
>> +:Example:
>> + ``$> cat ts_source``
>> +
>> + ``$> 1``
>> +
>
> Shouldn't literal code block be used instead for example snippet
> above?
>
It's consistent with the rest of the file. I think consistency for
something like this is more important than accuracy otherwise the new
entry would appear out of place.
Maybe they should all be changed to a different style, but that would be
a separate change unrelated to this set.
James
I've taken over this one from German because he's moved to a different
team. I gave it a quick check and bumped the version number in the docs
for the next release, but the month is an estimate.
Thanks
Changes since v2:
* Rebased onto coresight/next (b99ee26a1a)
* Bumped release version to 6.1
Changes since v1:
* Inline etmv4_to_ts_source() function.
* Collect review tag from Leo.
German Gomez (2):
coresight: etm4x: Expose default timestamp source in sysfs
coresight: etm4x: docs: Add documentation for 'ts_source' sysfs
interface
.../testing/sysfs-bus-coresight-devices-etm4x | 8 +++++
.../coresight/coresight-etm4x-reference.rst | 14 +++++++++
arch/arm64/include/asm/sysreg.h | 1 +
.../coresight/coresight-etm4x-sysfs.c | 29 +++++++++++++++++++
4 files changed, 52 insertions(+)
--
2.28.0