Re: [PATCH v3 1/2] perf trace: Add tests for BTF general augmentation
From: Howard Chu
Date: Sun Dec 15 2024 - 01:58:14 EST
Hello Namhyung,
On Fri, Dec 13, 2024 at 4:42 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> Hi Howard,
>
> On Wed, Dec 11, 2024 at 02:49:26PM -0800, Howard Chu wrote:
> > Currently, we only have perf trace augmentation tests for enum
> > arguments. This patch adds tests for more general syscall arguments,
> > such as struct pointers, strings, and buffers.
> >
> > These tests utilize the perf config system to configure the perf trace
> > output, as suggested by Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> >
> > Suggested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> > Signed-off-by: Howard Chu <howardchu95@xxxxxxxxx>
> > ---
> > tools/perf/tests/shell/trace_btf_general.sh | 93 +++++++++++++++++++++
> > 1 file changed, 93 insertions(+)
> > create mode 100755 tools/perf/tests/shell/trace_btf_general.sh
> >
> > diff --git a/tools/perf/tests/shell/trace_btf_general.sh b/tools/perf/tests/shell/trace_btf_general.sh
> > new file mode 100755
> > index 000000000000..bef07bad42bb
> > --- /dev/null
> > +++ b/tools/perf/tests/shell/trace_btf_general.sh
> > @@ -0,0 +1,93 @@
> > +#!/bin/bash
> > +# perf trace BTF general tests
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +err=0
> > +set -e
> > +
> > +. "$(dirname $0)"/lib/probe.sh
> > +
> > +file1=$(mktemp /tmp/file1_XXXX)
> > +file2=$(echo $file1 | sed 's/file1/file2/g')
> > +
> > +buffer="buffer content"
> > +perf_config_tmp=$(mktemp /tmp/.perfconfig_XXXXX)
> > +
> > +trap cleanup EXIT TERM INT HUP
> > +
> > +check_vmlinux() {
> > + echo "Checking if vmlinux BTF exists"
> > + if ! ls /sys/kernel/btf/vmlinux 1>/dev/null 2>&1
>
> Normally we do
>
> if [ ! -f /sys/kernel/btf/vmlinux ]
Sure, I'll change the check to this.
>
> > + then
> > + echo "Skipped due to missing vmlinux BTF"
> > + err=2
>
> This can be overwritten by trace_test_string.
Oops my bad sorry.
>
>
> > + fi
> > +}
> > +
> > +trace_test_string() {
> > + echo "Testing perf trace's string augmentation"
> > + if ! perf trace -e renameat* --max-events=1 -- mv ${file1} ${file2} 2>&1 | \
> > + grep -q -E "^mv/[0-9]+ renameat(2)?\(.*, \"${file1}\", .*, \"${file2}\", .*\) += +[0-9]+$"
>
> Does this work without BTF support?
Yes, this works without BTF with Arnaldo's patch adding
sys_enter_renameat2. Before the patch, it wouldn't work because the
second filename would not be displayed properly. I understand this may
seem redundant, but now in perf trace all the data is collected
through the BTF general collector (if BTF is present), so this
trace_test_string() tests the new code path that uses BTF information
to pretty-print string arguments, since all data collection goes
through it.
Thanks,
Howard