HI : I am currently using coresight ETM features on Android to try and improve performance. I compiled perf on aarch64 host and pushed it to android. The version of perf and linux kernel are the same.
1. Information about the device SM8450 + Android 12 Linux localhost 5.10.66-qki-consolidate-g14f56d7c5ad6 #1 SMP PREEMPT Tue May 10 11:18:19 UTC 2022 aarch64
2. I ran into some trouble 1) perf encountered syntax error when executing the command. 2) Unable to decode
3. The whole process of my test execution (1) PS C:\Users\wzs>adb push perf /data/local/tmp
(2) PS C:\Users\wzs>adb shell chmod 0777 /data/local/tmp/perf
(3) PS C:\Users\wzs>adb shell
#ls /sys/bus/event_source/devices/cs_etm/sinks/ coresight-eud coresight-tmc-etf coresight-tmc-etr coresight-tmc-etr1
(4) #cd /data/local/tmp/perf #HOME=/data/local/tmp #./perf --buildid-dir /data/local/tmp/.debug record -e cs_etm/@coresight-tmc-etr/u --filter 'filter 0x15f0/0x40@/system/lib64/libcstest.so' --per-thread ./main event syntax error: 'cs_etm/@coresight-tmc-etr/u' ___ parser error Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>] or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
There is a syntax error here, I think it is because the perf parser thinks that the symbol "-" in the string "coresight-tmc-etr" is illegal. But I don't know how to fix it, so I did the following. Use tmc_etr, but replace it with coresight-tmc-etr in the code.
--- a/tools/perf/util/parse-events2.c +++ b/tools/perf/util/parse-events.c @@ -2916,6 +2916,8 @@ int parse_events__is_hardcoded_term(struct parse_events_term *term) return term->type_term != PARSE_EVENTS__TERM_TYPE_USER; }
+char *cs_str;//"coresight-tmc-etr" + static int new_term(struct parse_events_term **_term, struct parse_events_term *temp, char *str, u64 num) @@ -2925,6 +2927,12 @@ static int new_term(struct parse_events_term **_term, term = malloc(sizeof(*term)); if (!term) return -ENOMEM; + if (str && !strcmp(str, "tmc_etr")) { + cs_str = (char*)malloc(30); + strcpy(cs_str, "coresight-tmc-etr"); + str = cs_str; + } *term = *temp; INIT_LIST_HEAD(&term->list); term->weak = false;
Will continue.
(5) #./perf --buildid-dir /data/local/tmp/.debug record -e cs_etm/@tmc_etr/u --per-thread ./main val: 20 [ perf record: Woken up 1 times to write data ] BFD: /apex/com.android.runtime/bin/linker64: unknown type [0x13] section `.relr.dyn' BFD: /apex/com.android.runtime/lib64/bionic/libm.so: unknown type [0x13] section `.relr.dyn' BFD: /system/lib64/libutils.so: unknown type [0x13] section `.relr.dyn' BFD: /system/lib64/libnetd_client.so: unknown type [0x13] section `.relr.dyn' BFD: /system/lib64/libcgrouprc.so: unknown type [0x13] section `.relr.dyn' BFD: /system/lib64/libvndksupport.so: unknown type [0x13] section `.relr.dyn' BFD: /system/lib64/liblog.so: unknown type [0x13] section `.relr.dyn' BFD: /system/lib64/libc++.so: unknown type [0x13] section `.relr.dyn' [ perf record: Captured and wrote 1.316 MB perf.data ]
(6) # ls -al total 1861311 drwxrwx--x 3 shell shell 8192 2022-01-05 05:37 . drwxr-x--x 5 root root 3452 2022-01-04 05:56 .. drwxr-xr-x 418 root root 24576 2022-01-05 04:31 .debug -rw-rw-rw- 1 root root 1859414850 2022-01-05 04:36 cs_example.tgz -rwxrwxrwx 1 root root 42944200 2022-05-14 16:15 perf -rw------- 1 root root 1425940 2022-01-05 05:37 perf.data
(7) #./perf report --stdio # To display the perf.data header info, please use --header/--header-only options. # Error: The perf.data data has no samples!
An exception has been shown here, no data was sampled.
(8) #tar czf cs_example.tgz perf.data ~/.debug
It will then be decoded on my host via OpenCSD.
(9) wzs@ubuntu:~/perf/windows_path/test-cs/cs-decode$ cat disasm.sh EXEC_PATH=/home/wzs/perf/sm8450_kernel_src/tools/perf/ SCRIPT_PATH=/home/wzs/perf/sm8450_kernel_src/tools/perf/scripts/python/ XTOOLS_PATH=/home/wzs/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objdump ./perf --exec-path=${EXEC_PATH} script --script=python:${SCRIPT_PATH}/arm-cs-trace-disasm.py -- -d $XTOOLS_PATH -k ./vmlinux -v
(10) wzs@ubuntu:~/perf/windows_path/test-cs/cs-decode$ ./disasm.sh ARM CoreSight Trace Data Assembler Dump parse_mmap = { pid: 19130 dso: /data/local/tmp/main start: 0x5f8d029000 end: 0x5f8d02a000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/bin/linker64 start: 0x7eaafab000 end: 0x7eab096000} parse_mmap = { pid: 19130 dso: [vdso] start: 0x7eaaf72000 end: 0x7eaaf73000} parse_mmap = { pid: 19130 dso: /system/lib64/libcstest.so start: 0x7ea9c62000 end: 0x7ea9c63000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/lib64/bionic/libc.so start: 0x7ea6f70000 end: 0x7ea702d000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/lib64/bionic/libc.so start: 0x7ea6f70000 end: 0x7ea702d000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/lib64/bionic/libdl.so start: 0x7ea9c0e000 end: 0x7ea9c0f000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/lib64/bionic/libdl.so start: 0x7ea9c0e000 end: 0x7ea9c0f000} parse_mmap = { pid: 19130 dso: /system/lib64/libc++.so start: 0x7ea9a8a000 end: 0x7ea9ae7000} parse_mmap = { pid: 19130 dso: /system/lib64/libc++.so start: 0x7ea9a8a000 end: 0x7ea9ae7000} parse_mmap = { pid: 19130 dso: /system/lib64/libcutils.so start: 0x7ea6ef0000 end: 0x7ea6ef8000} parse_mmap = { pid: 19130 dso: /system/lib64/libcutils.so start: 0x7ea6ef0000 end: 0x7ea6ef8000} parse_mmap = { pid: 19130 dso: /system/lib64/libcgrouprc.so start: 0x7ea6e8f000 end: 0x7ea6e90000} parse_mmap = { pid: 19130 dso: /system/lib64/libcgrouprc.so start: 0x7ea6e8f000 end: 0x7ea6e90000} parse_mmap = { pid: 19130 dso: /system/lib64/libprocessgroup.so start: 0x7c96da5000 end: 0x7c96dd8000} parse_mmap = { pid: 19130 dso: /system/lib64/libprocessgroup.so start: 0x7c96da5000 end: 0x7c96dd8000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/lib64/bionic/libm.so start: 0x7ea6e52000 end: 0x7ea6e75000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/lib64/bionic/libm.so start: 0x7ea6e52000 end: 0x7ea6e75000} parse_mmap = { pid: 19130 dso: /system/lib64/libbase.so start: 0x7c96d53000 end: 0x7c96d7c000} parse_mmap = { pid: 19130 dso: /system/lib64/libbase.so start: 0x7c96d53000 end: 0x7c96d7c000} parse_mmap = { pid: 19130 dso: /system/lib64/liblog.so start: 0x7c96d2a000 end: 0x7c96d35000} parse_mmap = { pid: 19130 dso: /system/lib64/liblog.so start: 0x7c96d2a000 end: 0x7c96d35000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/lib64/bionic/libdl_android.so start: 0x7c96ced000 end: 0x7c96cee000} parse_mmap = { pid: 19130 dso: /apex/com.android.runtime/lib64/bionic/libdl_android.so start: 0x7c96ced000 end: 0x7c96cee000} parse_mmap = { pid: 19130 dso: /system/lib64/libutils.so start: 0x7c96caa000 end: 0x7c96cb7000} parse_mmap = { pid: 19130 dso: /system/lib64/libutils.so start: 0x7c96caa000 end: 0x7c96cb7000} parse_mmap = { pid: 19130 dso: /system/lib64/libvndksupport.so start: 0x7c96c4d000 end: 0x7c96c4e000} parse_mmap = { pid: 19130 dso: /system/lib64/libvndksupport.so start: 0x7c96c4d000 end: 0x7c96c4e000} parse_mmap = { pid: 19130 dso: /system/lib64/libnetd_client.so start: 0x7c96c36000 end: 0x7c96c3c000} parse_mmap = { pid: 19130 dso: /system/lib64/libnetd_client.so start: 0x7c96c36000 end: 0x7c96c3c000} End
At step 7 it shows no sampled data, and at step 10 there really isn't any output. I think it should be at step 5 that it doesn't work, but perf doesn't actually report an error. Please give me some advice, I would be happy to make this function work successfully on android. This would be helpful for debugging and performance related work. Thanks.