On 1 August 2016 at 07:19, Mike Leach mike.leach@linaro.org wrote:
Added bash scripts to setup build and test environment variables required when testing the library with perf report and perf script.
Updated HOWTO.md to describe the use of these scripts. Adjust for latest opencsd-perf branch.
Very interesting - I'll have to try that. I still see references to opencsd-0v003 below.
Signed-off-by: Mike Leach mike.leach@linaro.org
HOWTO.md | 70 ++++++++++++++++++---- .../tests/perf-test-scripts/perf-setup-env.bash | 42 +++++++++++++ .../tests/perf-test-scripts/perf-test-report.bash | 14 +++++ .../tests/perf-test-scripts/perf-test-script.bash | 11 ++++ 4 files changed, 124 insertions(+), 13 deletions(-) create mode 100755 decoder/tests/perf-test-scripts/perf-setup-env.bash create mode 100755 decoder/tests/perf-test-scripts/perf-test-report.bash create mode 100755 decoder/tests/perf-test-scripts/perf-test-script.bash
diff --git a/HOWTO.md b/HOWTO.md index ad19e9e..6d3cde3 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -8,7 +8,7 @@ library to collect and extract program flow traces generated by the CoreSight IP blocks on a Linux system. The examples have been generated using an aarch64 Juno-r0 platform. All information is considered accurate and tested using library branches `opencsd-0v002` and `opencsd-0v003` (decode library only) -and the latest perf branch `perf-opencsd-4.7-rc4` (decode library + perf tools) +and the latest perf branch `perf-opencsd-4.7` (decode library + perf tools) on the [OpenCSD github repository][1].
@@ -17,7 +17,7 @@ On Target Trace Acquisition - Perf Record
All the enhancement to the Perf tools that support the new `cs_etm` pmu have not been upstreamed yet. To get the required functionality branch -`perf-opencsd-4.7-rc4` needs to be downloaded to the target system where +`perf-opencsd-4.7` needs to be downloaded to the target system where traces are to be collected. This branch is an upstream v4.7-rc4 kernel supplemented with modifications to the CoreSight framework and drivers to be usable by the Perf core. The remaining out of tree patches are being @@ -163,14 +163,14 @@ the host's (which has nothing to do with the target) architecture: Off Target Perf Tools Compilation
As stated above not all the pieces of the solution have been upstreamed. To -get all the components branch `perf-opencsd-4.7-rc4` needs to be +get all the components branch `perf-opencsd-4.7` needs to be obtained:
- linaro@t430:~/linaro/coresight$ git clone -b perf-opencsd-4.7-rc4 https://github.com/Linaro/OpenCSD.git perf-opencsd-4.7-rc4
- linaro@t430:~/linaro/coresight$ git clone -b perf-opencsd-4.7 https://github.com/Linaro/OpenCSD.git perf-opencsd-4.7 ... ...
- linaro@t430:~/linaro/coresight$ ls perf-opencsd-4.7-rc4/
- linaro@t430:~/linaro/coresight$ ls perf-opencsd-4.7/ arch certs CREDITS Documentation firmware include ipc Kconfig lib Makefile net REPORTING-BUGS scripts sound usr block COPYING crypto drivers fs init Kbuild kernel MAINTAINERS mm README samples security tools virt
@@ -179,12 +179,14 @@ variable telling the build scripts where to find the library is needed. If the `CSTRACE_PATH` variable is not defined the compilation will still be successful, but handling of CoreSight trace data won't be supported.
- linaro@t430:~/linaro/coresight$ cd perf-opencsd-4.7-rc4
- linaro@t430:~/linaro/coresight/perf-opencsd-4.7-rc4$ export CSTRACE_PATH=~/linaro/coresight/opencsd-0v003/decoder
- linaro@t430:~/linaro/coresight/perf-opencsd-4.7-rc4$ make -C tools/perf
+**See perf-test-scripts below for assistance in creating a build and test enviroment.**
- linaro@t430:~/linaro/coresight$ cd perf-opencsd-4.7
- linaro@t430:~/linaro/coresight/perf-opencsd-4.7$ export CSTRACE_PATH=~/linaro/coresight/opencsd-0v003/decoder
- linaro@t430:~/linaro/coresight/perf-opencsd-4.7$ make -C tools/perf ... ...
- linaro@t430:~/linaro/coresight/perf-opencsd-4.7-rc4$ ls -l tools/perf/perf
- linaro@t430:~/linaro/coresight/perf-opencsd-4.7$ ls -l tools/perf/perf -rwxrwxr-x 1 linaro linaro 6276360 Mar 3 10:05 tools/perf/perf
@@ -224,7 +226,7 @@ to be sure everything is clean. linaro@t430:~/linaro/coresight/feb24$ rm -rf ~/.debug linaro@t430:~/linaro/coresight/feb24$ cp -dpR .debug ~/ linaro@t430:~/linaro/coresight/feb24$ export LD_LIBRARY_PATH=~/linaro/coresight/opencsd-0v003/decoder/lib/linux64/dbg/
- linaro@t430:~/linaro/coresight/feb24$ ../perf-opencsd-4.7-rc4/tools/perf/perf report --stdio
linaro@t430:~/linaro/coresight/feb24$ ../perf-opencsd-4.7/tools/perf/perf report --stdio
# To display the perf.data header info, please use --header/--header-only options. #
@@ -268,7 +270,7 @@ to be sure everything is clean.
Additional data can be obtained, which contains a dump of the trace packets received using the command
- mjl@ubuntu-vbox:./perf-opencsd-4.7-rc4/coresight/tools/perf/perf report --stdio --dump
- mjl@ubuntu-vbox:./perf-opencsd-4.7/coresight/tools/perf/perf report --stdio --dump
resulting a large amount of data, trace looking like:-
@@ -317,10 +319,10 @@ Trace Decoding with Perf Script Working with perf scripts needs more command line options but yields interesting results.
- linaro@t430:~/linaro/coresight/feb24$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-4.7-rc4/tools/perf/
- linaro@t430:~/linaro/coresight/feb24$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-4.7/tools/perf/ linaro@t430:~/linaro/coresight/feb24$ export SCRIPT_PATH=$EXEC_PATH/scripts/python/ linaro@t430:~/linaro/coresight/feb24$ export XTOOL_PATH=/your/aarch64/toolchain/path/bin/
- linaro@t430:~/linaro/coresight/feb24$ ../perf-opencsd-4.7-rc4/tools/perf/perf --exec-path=${EXEC_PATH} script --script=python:${SCRIPT_PATH}/cs-trace-disasm.py -- -d ${XTOOL_PATH}/aarch64-linux-gnu-objdump
linaro@t430:~/linaro/coresight/feb24$ ../perf-opencsd-4.7/tools/perf/perf --exec-path=${EXEC_PATH} script --script=python:${SCRIPT_PATH}/cs-trace-disasm.py -- -d ${XTOOL_PATH}/aarch64-linux-gnu-objdump
7f89f24d80: 910003e0 mov x0, sp 7f89f24d84: 94000d53 bl 7f89f282d0 <free@plt+0x3790>
@@ -346,6 +348,48 @@ interesting results. 7f89f28304: eb01001f cmp x0, x1 7f89f28308: 54ffffc1 b.ne 7f89f28300 <free@plt+0x37c0>
+Perf Test Environment Scripts +-----------------------------
+The decoder library comes with a number of `bash` scripts that ease the setting up of the +offline build and test environment for perf, and executing tests.
+These scripts can be found in
- decoder/tests/perf-test-scripts
+There are three scripts provided:
+- `perf-setup-env.bash` : this sets up all the environment variables mentioned above. +- `perf-test-report.bash` : this runs `perf report` - using the environment setup by `perf-setup-env.bash` +- `perf-test-script.bash` : this runs `perf script` - using the environment setup by `perf-setup-env.bash`
+Use as follows:-
+1. Prior to building perf, edit `perf-setup-env.bash` to conform to your environment. There are four lines at the top of the file that will require editing.
+2. Execute the script using the command
source perf-setup-env.bash
- This will set up all the environment variables mentioned in the sections on building and running
- perf above, and these are used by the `perf-test...` scripts to run the tests.
+3. Build perf as described above. +4. Follow the instructions for downloading the test capture, or create a capture from your target. +5. Copy the `perf-test...` scripts into the capture data directory -> the one that contains `perf.data`.
+6. The scripts can now be run. No options are required for the default operation, but any command line options will be added to the perf report / perf script command line.
+e.g.
./perf-test-report.bash --dump
+will add the --dump option to the end of the command line and run
${PERF_EXEC_PATH}/perf report --stdio --dump
The Linaro CoreSight Team
- Mike Leach
diff --git a/decoder/tests/perf-test-scripts/perf-setup-env.bash b/decoder/tests/perf-test-scripts/perf-setup-env.bash new file mode 100755 index 0000000..09431a7 --- /dev/null +++ b/decoder/tests/perf-test-scripts/perf-setup-env.bash @@ -0,0 +1,42 @@ +#!/bin/bash +# Script to set up the environment for testing perf with OpenCSD +# +# See HOWTO.md for details on how these environment variables should be set and used. +# +# to use this script:- +# +# source perf-setup-env.bash +#
+#------ User Edits Start ------- +# Edit as required for user system.
+# Root of the opencsd library project as cloned from github +export OPENCSD_ROOT=~/OpenCSD/opencsd-github/opencsd
+# the opencsd build library directory to use. +export OCSD_LIB_DIR=lib/linux64/rel
+# the root of the perf branch / perf dev-tree as checked out +export PERF_ROOT=~/work2/perf-opencsd/mp-4.7-rc4/coresight
+# the arm x-compiler toolchain path +export XTOOLS_PATH=~/work2/toolchain-aarch64/gcc-linaro-4.9-2015.05-1-rc1-x86_64_aarch64-linux-gnu/bin/
+#------ User Edits End -------
+# path to source/include root dir - used by perf build to +# include Opencsd decoder. +export CSTRACE_PATH=${OPENCSD_ROOT}/decoder
+# add library to lib path +if [ "${LD_LIBRARY_PATH}" == "" ]; then
- export LD_LIBRARY_PATH=${CSTRACE_PATH}/${OCSD_LIB_DIR}
+else
- export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CSTRACE_PATH}/${OCSD_LIB_DIR}
+fi
+# perf script defines +export PERF_EXEC_PATH=${PERF_ROOT}/tools/perf +export PERF_SCRIPT_PATH=${PERF_EXEC_PATH}/scripts/python
diff --git a/decoder/tests/perf-test-scripts/perf-test-report.bash b/decoder/tests/perf-test-scripts/perf-test-report.bash new file mode 100755 index 0000000..f8d4e7e --- /dev/null +++ b/decoder/tests/perf-test-scripts/perf-test-report.bash @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Script to run perf report +# +# Uses environment set up by perf-setup-env.bash. +# See HOWTO.md for further details. +# +# run from directory containing perf.data file. +# +#
+${PERF_EXEC_PATH}/perf report --stdio $*
diff --git a/decoder/tests/perf-test-scripts/perf-test-script.bash b/decoder/tests/perf-test-scripts/perf-test-script.bash new file mode 100755 index 0000000..745e8b7 --- /dev/null +++ b/decoder/tests/perf-test-scripts/perf-test-script.bash @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Script to run perf report +# +# Uses environment set up by perf-setup-env.bash. +# See HOWTO.md for further details. +# +# run from directory containing perf.data file. +#
+${PERF_EXEC_PATH}/perf --exec-path=${PERF_EXEC_PATH} script --script=python:${PERF_SCRIPT_PATH}/cs-trace-disasm.py -- -d ${XTOOLS_PATH}/aarch64-linux-gnu-objdump $*
2.7.4
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight