Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf test: Handle perftool-testsuite_probe failure due to broken DWARF

Test case test_adding_blacklisted ends in failure if the blacklisted
probe is of an assembler function with no DWARF available. At the same
time, probing the blacklisted function with ASM DWARF doesn't test the
blacklist itself as the failure is a result of the broken DWARF.

When the broken DWARF output is encountered, check if the probed
function was compiled by the assembler. If so, the broken DWARF message
is expected and does not report a perf issue, else report a failure. If
the ASM DWARF affected the probe, try the next probe on the blacklist.
If the first 5 probes are defective due to broken DWARF, skip the test
case.

Fixes: def5480d63c1e847 ("perf testsuite probe: Add test for blacklisted kprobes handling")
Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Link: https://lore.kernel.org/r/20241017161555.236769-1-vmolnaro@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Veronika Molnarova and committed by
Arnaldo Carvalho de Melo
06a130e4 d822ca29

+52 -13
+52 -13
tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh
··· 19 19 TEST_RESULT=0 20 20 21 21 # skip if not supported 22 - BLACKFUNC=`head -n 1 /sys/kernel/debug/kprobes/blacklist 2> /dev/null | cut -f2` 23 - if [ -z "$BLACKFUNC" ]; then 22 + BLACKFUNC_LIST=`head -n 5 /sys/kernel/debug/kprobes/blacklist 2> /dev/null | cut -f2` 23 + if [ -z "$BLACKFUNC_LIST" ]; then 24 24 print_overall_skipped 25 25 exit 0 26 26 fi 27 + 28 + # try to find vmlinux with DWARF debug info 29 + VMLINUX_FILE=$(perf probe -v random_probe |& grep "Using.*for symbols" | sed -r 's/^Using (.*) for symbols$/\1/') 27 30 28 31 # remove all previously added probes 29 32 clear_all_probes 30 33 31 34 32 35 ### adding blacklisted function 33 - 34 - # functions from blacklist should be skipped by perf probe 35 - ! $CMD_PERF probe $BLACKFUNC > $LOGS_DIR/adding_blacklisted.log 2> $LOGS_DIR/adding_blacklisted.err 36 - PERF_EXIT_CODE=$? 37 - 38 36 REGEX_SCOPE_FAIL="Failed to find scope of probe point" 39 37 REGEX_SKIP_MESSAGE=" is blacklisted function, skip it\." 40 - REGEX_NOT_FOUND_MESSAGE="Probe point \'$BLACKFUNC\' not found." 38 + REGEX_NOT_FOUND_MESSAGE="Probe point \'$RE_EVENT\' not found." 41 39 REGEX_ERROR_MESSAGE="Error: Failed to add events." 42 40 REGEX_INVALID_ARGUMENT="Failed to write event: Invalid argument" 43 41 REGEX_SYMBOL_FAIL="Failed to find symbol at $RE_ADDRESS" 44 - REGEX_OUT_SECTION="$BLACKFUNC is out of \.\w+, skip it" 45 - ../common/check_all_lines_matched.pl "$REGEX_SKIP_MESSAGE" "$REGEX_NOT_FOUND_MESSAGE" "$REGEX_ERROR_MESSAGE" "$REGEX_SCOPE_FAIL" "$REGEX_INVALID_ARGUMENT" "$REGEX_SYMBOL_FAIL" "$REGEX_OUT_SECTION" < $LOGS_DIR/adding_blacklisted.err 46 - CHECK_EXIT_CODE=$? 42 + REGEX_OUT_SECTION="$RE_EVENT is out of \.\w+, skip it" 43 + REGEX_MISSING_DECL_LINE="A function DIE doesn't have decl_line. Maybe broken DWARF?" 47 44 48 - print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "adding blacklisted function $BLACKFUNC" 49 - (( TEST_RESULT += $? )) 45 + BLACKFUNC="" 46 + SKIP_DWARF=0 50 47 48 + for BLACKFUNC in $BLACKFUNC_LIST; do 49 + echo "Probing $BLACKFUNC" 50 + 51 + # functions from blacklist should be skipped by perf probe 52 + ! $CMD_PERF probe $BLACKFUNC > $LOGS_DIR/adding_blacklisted.log 2> $LOGS_DIR/adding_blacklisted.err 53 + PERF_EXIT_CODE=$? 54 + 55 + # check for bad DWARF polluting the result 56 + ../common/check_all_patterns_found.pl "$REGEX_MISSING_DECL_LINE" >/dev/null < $LOGS_DIR/adding_blacklisted.err 57 + 58 + if [ $? -eq 0 ]; then 59 + SKIP_DWARF=1 60 + echo "Result polluted by broken DWARF, trying another probe" 61 + 62 + # confirm that the broken DWARF comes from assembler 63 + if [ -n "$VMLINUX_FILE" ]; then 64 + readelf -wi "$VMLINUX_FILE" | 65 + awk -v probe="$BLACKFUNC" '/DW_AT_language/ { comp_lang = $0 } 66 + $0 ~ probe { if (comp_lang) { print comp_lang }; exit }' | 67 + grep -q "MIPS assembler" 68 + 69 + CHECK_EXIT_CODE=$? 70 + if [ $CHECK_EXIT_CODE -ne 0 ]; then 71 + SKIP_DWARF=0 # broken DWARF while available 72 + break 73 + fi 74 + fi 75 + else 76 + ../common/check_all_lines_matched.pl "$REGEX_SKIP_MESSAGE" "$REGEX_NOT_FOUND_MESSAGE" "$REGEX_ERROR_MESSAGE" "$REGEX_SCOPE_FAIL" "$REGEX_INVALID_ARGUMENT" "$REGEX_SYMBOL_FAIL" "$REGEX_OUT_SECTION" < $LOGS_DIR/adding_blacklisted.err 77 + CHECK_EXIT_CODE=$? 78 + 79 + SKIP_DWARF=0 80 + break 81 + fi 82 + done 83 + 84 + if [ $SKIP_DWARF -eq 1 ]; then 85 + print_testcase_skipped "adding blacklisted function $BLACKFUNC" 86 + else 87 + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "adding blacklisted function $BLACKFUNC" 88 + (( TEST_RESULT += $? )) 89 + fi 51 90 52 91 ### listing not-added probe 53 92