lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue, 25 Jan 2022 16:51:32 +0000
From:   German Gomez <german.gomez@....com>
To:     linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        acme@...nel.org
Cc:     German Gomez <german.gomez@....com>, Jiri Olsa <jolsa@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>
Subject: [PATCH] perf test: Add shell script test for ARM64 frame-pointer call graphs

In the commit in [1], the frame-pointer call-graphs were fixed in ARM64.
So add a test to avoid future regressions.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b9f6fbb3b2c29736970ae9fcc0e82b0bd459442b

Suggested-by: Jiri Olsa <jolsa@...nel.org>
Signed-off-by: German Gomez <german.gomez@....com>
---
 .../tests/shell/test_arm_fp_call_graph.sh     | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100755 tools/perf/tests/shell/test_arm_fp_call_graph.sh

diff --git a/tools/perf/tests/shell/test_arm_fp_call_graph.sh b/tools/perf/tests/shell/test_arm_fp_call_graph.sh
new file mode 100755
index 000000000000..4ba17163b320
--- /dev/null
+++ b/tools/perf/tests/shell/test_arm_fp_call_graph.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+# Check frame pointer call-graphs are correct on Arm64
+
+# SPDX-License-Identifier: GPL-2.0
+# German Gomez <german.gomez@....com>, 2022
+
+# This test checks that the perf tool injects the missing caller of a
+# leaf function on Arm64 when unwinding using frame pointers.
+# See: https://lore.kernel.org/r/20211217154521.80603-7-german.gomez@arm.com
+
+# Only run this test on Arm64
+lscpu | grep -q "aarch64" || return 2
+
+if ! [ -x "$(command -v cc)" ]; then
+	echo "failed: no compiler, install gcc"
+	exit 2
+fi
+
+PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+TEST_PROGRAM_SOURCE=$(mktemp /tmp/test_program.XXXXX.c)
+TEST_PROGRAM=$(mktemp /tmp/test_program.XXXXX)
+SCRIPT_FILE=$(mktemp /tmp/perf.script.XXXXX)
+
+cleanup_files() {
+	rm -f $PERF_DATA*
+	rm -f $TEST_PROGRAM_SOURCE
+	rm -f $TEST_PROGRAM
+	rm -f $SCRIPT_FILE
+}
+
+trap cleanup_files exit term int
+
+# compile test program
+cat << EOF > $TEST_PROGRAM_SOURCE
+int a = 0;
+void leaf(void) {
+  for (int i = 0; i < 10000000; i++)
+    a *= a;
+}
+void parent(void) {
+  leaf();
+}
+int main(void) {
+  parent();
+  return 0;
+}
+EOF
+
+CFLAGS="-O0 -fno-inline -fno-omit-frame-pointer"
+cc $CFLAGS $TEST_PROGRAM_SOURCE -o $TEST_PROGRAM || exit 1
+
+perf record --call-graph fp -o $PERF_DATA -- $TEST_PROGRAM
+
+# search for the following pattern in perf-script output
+#     734 leaf+0x18 (...)
+#     78b parent+0xb (...)
+#     7a4 main+0xc (...)
+
+perf script -i $PERF_DATA | egrep "[0-9a-f]+ +leaf" -A2 -m1 > $SCRIPT_FILE
+
+egrep -q " +leaf\+0x[0-9a-f]+" $SCRIPT_FILE && \
+egrep -q " +parent\+0x[0-9a-f]+" $SCRIPT_FILE && \
+egrep -q " +main\+0x[0-9a-f]+" $SCRIPT_FILE
+err=$?
+
+echo -n "Check frame pointer call-graphs on Arm64: "
+if [ $err != 0 ]; then
+	echo "FAIL"
+	exit 1
+else
+	echo "PASS"
+fi
+
+exit 0
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ