Hi Mike,
Since commit 9b6a3f3633a5cc9("coresight: etmv4: Fix CPU power management
setup in probe() function"),
ETM probe fails consistently like below:
localhost ~ # dmesg | grep -i etm
[ 6.460602] coresight-etm4x: probe of 7040000.etm failed with error
-16
[ 6.524756] coresight etm1: CPU1: ETM v4.2 initialized
[ 6.531152] coresight etm2: CPU2: ETM v4.2 initialized
[ 6.538495] coresight etm3: CPU3: ETM v4.2 initialized
[ 6.545124] coresight etm4: CPU4: ETM v4.2 initialized
[ 6.552904] coresight etm5: CPU5: ETM v4.2 initialized
[ 6.559714] coresight etm6: CPU6: ETM v4.2 initialized
[ 6.569596] coresight etm7: CPU7: ETM v4.2 initialized
localhost ~ #
Most of the time its for ETM0 but I occasionally see ETM1 and other ETMs
failing to probe,
but the some ETM probe failure is always there. I'm using SC7180 based
platform on 5.4 kernel
which has all the coresight patches backported.
If I revert that commit, I don't see the issue at all. In case you can
identify something which
might be causing this, please let me know. I'm planning to look into
this as well in the meantime.
Thanks,
Sai
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member
of Code Aurora Forum, hosted by The Linux Foundation
etm4_count keeps track of number of ETMv4 registered and on some
systems, a race is observed on etm4_count variable which can
lead to multiple calls to cpuhp_setup_state_nocalls_cpuslocked().
This function internally calls cpuhp_store_callbacks() which
prevents multiple registrations of callbacks for a given state
and due to this race, it returns -EBUSY leading to ETM probe
failures like below.
coresight-etm4x: probe of 7040000.etm failed with error -16
This race can easily be triggered with async probe by setting
probe type as PROBE_PREFER_ASYNCHRONOUS and with ETM power
management property "arm,coresight-loses-context-with-cpu".
Prevent this race by converting etm4_count variable to atomic.
Fixes: 9b6a3f3633a5 ("coresight: etmv4: Fix CPU power management setup in probe() function")
Fixes: 58eb457be028 ("hwtracing/coresight-etm4x: Convert to hotplug state machine")
Suggested-by: Mike Leach <mike.leach(a)linaro.org>
(Mike: Rootcause and context for commit message)
Signed-off-by: Sai Prakash Ranjan <saiprakash.ranjan(a)codeaurora.org>
---
drivers/hwtracing/coresight/coresight-etm4x.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index 6d7d2169bfb2..f256ea744c51 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -49,7 +49,7 @@ MODULE_PARM_DESC(pm_save_enable,
"Save/restore state on power down: 1 = never, 2 = self-hosted");
/* The number of ETMv4 currently registered */
-static int etm4_count;
+static atomic_t etm4_count;
static struct etmv4_drvdata *etmdrvdata[NR_CPUS];
static void etm4_set_default_config(struct etmv4_config *config);
static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
@@ -1403,7 +1403,7 @@ static int etm4_pm_setup_cpuslocked(void)
{
int ret;
- if (etm4_count++)
+ if (atomic_inc_return(&etm4_count))
return 0;
ret = cpu_pm_register_notifier(&etm4_cpu_pm_nb);
@@ -1434,13 +1434,13 @@ static int etm4_pm_setup_cpuslocked(void)
cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
reduce_count:
- --etm4_count;
+ atomic_dec(&etm4_count);
return ret;
}
static void etm4_pm_clear(void)
{
- if (--etm4_count != 0)
+ if (atomic_dec_return(&etm4_count) != 0)
return;
cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Allow to build coresight as modules. This gives developers the feasibility to
test their code without reboot.
This series is based on below two series.
- "coresight: allow to build components as modules"
https://lkml.org/lkml/2018/6/5/989
- "coresight: make drivers modular"
https://lkml.org/lkml/2020/1/17/468
Change from v4:
Fix error handling in coresight_grab_devicei() (Greg)
Add coresight: cti: Fix remove sysfs link error from Mike
-https://lists.linaro.org/pipermail/coresight/2020-July/004275.html
Move cti_remove_conn_xrefs() into cti_remove() (Mike)
Align patch subject to coresight: <component>: <description> (Mike)
Change from v3:
Rebase to coresight-next (Mike and Mathieu)
Reorder try_get_module() (Suzuki)
Clean up etmdrvdata[] in device remote path (Mike)
Move cti_remove_conn_xrefs to cti_remove (Mike)
Change from v2:
Rebase to 5.8-rc5. Export coresight_add_sysfs_link and
coresight_remove_sysfs_link
Fix one cut and paste error on MODULE_DESCRIPTION of CTI
Change from v1:
Use try_module_get() to avoid module to be unloaded when device is used
in active trace session. (Mathieu P)
Change from above two series.
This series adds the support to dynamically remove module when the device in
that module is enabled and used by some trace path. It disables all trace
paths with that device and release the trace path.
Kim Phillips (7):
coresight: use IS_ENABLED for CONFIGs that may be modules
coresight: etm3x: allow etm3x to be built as a module
coresight: etm4x: allow etm4x to be built as a module
coresight: etb: allow etb to be built as a module
coresight: tpiu: allow tpiu to be built as a module
coresight: tmc: allow tmc to be built as a module
coresight: allow funnel and replicator drivers to be built as modules
Mian Yousaf Kaukab (4):
coresight: export global symbols
coresight: funnel: remove multiple init calls from funnel driver
coresight: replicator: remove multiple init calls
coresight: tmc-etr: add function to register catu ops
Mike Leach (1):
coresight: cti: Fix remove sysfs link error
Tingwei Zhang (10):
coresight: cpu_debug: add module name in Kconfig
coresight: cpu_debug: define MODULE_DEVICE_TABLE
coresight: add coresight prefix to barrier_pkt
coresight: add try_get_module() in coresight_grab_device()
coresight: stm: allow to build coresight-stm as a module
coresight: etm: perf: Fix warning caused by etm_setup_aux failure
coresight: cti: add function to register cti associate ops
coresight: cti: allow cti to be built as a module
coresight: catu: allow catu drivers to be built as modules
coresight: allow the coresight core driver to be built as a module
drivers/hwtracing/coresight/Kconfig | 54 +++++++--
drivers/hwtracing/coresight/Makefile | 22 ++--
drivers/hwtracing/coresight/coresight-catu.c | 37 +++++-
drivers/hwtracing/coresight/coresight-catu.h | 2 -
.../{coresight.c => coresight-core.c} | 114 +++++++++++++++---
.../hwtracing/coresight/coresight-cpu-debug.c | 2 +
.../{coresight-cti.c => coresight-cti-core.c} | 60 +++++++--
drivers/hwtracing/coresight/coresight-etb10.c | 22 +++-
.../hwtracing/coresight/coresight-etm-perf.c | 13 +-
.../hwtracing/coresight/coresight-etm-perf.h | 5 +-
...resight-etm3x.c => coresight-etm3x-core.c} | 27 ++++-
...resight-etm4x.c => coresight-etm4x-core.c} | 26 +++-
.../hwtracing/coresight/coresight-funnel.c | 62 +++++++++-
.../hwtracing/coresight/coresight-platform.c | 1 +
drivers/hwtracing/coresight/coresight-priv.h | 24 ++--
.../coresight/coresight-replicator.c | 63 +++++++++-
drivers/hwtracing/coresight/coresight-stm.c | 20 ++-
drivers/hwtracing/coresight/coresight-sysfs.c | 2 +
.../{coresight-tmc.c => coresight-tmc-core.c} | 19 ++-
.../hwtracing/coresight/coresight-tmc-etf.c | 2 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 21 +++-
drivers/hwtracing/coresight/coresight-tmc.h | 3 +
drivers/hwtracing/coresight/coresight-tpiu.c | 19 ++-
include/linux/coresight.h | 2 +-
24 files changed, 539 insertions(+), 83 deletions(-)
rename drivers/hwtracing/coresight/{coresight.c => coresight-core.c} (94%)
rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (95%)
rename drivers/hwtracing/coresight/{coresight-etm3x.c => coresight-etm3x-core.c} (97%)
rename drivers/hwtracing/coresight/{coresight-etm4x.c => coresight-etm4x-core.c} (98%)
rename drivers/hwtracing/coresight/{coresight-tmc.c => coresight-tmc-core.c} (96%)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Allow to build coresight as modules. This gives developers the feasibility to
test their code without reboot.
This series is based on below two series.
- "coresight: allow to build components as modules"
https://lkml.org/lkml/2018/6/5/989
- "coresight: make drivers modular"
https://lkml.org/lkml/2020/1/17/468
Change from v2:
Rebase to 5.8-rc5. Export coresight_add_sysfs_link and
coresight_remove_sysfs_link
Fix one cut and paste error on MODULE_DESCRIPTION of CTI
Change from v1:
Use try_module_get() to avoid module to be unloaded when device is used
in active trace session. (Mathieu P)
Change from above two series.
This series adds the support to dynamically remove module when the device in
that module is enabled and used by some trace path. It disables all trace
paths with that device and release the trace path.
Kim Phillips (7):
coresight: use IS_ENABLED for CONFIGs that may be modules
coresight: allow etm3x to be built as a module
coresight: allow etm4x to be built as a module
coresight: allow etb to be built as a module
coresight: allow tpiu to be built as a module
coresight: allow tmc to be built as a module
coresight: allow funnel and replicator drivers to be built as modules
Mian Yousaf Kaukab (4):
coresight: export global symbols
coresight: remove multiple init calls from funnel driver
coresight: remove multiple init calls from replicator driver
coresight: tmc-etr: add function to register catu ops
Tingwei Zhang (9):
coresight: cpu_debug: add module name in Kconfig
coresight: cpu_debug: define MODULE_DEVICE_TABLE
coresight: add coresight prefix to barrier_pkt
Allow to build coresight-stm as a module, for ease of development.
coresight: cti: add function to register cti associate ops
coresight: allow cti to be built as a module
coresight: allow catu drivers to be built as modules
coresight: add try_get_module() in coresight_grab_device()
coresight: allow the coresight core driver to be built as a module
drivers/hwtracing/coresight/Kconfig | 54 ++++++++--
drivers/hwtracing/coresight/Makefile | 22 ++--
drivers/hwtracing/coresight/coresight-catu.c | 37 ++++++-
drivers/hwtracing/coresight/coresight-catu.h | 2 -
.../{coresight.c => coresight-core.c} | 102 ++++++++++++++----
.../hwtracing/coresight/coresight-cpu-debug.c | 2 +
.../{coresight-cti.c => coresight-cti-core.c} | 46 +++++++-
drivers/hwtracing/coresight/coresight-etb10.c | 22 +++-
.../hwtracing/coresight/coresight-etm-perf.c | 9 +-
.../hwtracing/coresight/coresight-etm-perf.h | 5 +-
...resight-etm3x.c => coresight-etm3x-core.c} | 27 ++++-
...resight-etm4x.c => coresight-etm4x-core.c} | 31 +++++-
.../hwtracing/coresight/coresight-funnel.c | 62 ++++++++++-
.../hwtracing/coresight/coresight-platform.c | 1 +
drivers/hwtracing/coresight/coresight-priv.h | 24 ++---
.../coresight/coresight-replicator.c | 63 ++++++++++-
drivers/hwtracing/coresight/coresight-stm.c | 20 +++-
drivers/hwtracing/coresight/coresight-sysfs.c | 2 +
.../{coresight-tmc.c => coresight-tmc-core.c} | 19 +++-
.../hwtracing/coresight/coresight-tmc-etf.c | 2 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 21 +++-
drivers/hwtracing/coresight/coresight-tmc.h | 3 +
drivers/hwtracing/coresight/coresight-tpiu.c | 19 +++-
include/linux/coresight.h | 2 +-
24 files changed, 521 insertions(+), 76 deletions(-)
rename drivers/hwtracing/coresight/{coresight.c => coresight-core.c} (94%)
rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (96%)
rename drivers/hwtracing/coresight/{coresight-etm3x.c => coresight-etm3x-core.c} (97%)
rename drivers/hwtracing/coresight/{coresight-etm4x.c => coresight-etm4x-core.c} (98%)
rename drivers/hwtracing/coresight/{coresight-tmc.c => coresight-tmc-core.c} (96%)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
This patch updates the documentation with a summary of
all necessary steps to be followed for performing afdo
optimization
Signed-off-by: Andrea Brunato <andrea.brunato(a)arm.com>
---
decoder/tests/auto-fdo/autofdo.md | 40 +++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/decoder/tests/auto-fdo/autofdo.md b/decoder/tests/auto-fdo/autofdo.md
index 69ed152..b28b645 100644
--- a/decoder/tests/auto-fdo/autofdo.md
+++ b/decoder/tests/auto-fdo/autofdo.md
@@ -433,10 +433,50 @@ sudo ./set_strobing.sh 5000 10000
perf record -e cs_etm/@tmc_etr0/u --per-thread -- <your app>"
perf inject -i perf.data -o inj.data --itrace=i100000il
create_llvm_prof -binary=/path/to/binary -profile=inj.data -out=program.llvmprof
+clang -O2 -fprofile-sample-use=program.llvmprof -o program program.c
```
Use `create_gcov` for gcc.
+## High Level Summary for recoding on Arm board and decoding on different host
+
+1. (on Arm board)
+
+ sudo ./set_strobing.sh 5000 10000
+ perf record -e cs_etm/@tmc_etr0/u --per-thread -- <your app>.
+ If you specify `-N, --no-buildid-cache`, perf will just take care of recording the target binary and nothing will be copied.<br> If you don't specify it, any recorded dynamic library will be copied to ~/.debug in the board.
+
+2. (on Arm board) `perf archive` which saves all the found libraries in a tar (internally, it looks into perf.data file and performs a lookup using perf-buildid-list --with-hits)
+3. (on host) `scp` to copy perf.data and the .tar file generated from `perf archive`.
+4. (on host) Run `tar xvf perf_data.tar.bz2 -C ~/.debug` to populate the buildid-cache
+5. (on host) Double check the setup is correct:
+
+ a. `perf buildid-list -i perf.data` gives you the list of dynamic libraries buildids whose trace has been recorded and saved in perf.data.
+ b. `perf buildid-cache --list` lists the dynamic libraries in the buildid cache that will be used by `perf inject`.
+ Make sure the output of (a) and (b) overlaps as in buildid value for those binaries you are interested into optimizing with afdo.
+
+6. (on host) `perf inject -i perf.data -o inj.data --itrace=i100000il` will check for the dynamic libraries using the buildid inside the buildid-cache and post-process the trace.<br> buildids have to be the same, otherwise it won't be possible to post-process the trace.
+
+7. (on host) `create_llvm_prof -binary=/path/to/binary -profile=inj.data -out=program.llvmprof` takes the output from perf-inject and tranforms it into a format that the compiler can read.
+8. (on host) `clang -O2 -fprofile-sample-use=program.llvmprof -o program program.c` to make clang use the produced profile.<br>
+ If you are confident enough that your profile is accurate, you can add the `-fprofile-sample-accurate` flag, which will penalize all the callsites without corresponding profile, marking them as cold.
+
+If you are using the same host for both building the binary to be traced and re-building it with afdo:
+
+1. You won't need to copy back any dynamic libraries from the board (since you already have them), and can use `--no-buildid-cache` when recording
+2. You have to make sure the relevant dynamic libraries to be optimized are present in the buildid-cache.
+
+You can easily add a dynamic library manually into the build-id cache by running:
+
+`perf buildid-cache --add <path/to/library/or/binary> -vvv`
+
+You can easily check what is currently contained in you buildid-cache by running:
+
+`perf buildid-cache --list`
+
+You can check the buildid of a given binary/dynamic library:
+
+`file <path/to/dynamic/library>`
## References
--
2.17.1
Allow to build coresight as modules. This gives developers the feasibility to
test their code without reboot.
This series is based on below two series.
- "coresight: allow to build components as modules"
https://lkml.org/lkml/2018/6/5/989
- "coresight: make drivers modular"
https://lkml.org/lkml/2020/1/17/468
Change from v1:
Use try_module_get() to avoid module to be unloaded when device is used
in active trace session. (Mathieu P)
Change from above two series.
This series adds the support to dynamically remove module when the device in
that module is enabled and used by some trace path. It disables all trace
paths with that device and release the trace path.
Kim Phillips (7):
coresight: use IS_ENABLED for CONFIGs that may be modules
coresight: allow etm3x to be built as a module
coresight: allow etm4x to be built as a module
coresight: allow etb to be built as a module
coresight: allow tpiu to be built as a module
coresight: allow tmc to be built as a module
coresight: allow funnel and replicator drivers to be built as modules
Mian Yousaf Kaukab (4):
coresight: export global symbols
coresight: remove multiple init calls from funnel driver
coresight: remove multiple init calls from replicator driver
coresight: tmc-etr: add function to register catu ops
Tingwei Zhang (9):
coresight: cpu_debug: add module name in Kconfig
coresight: cpu_debug: define MODULE_DEVICE_TABLE
coresight: add coresight prefix to barrier_pkt
Allow to build coresight-stm as a module, for ease of development.
coresight: cti: add function to register cti associate ops
coresight: allow cti to be built as a module
coresight: allow catu drivers to be built as modules
coresight: add try_get_module() in coresight_grab_device()
coresight: allow the coresight core driver to be built as a module
drivers/hwtracing/coresight/Kconfig | 54 ++++++++--
drivers/hwtracing/coresight/Makefile | 20 ++--
drivers/hwtracing/coresight/coresight-catu.c | 37 ++++++-
drivers/hwtracing/coresight/coresight-catu.h | 2 -
.../{coresight.c => coresight-core.c} | 101 +++++++++++++++---
.../hwtracing/coresight/coresight-cpu-debug.c | 2 +
.../{coresight-cti.c => coresight-cti-core.c} | 46 +++++++-
drivers/hwtracing/coresight/coresight-etb10.c | 22 +++-
.../hwtracing/coresight/coresight-etm-perf.c | 9 +-
.../hwtracing/coresight/coresight-etm-perf.h | 5 +-
...resight-etm3x.c => coresight-etm3x-core.c} | 27 ++++-
...resight-etm4x.c => coresight-etm4x-core.c} | 31 +++++-
.../hwtracing/coresight/coresight-funnel.c | 62 ++++++++++-
.../hwtracing/coresight/coresight-platform.c | 1 +
drivers/hwtracing/coresight/coresight-priv.h | 24 ++---
.../coresight/coresight-replicator.c | 63 ++++++++++-
drivers/hwtracing/coresight/coresight-stm.c | 20 +++-
.../{coresight-tmc.c => coresight-tmc-core.c} | 19 +++-
.../hwtracing/coresight/coresight-tmc-etf.c | 2 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 21 +++-
drivers/hwtracing/coresight/coresight-tmc.h | 3 +
drivers/hwtracing/coresight/coresight-tpiu.c | 19 +++-
include/linux/coresight.h | 2 +-
23 files changed, 518 insertions(+), 74 deletions(-)
rename drivers/hwtracing/coresight/{coresight.c => coresight-core.c} (94%)
rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (95%)
rename drivers/hwtracing/coresight/{coresight-etm3x.c => coresight-etm3x-core.c} (97%)
rename drivers/hwtracing/coresight/{coresight-etm4x.c => coresight-etm4x-core.c} (98%)
rename drivers/hwtracing/coresight/{coresight-tmc.c => coresight-tmc-core.c} (96%)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Hi,
While running perf on some function-heavy code I noticed the ETM return stack
isn't enabled (TRCCONFIGR bit 9). I know that it can easily be enabled with retstack=1,
but have we considered making this the default as we move to simplification of
perf options? It could lead to more efficient profiles and shouldn't be any more
difficult to decode than ETM normally is.
Al