From nobody Tue Nov 26 19:57:08 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61FB21C6F55 for ; Wed, 16 Oct 2024 09:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729070414; cv=none; b=TXFCrcXiY7OI/QqM3jlHIkWgWZvzax+hQO8eCYUwXcmwfXpLzrieXjq+EicF850zWf9VcgxmuPd5tNBpvZJSRmVPacUWQROA89sJcscXSjkddeVJSjyfJdUFI8lye7zjjkC+PfX9FqJtAmLgiTQ6PMcOoCwCH2DTXpHr8gHCF2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729070414; c=relaxed/simple; bh=ZJgqU7D2tEQg77R4kba5Yy9aZywjprp4o4yoANv/N74=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=I5k0vLJgqzfrpeJEcSX2EbEOjhT5B5Q49ls4rJkW2PjXurz4x5Wrtjq/qvPcQA8CPtJkM6fvFAAsGjzk+sZSZD7RLhUsCTgu2nTr7jPLFu5B+Lsq4ZV8su2Nmvt/AENXMZTU292rglgMC+zSNGx4WiPo0BbVG1/zeUq7b4PIfFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Y31SZN6p; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y31SZN6p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729070411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MD4PH+TjntKYNaAOSsAlc5YKOp3Bk0mCE3I/9BhgQQM=; b=Y31SZN6pJMno48C2cH/26jSHSgLoqJCONHbL4HtoA3fFlSKU0z+/rFsWEeUQHKHf8Tky37 AElmG6z1H1NF+EyFBj3DO2aJ3Ar4q/TM0xXCxATmOC48ExXdBofT1I6nLikqOfbQrnSbD2 kcVTat+8tAxpjD1uuq7HRAJ/aSQhC2U= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-74-JGGOLuF_OJ6zH1KC-6Qn8A-1; Wed, 16 Oct 2024 05:20:05 -0400 X-MC-Unique: JGGOLuF_OJ6zH1KC-6Qn8A-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7A00A1955EE6; Wed, 16 Oct 2024 09:20:03 +0000 (UTC) Received: from dhcpe026.fit.vutbr.com (unknown [10.45.226.97]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 502691956086; Wed, 16 Oct 2024 09:19:53 +0000 (UTC) From: vmolnaro@redhat.com To: linux-perf-users@vger.kernel.org, acme@kernel.org, acme@redhat.com Cc: mpetlan@redhat.com, peterz@infradead.org, mingo@redhat.com, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, kan.liang@linux.intel.com, linux-kernel@vger.kernel.org Subject: [PATCH] perf test: Handle perftool-testsuite_probe failure due to broken DWARF Date: Wed, 16 Oct 2024 11:19:30 +0200 Message-ID: <20241016091930.191761-1-vmolnaro@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" From: Veronika Molnarova 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 kp= robes handling") Signed-off-by: Veronika Molnarova --- .../base_probe/test_adding_blacklisted.sh | 74 +++++++++++++++---- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh b= /tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh index b5dc10b2a73810b3..f67b3b267ac55269 100755 --- a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh +++ b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh @@ -19,35 +19,79 @@ TEST_RESULT=3D0 =20 # skip if not supported -BLACKFUNC=3D`head -n 1 /sys/kernel/debug/kprobes/blacklist 2> /dev/null | = cut -f2` -if [ -z "$BLACKFUNC" ]; then +BLACKFUNC_LIST=3D`head -n 5 /sys/kernel/debug/kprobes/blacklist 2> /dev/nu= ll | cut -f2` +if [ -z "$BLACKFUNC_LIST" ]; then print_overall_skipped exit 0 fi =20 +# chceck if locate is present to find vmlinux with DWARF debug info +locate --help 2&> /dev/null +if [ $? -eq 0 ]; then + VMLINUX_FILE=3D$(locate -r '/vmlinux$' | xargs -I{} sh -c 'test -f "{}" &= & echo "{}"' | grep "$(uname -r)") +fi + # remove all previously added probes clear_all_probes =20 =20 ### adding blacklisted function - -# functions from blacklist should be skipped by perf probe -! $CMD_PERF probe $BLACKFUNC > $LOGS_DIR/adding_blacklisted.log 2> $LOGS_D= IR/adding_blacklisted.err -PERF_EXIT_CODE=3D$? - REGEX_SCOPE_FAIL=3D"Failed to find scope of probe point" REGEX_SKIP_MESSAGE=3D" is blacklisted function, skip it\." -REGEX_NOT_FOUND_MESSAGE=3D"Probe point \'$BLACKFUNC\' not found." +REGEX_NOT_FOUND_MESSAGE=3D"Probe point \'$RE_EVENT\' not found." REGEX_ERROR_MESSAGE=3D"Error: Failed to add events." REGEX_INVALID_ARGUMENT=3D"Failed to write event: Invalid argument" REGEX_SYMBOL_FAIL=3D"Failed to find symbol at $RE_ADDRESS" -REGEX_OUT_SECTION=3D"$BLACKFUNC is out of \.\w+, skip it" -../common/check_all_lines_matched.pl "$REGEX_SKIP_MESSAGE" "$REGEX_NOT_FOU= ND_MESSAGE" "$REGEX_ERROR_MESSAGE" "$REGEX_SCOPE_FAIL" "$REGEX_INVALID_ARGU= MENT" "$REGEX_SYMBOL_FAIL" "$REGEX_OUT_SECTION" < $LOGS_DIR/adding_blacklis= ted.err -CHECK_EXIT_CODE=3D$? - -print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "adding blacklisted functio= n $BLACKFUNC" -(( TEST_RESULT +=3D $? )) - +REGEX_OUT_SECTION=3D"$RE_EVENT is out of \.\w+, skip it" +REGEX_MISSING_DECL_LINE=3D"A function DIE doesn't have decl_line. Maybe br= oken DWARF?" + +BLACKFUNC=3D"" +SKIP_DWARF=3D0 + +for BLACKFUNC in $BLACKFUNC_LIST; do + echo "Probing $BLACKFUNC" + + # functions from blacklist should be skipped by perf probe + ! $CMD_PERF probe $BLACKFUNC > $LOGS_DIR/adding_blacklisted.log 2> $LOGS_= DIR/adding_blacklisted.err + PERF_EXIT_CODE=3D$? + + # check for bad DWARF polluting the result + ../common/check_all_patterns_found.pl "$REGEX_MISSING_DECL_LINE" >/dev/nu= ll < $LOGS_DIR/adding_blacklisted.err + + if [ $? -eq 0 ]; then + SKIP_DWARF=3D1 + + # confirm that the broken DWARF comes from assembler + if [ -n "$VMLINUX_FILE" ]; then + readelf -wi "$VMLINUX_FILE" | + awk -v probe=3D"$BLACKFUNC" '/DW_AT_language/ { comp_lang =3D $0 } + $0 ~ probe { if (comp_lang) { print comp_lang }; exit }' | + grep -q "MIPS assembler" + + CHECK_EXIT_CODE=3D$? + if [ $CHECK_EXIT_CODE -ne 0 ]; then + SKIP_DWARF=3D0 # broken DWARF while available + break + fi + else + echo "Result polluted by broken DWARF, trying another probe" + fi + + else + ../common/check_all_lines_matched.pl "$REGEX_SKIP_MESSAGE" "$REGEX_NOT_F= OUND_MESSAGE" "$REGEX_ERROR_MESSAGE" "$REGEX_SCOPE_FAIL" "$REGEX_INVALID_AR= GUMENT" "$REGEX_SYMBOL_FAIL" "$REGEX_OUT_SECTION" < $LOGS_DIR/adding_blackl= isted.err + CHECK_EXIT_CODE=3D$? + + SKIP_DWARF=3D0 + break + fi +done + +if [ $SKIP_DWARF -eq 1 ]; then + print_testcase_skipped "adding blacklisted function $BLACKFUNC" +else + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "adding blacklisted functi= on $BLACKFUNC" + (( TEST_RESULT +=3D $? )) +fi =20 ### listing not-added probe =20 --=20 2.43.0