Re: [PATCH perf-tools-next v3 4/4] perf tests: Add shell test for kernel symbol beautifier

[email protected]
Newsgroups org.kernel.vger.linux-perf-users
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The BTF type routing test does not actually test BTF symbolization, as it silently falls back to the default kallsyms beautifier.
--

--- Patch [4]: [PATCH perf-tools-next v3 4/4] perf tests: Add shell test for kernel symbol beautifier ---
commit c8c43ea37c4e0f26131dd9e871af4241cd478b77
Author: Aaron Tomlin <[email protected]>

perf tests: Add shell test for kernel symbol beautifier

This commit adds a shell test script, trace_ksym_beautifier.sh, to verify
that perf trace symbolises kernel virtual addresses and function pointers
using both the default kallsyms beautifier and BTF type routing.

> diff --git a/tools/perf/tests/shell/trace_ksym_beautifier.sh b/tools/perf/tests/shell/trace_ksym_beautifier.sh
> new file mode 100755
> index 0000000000000..30a8429669dd5
> --- /dev/null
> +++ b/tools/perf/tests/shell/trace_ksym_beautifier.sh
[ ... ]
> +test_ksym_btf() {
> +  echo "Testing perf trace kernel symbol beautifier (BTF)"
> +  if [ ! -f /sys/kernel/btf/vmlinux ]; then
> +    echo "Skipping BTF test due to missing vmlinux BTF"
> +    return
> +  fi
> +
> +  output="$(perf trace -e kmem:kmalloc --force-btf --max-events=1 2>&1)"

[Severity: Medium]
Does this actually test the BTF type routing as intended?

Looking at the kmem:kmalloc tracepoint, the call_site field is defined as an
unsigned long, rather than a function pointer. When trace__btf_scnprintf()
evaluates this, it determines it is an integer rather than a function
pointer, and returns 0.

This causes perf to silently fall back to the default SCA_KSYM beautifier.
Consequently, the test passes via the fallback path rather than truly
exercising the BTF routing.

Would it be better to use a tracepoint with a field explicitly typed as a
function pointer for the --force-btf test?

> +  if ! echo "$output" | grep -q -E "call_site: [a-zA-Z_][a-zA-Z0-9_]*" || echo "$output" | grep -q -E "call_site: 0x[0-9a-fA-F]+"
> +  then
> +    printf "BTF function symbolization failed, output:\n%s\n" "$output"
> +    err=1
> +  fi
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.