From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 592F2FA3757 for ; Fri, 13 Sep 2024 13:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jk42BBPbZyAoyBGnraQBCVWneXOR+QFdDciS6JucM+w=; b=SQcNG++8l68qdwr/9MRSNhCbTf di8h8ebDfDL6FUc1OvWy5ugg5k0C3NV1Z8OEA/Z6Gv8VsO2P1Vg0yABFgXAxIMljlHFXbE+ZTReuQ ZH6rw90DKKbt3Gl9w765WEv9QyzGXWK9WVYiI/Set/0V9eNxRhx8VUvp14hEmyEm8g8p2k46Ujeww Hrz/wCM9S/lH+HNzI4UL1Fx6lYnKzn6cAiyghkerUeSPNYmqxdjW3jlDLRpxiyNS640yvY7UXnFYp Pek54GmicMQkncLMwqewI7VTK+rLqws1nXNGhIN6rkY0NP82iXPvZ7hRsIVfCWtK13qjnWUn58BdP 6gQsl62Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sp6Tb-0000000G3Aq-4Akq; Fri, 13 Sep 2024 13:36:43 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sp6S8-0000000G2sa-0Nag for linux-arm-kernel@lists.infradead.org; Fri, 13 Sep 2024 13:35:13 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C65A613D5; Fri, 13 Sep 2024 06:35:40 -0700 (PDT) Received: from [10.2.76.71] (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 787033F73B; Fri, 13 Sep 2024 06:35:08 -0700 (PDT) Message-ID: <42bfbda0-3b4a-496f-a96a-8f16d3e108f7@arm.com> Date: Fri, 13 Sep 2024 14:35:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 7/7] perf test: cs-etm: Test Coresight disassembly script To: James Clark , linux-perf-users@vger.kernel.org, gankulkarni@os.amperecomputing.com, coresight@lists.linaro.org, scclevenger@os.amperecomputing.com Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Leo Yan , Ben Gainey , Ruidong Tian , Benjamin Gray , Mathieu Poirier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20240912151143.1264483-1-james.clark@linaro.org> <20240912151143.1264483-8-james.clark@linaro.org> Content-Language: en-US From: Leo Yan In-Reply-To: <20240912151143.1264483-8-james.clark@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240913_063512_263075_41C4C95A X-CRM114-Status: GOOD ( 21.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/12/24 16:11, James Clark wrote: > > Run a few samples through the disassembly script and check to see that > at least one branch instruction is printed. > > Signed-off-by: James Clark > --- > .../tests/shell/test_arm_coresight_disasm.sh | 63 +++++++++++++++++++ > 1 file changed, 63 insertions(+) > create mode 100755 tools/perf/tests/shell/test_arm_coresight_disasm.sh > > diff --git a/tools/perf/tests/shell/test_arm_coresight_disasm.sh b/tools/perf/tests/shell/test_arm_coresight_disasm.sh > new file mode 100755 > index 000000000000..6d004bf29f80 > --- /dev/null > +++ b/tools/perf/tests/shell/test_arm_coresight_disasm.sh > @@ -0,0 +1,63 @@ > +#!/bin/sh > +# Check Arm CoreSight disassembly script completes without errors > +# SPDX-License-Identifier: GPL-2.0 > + > +# The disassembly script reconstructs ranges of instructions and gives these to objdump to > +# decode. objdump doesn't like ranges that go backwards, but these are a good indication > +# that decoding has gone wrong either in OpenCSD, Perf or in the range reconstruction in > +# the script. Test all 3 parts are working correctly by running the script. > + > +skip_if_no_cs_etm_event() { > + perf list | grep -q 'cs_etm//' && return 0 > + > + # cs_etm event doesn't exist > + return 2 > +} > + > +skip_if_no_cs_etm_event || exit 2 > + > +# Assume an error unless we reach the very end > +set -e > +glb_err=1 > + > +perfdata_dir=$(mktemp -d /tmp/__perf_test.perf.data.XXXXX) > +perfdata=${perfdata_dir}/perf.data > +file=$(mktemp /tmp/temporary_file.XXXXX) > + > +cleanup_files() > +{ > + set +e > + rm -rf ${perfdata_dir} > + rm -f ${file} > + trap - EXIT TERM INT > + exit $glb_err > +} > + > +trap cleanup_files EXIT TERM INT > + > +# Ranges start and end on branches, so check for some likely branch instructions > +sep="\s\|\s" > +branch_search="\sbl${sep}b${sep}b.ne${sep}b.eq${sep}cbz\s" > + > +## Test kernel ## > +if [ -e /proc/kcore ]; then > + echo "Testing kernel disassembly" > + perf record -o ${perfdata} -e cs_etm//k --kcore -- touch $file > /dev/null 2>&1 > + perf script -i ${perfdata} -s python:tools/perf/scripts/python/arm-cs-trace-disasm.py -- \ > + -d --stop-sample=30 2> /dev/null > ${file} This is fine for self test. But for a CI test in a distro, will it fail to find script with prefix 'tools/perf/...'? Thanks, Leo > + grep -q -e ${branch_search} ${file} > + echo "Found kernel branches" > +else > + # kcore is required for correct kernel decode due to runtime code patching > + echo "No kcore, skipping kernel test" > +fi > + > +## Test user ## > +echo "Testing userspace disassembly" > +perf record -o ${perfdata} -e cs_etm//u -- touch $file > /dev/null 2>&1 > +perf script -i ${perfdata} -s python:tools/perf/scripts/python/arm-cs-trace-disasm.py -- \ > + -d --stop-sample=30 2> /dev/null > ${file} > +grep -q -e ${branch_search} ${file} > +echo "Found userspace branches" > + > +glb_err=0 > -- > 2.34.1 >