From nobody Thu Jan 1 10:42:04 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A808CDB474 for ; Mon, 23 Oct 2023 13:17:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230113AbjJWNRN (ORCPT ); Mon, 23 Oct 2023 09:17:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjJWNRL (ORCPT ); Mon, 23 Oct 2023 09:17:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0AD610B; Mon, 23 Oct 2023 06:17:07 -0700 (PDT) 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 5FC412F4; Mon, 23 Oct 2023 06:17:48 -0700 (PDT) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DC23F3F762; Mon, 23 Oct 2023 06:17:04 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, coresight@lists.linaro.org, suzuki.poulose@arm.com, atrajeev@linux.vnet.ibm.com, tianruidong@linux.alibaba.com Cc: linux-kernel@vger.kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kajol Jain , Tiezhu Yang , Anushree Mathur Subject: [PATCH] perf tests: test_arm_coresight: Simplify source iteration Date: Mon, 23 Oct 2023 14:15:49 +0100 Message-Id: <20231023131550.487760-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There are two reasons to do this, firstly there is a shellcheck warning in cs_etm_dev_name(), which can be completely deleted. And secondly the current iteration method doesn't support systems with both ETE and ETM because it picks one or the other. There isn't a known system with this configuration, but it could happen in the future. Iterating over all the sources for each CPU can be done by going through /sys/bus/event_source/devices/cs_etm/cpu* and following the symlink back to the Coresight device in /sys/bus/coresight/devices. This will work whether the device is ETE, ETM or any future name, and is much simpler and doesn't require any hard coded version numbers Suggested-by: Suzuki K Poulose Signed-off-by: James Clark Acked-by: Ian Rogers Tested-by: Leo Yan --- This was discussed here previously: https://lore.kernel.org/all/20230929041133.95355-2-atrajeev@linux.vnet.ibm.= com/ I chose not to add a fixes tag like the original because shellcheck isn't part of the build so it doesn't really fix any real issue yet and is just a refactor. tools/perf/tests/shell/test_arm_coresight.sh | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/test= s/shell/test_arm_coresight.sh index fe78c4626e45..65dd85207125 100755 --- a/tools/perf/tests/shell/test_arm_coresight.sh +++ b/tools/perf/tests/shell/test_arm_coresight.sh @@ -11,19 +11,6 @@ =20 glb_err=3D0 =20 -cs_etm_dev_name() { - cs_etm_path=3D$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -p= rint -quit) - trcdevarch=3D$(cat ${cs_etm_path}/mgmt/trcdevarch) - archhver=3D$((($trcdevarch >> 12) & 0xf)) - archpart=3D$(($trcdevarch & 0xfff)) - - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" =3D "0xA13" ] ; th= en - echo "ete" - else - echo "etm" - fi -} - skip_if_no_cs_etm_event() { perf list | grep -q 'cs_etm//' && return 0 =20 @@ -149,7 +136,9 @@ arm_cs_iterate_devices() { =20 arm_cs_etm_traverse_path_test() { # Iterate for every ETM device - for dev in /sys/bus/coresight/devices/$(cs_etm_dev_name)*; do + for dev in /sys/bus/event_source/devices/cs_etm/cpu*; do + # Canonicalize the path + dev=3D`readlink -f $dev` =20 # Find the ETM device belonging to which CPU cpu=3D`cat $dev/cpu` --=20 2.34.1