Message ID | 20231023131550.487760-1-james.clark@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1290858vqx; Mon, 23 Oct 2023 06:17:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSWEdcHcjubcTQy6YsRxc0zrDYl5uxzgK8XitTKWwIaIzbVaqRdFycCNg4Kzrk8YVIuyHO X-Received: by 2002:a17:902:e5cb:b0:1ca:220:ce42 with SMTP id u11-20020a170902e5cb00b001ca0220ce42mr7314161plf.37.1698067050375; Mon, 23 Oct 2023 06:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698067050; cv=none; d=google.com; s=arc-20160816; b=I4DVCNosbNRYEMyDVW7y8xAGZ+jk+ra+uvGbJvRmwFRReNk62u1wLksNgI5EEyCPGi H6p69tZsN8ULJHCHjjpz0wvC+awTT7YGSMxHeUqc9Py8K1VpFkW1jCnXRweMel67iofT JTl5Z1FAhExofl6msLE5rLILktVyVLiZbF7cE3iieaKCrXxY6rzOrqvThtuJ1YAus7iF ALPQ+kdvWSlxTNmfLvmux/yHUJVsuUnczxDew/Vz2UlLJIx9lOYfatlawc9XceK7FI9C oAgEA0ZDKotyfzqI7vfUqrcHsKP6UIEZxaIYGJnJn/AelLpiw5kc1OZ6ruqMlA+of/9I 6HHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=d354Oujesk+dcbwR0/HqWgMYbMzl4JahhIS1rCfKmf4=; fh=ehbYJBdzUpRLQBZTnuVR17kEKGKzfn9GAmR03hucq+Q=; b=I4u1G3qI3BHf/XYtfqrWno5fSQQjEDR1H9rHMy1xXmaRIrFkI8978LxZnGuC6ErT5c riPidN+m9HHmei7MukDEIAmTP0ac0rL8kcr1WIDcq8B/8Cpl81uUogQy316y8/ANwCz+ dh26vMfE8PPWMONKm9D1sXIOLXLh2HSrxHCl/oqObldj6GyJu1eZJitLqgngS1mUQ5xr 0MydxrqIzjirLLTXWEwBtVCUoV08AeKvYdGiEQVqDBhfc18WNlktgABjMNqJFZTN6rEl /+j3R2rDNZt5pQt/WUdiEUdGDKBSPstLT8OnIvbd84JYNODPhZcYquEltkKFORoebEOR VBMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u3-20020a17090282c300b001c72c792794si6185793plz.47.2023.10.23.06.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C94C380A4AC5; Mon, 23 Oct 2023 06:17:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbjJWNRM (ORCPT <rfc822;aposhian.dev@gmail.com> + 27 others); Mon, 23 Oct 2023 09:17:12 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <james.clark@arm.com> 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 <james.clark@arm.com>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Kajol Jain <kjain@linux.ibm.com>, Tiezhu Yang <yangtiezhu@loongson.cn>, Anushree Mathur <anushree.mathur@linux.vnet.ibm.com> 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: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 06:17:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780552355260379656 X-GMAIL-MSGID: 1780552355260379656 |
Series |
perf tests: test_arm_coresight: Simplify source iteration
|
|
Commit Message
James Clark
Oct. 23, 2023, 1:15 p.m. UTC
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 <suzuki.poulose@arm.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
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(-)
Comments
On Mon, Oct 23, 2023 at 6:17 AM James Clark <james.clark@arm.com> wrote: > > 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 <suzuki.poulose@arm.com> > Signed-off-by: James Clark <james.clark@arm.com> Acked-by: Ian Rogers <irogers@google.com> Thanks, Ian > --- > > 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/tests/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 @@ > > glb_err=0 > > -cs_etm_dev_name() { > - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) > - trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) > - archhver=$((($trcdevarch >> 12) & 0xf)) > - archpart=$(($trcdevarch & 0xfff)) > - > - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then > - echo "ete" > - else > - echo "etm" > - fi > -} > - > skip_if_no_cs_etm_event() { > perf list | grep -q 'cs_etm//' && return 0 > > @@ -149,7 +136,9 @@ arm_cs_iterate_devices() { > > 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=`readlink -f $dev` > > # Find the ETM device belonging to which CPU > cpu=`cat $dev/cpu` > -- > 2.34.1 >
On Mon, Oct 23, 2023 at 02:15:49PM +0100, James Clark wrote: > 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 <suzuki.poulose@arm.com> > Signed-off-by: James Clark <james.clark@arm.com> Looks good to me. And I did a test for it: Tested-by: Leo Yan <leo.yan@linaro.org>
On Mon, 23 Oct 2023 14:15:49 +0100, James Clark wrote: > 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 > > [...] Applied to perf-tools-next, thanks!
diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/tests/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 @@ glb_err=0 -cs_etm_dev_name() { - cs_etm_path=$(find /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit) - trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch) - archhver=$((($trcdevarch >> 12) & 0xf)) - archpart=$(($trcdevarch & 0xfff)) - - if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then - echo "ete" - else - echo "etm" - fi -} - skip_if_no_cs_etm_event() { perf list | grep -q 'cs_etm//' && return 0 @@ -149,7 +136,9 @@ arm_cs_iterate_devices() { 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=`readlink -f $dev` # Find the ETM device belonging to which CPU cpu=`cat $dev/cpu`