From patchwork Tue Sep 3 10:19:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13788484 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 E274FCD13CF for ; Tue, 3 Sep 2024 10:28:33 +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: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VJKJCBpUvVPcGAEYnax2qcSOD0MR4G3nPcSezle+qU4=; b=ED6c8BnYzSonU1cXi1QU2UnO+b 9dptQ5g+g8qEiF6Ili30XRpxXCezvhtzg8hxOFWZ+jv75Kzjd94dwTnfLaMwm47xqvzSruMrZhgL7 2GyYXcFXEur6ckd6gv9p9JTl5fygC46Y9DTV8pYEF0RYd/1bOgzRRY7boVIo7WMifgqUPmFtHXacC zfrCDlJ7ziqACPWN8hX/sKVsk+HQSLsyw4naQfhf5QAwvizUGCpA3+JCOfdK9EyL6oZUHTqx0OLfz 8yt+dhQgng2SQyfZvZFjzb+fOLVdjwTfLrVd6AwrqrsDefVUESdW+P805KFiCWf4Srpju2QtqH6TZ YcX7Gocg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slQlt-0000000HLFX-1haV; Tue, 03 Sep 2024 10:28:25 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slQfw-0000000HKBZ-2LON for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2024 10:22:18 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42bbe908380so31051085e9.2 for ; Tue, 03 Sep 2024 03:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725358935; x=1725963735; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VJKJCBpUvVPcGAEYnax2qcSOD0MR4G3nPcSezle+qU4=; b=rQCIfM+oYmcRSq2yceQ4G2ml/q2N4ZDFUFkvrZlX/752XJBPdSgMMGNEzrV+8eAxdq URKcaXY+czr3iiF4hjEzBYuECt2DeKRMAED3o6OzGVLSTJuIOBR2um721rrq7cKF0Z0g 9PA1MEXERWH8xsASTUvbTSsZ5e10K4YkgArkuPg+RTIFY+WsfeUTr34UQ5emlnH62fCQ JXsGAUSaTzqJ+YCki/QQh2Nzg2RksBJBWCOMAKJl55Xa9WG4xK6snzvbYAqnuerJBCkE d/n3dsQgH61Dk6zJ6BPibo/1zZeL/EJwZ4M59xpHYxCYTOOLW7qQrxHlJq4P2OZTo8RI 2oyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725358935; x=1725963735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VJKJCBpUvVPcGAEYnax2qcSOD0MR4G3nPcSezle+qU4=; b=KQfTGMqR1bK2okc1GpAx7QHAq09uqCBQwfiMTy4ZUmqLzVGKM0VEULeS/jmmnkClj1 LU02gMMX7GwSzuM7xDQuCOUV6sDwfqX/ltINjdH6Dh1EjLEEhr6mxgl1S4pvIDVMEp/o saSYOmBOrlkICMNYD8SgwyL3qoCMO/Xn8PVR3P4j+p7uKNyiNGMuWm/6m4ff8TqcpxC+ rIKyvWHYO5anJz+BeO6yyb69PjRh+7zLV+GI5uI4t/+JutTDoyezZwuMTs21vS3JiRVA PbbtyjwRWb0xdhn8P1I3hmrOMu6m+17jaulmlJN6XO+TMOPJAb12ke3JZA5kHa6YrLhe vRBw== X-Forwarded-Encrypted: i=1; AJvYcCXFUvdpDy66ISswNQi1d2jXOnWidZiR6/+uKBkplqv8FVJ73eTVXxaqI1n8KwRHozz9I7G17d6hiOdmUDIJ0EP6@lists.infradead.org X-Gm-Message-State: AOJu0Yy2n+USPP4Ds1NP7QWatPhuHPmu1ssU2aIx+699RUo8gFs6v1F0 aTI5HnX58BZIS7HmSzmoEodo2Iay0/3dBtwJ6XpPWN0GJDnQtYmPnMd3wDgMvEg= X-Google-Smtp-Source: AGHT+IFgSoyyOtImdhFvpIkfkxAvYNeSg4DDCvj9dTZ/CYpAWzZrXxUx8ASLwX+TMI1prEH2Ay5XJA== X-Received: by 2002:a05:600c:3b1b:b0:42a:a6d2:328b with SMTP id 5b1f17b1804b1-42bdc64e691mr64706745e9.30.1725358934675; Tue, 03 Sep 2024 03:22:14 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6e274ccsm168739995e9.37.2024.09.03.03.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 03:22:14 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org, kan.liang@linux.intel.com, ak@linux.intel.com, namhyung@kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Weilin Wang , Dominique Martinet , Athira Rajeev , Colin Ian King , Yang Jihong , Howard Chu , Ze Gao , Yunseong Kim , Sun Haiyong , Jing Zhang , Yicong Yang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 7/7] perf test: Add a test for default perf stat command Date: Tue, 3 Sep 2024 11:19:51 +0100 Message-Id: <20240903102005.78049-8-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903102005.78049-1-james.clark@linaro.org> References: <20240903102005.78049-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_032216_664761_C704C526 X-CRM114-Status: GOOD ( 14.74 ) 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 Test that one cycles event is opened for each core PMU when "perf stat" is run without arguments. The event line can either be output as "pmu/cycles/" or just "cycles" if there is only one PMU. Include 2 spaces for padding in the one PMU case to avoid matching when the word cycles is included in metric descriptions. Signed-off-by: James Clark --- tools/perf/tests/shell/stat.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh index 525d0c44fdc6..5a2ca2bcf94d 100755 --- a/tools/perf/tests/shell/stat.sh +++ b/tools/perf/tests/shell/stat.sh @@ -148,6 +148,30 @@ test_cputype() { echo "cputype test [Success]" } +test_hybrid() { + # Test the default stat command on hybrid devices opens one cycles event for + # each CPU type. + echo "hybrid test" + + # Count the number of core PMUs, assume minimum of 1 + pmus=$(ls /sys/bus/event_source/devices/*/cpus 2>/dev/null | wc -l) + if [ "$pmus" -lt 1 ] + then + pmus=1 + fi + + # Run default Perf stat + cycles_events=$(perf stat -- true 2>&1 | grep -E "/cycles/| cycles " | wc -l) + + if [ "$pmus" -ne "$cycles_events" ] + then + echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]" + err=1 + return + fi + echo "hybrid test [Success]" +} + test_default_stat test_stat_record_report test_stat_record_script @@ -155,4 +179,5 @@ test_stat_repeat_weak_groups test_topdown_groups test_topdown_weak_groups test_cputype +test_hybrid exit $err