From patchwork Thu Sep 26 14:48:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13813441 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 88FA5CDE00F for ; Thu, 26 Sep 2024 14:59:11 +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=ODdlKFq2yo+wpxcR2RtzNa0ArGaQotdno3xb1lEd+xc=; b=VLX0EP1Vdwvhs9XC8FKGhhzeTH Csx0T+yYBhtz6UyCTvh5O8nGtQWKZDzm9sa4djK579tNe5C1b8+1z+DRoOV7GvDSQYUVZXkGmyro9 ovRUqD0PxcOzEHkCSqt0QOgqhC4y+6vxe9WGBS73DafajYeF46lHCJulLZhJHRQi5au8IXGQRqXla V9PRZqQDV2dG/B4CnlIoRyM+rc12vdYby+xn2XFlNyuZ987KU1gl++2GzNdoK9IOLmbBe7q+FcXdq ur1lztjdXMXazMqfNbRoDFokSwuFv7nlg1gjuFnnW3A4bvk73FJSOvaEWOVrV/of3NlOnV3xtIO39 y9VCcl7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stpxM-00000008g6l-1DSj; Thu, 26 Sep 2024 14:59:00 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stppO-00000008ecS-2WQ6 for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 14:50:48 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a8d56155f51so129865166b.2 for ; Thu, 26 Sep 2024 07:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727362245; x=1727967045; 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=ODdlKFq2yo+wpxcR2RtzNa0ArGaQotdno3xb1lEd+xc=; b=LJYaG4KJe+932pDvYJuGtUEvIRU6HXGRd5a0oC06t/l/EZnCv6GZGaLVgjTT0s2uS5 hGIdBEGsTj+HiH0ii9iyl5SD3iWRW6AFTZKtWtce76P64MSzsJIOH4VW0H6IJJBBvHLI gT3ewKhCnl+yjwWRwtZELB9eHp2fL5Ffv4yNpfD6vqwyhqvVIbhA0wQU7mqzeiJvzGF/ MglVITlPxm9ABAmTbNnDWq1BbndcQcttprVR8Xpjxy5sLFFQczP8Yi+5Us8c849IH2/O OaEpJr/kR3m2DVLRUlah441X+QtDRjz5B+2awLhQXhDmWWwL/xWa3NBRHAkDXYGO9lcx LTrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727362245; x=1727967045; 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=ODdlKFq2yo+wpxcR2RtzNa0ArGaQotdno3xb1lEd+xc=; b=JKpCTOBykKjvl0/JsigsWh0DpPqIWzThj2BLp7DQyH4OegSlRORehlKGeAYdE+SPe1 Dgtv2193/VZ21ioxFZ167UnoAgPkS1An9L5eKXKiBNpRrj7vprwUuIDBASFfRHWopuGc m9ZINNsf5IXSqDXXeWv45qCIbYIUaeU6M+YdiHNBkFjv5KHYglOXVR0nDtsxibN+AyQu rfTkT2Jww4xUhZTCuT1Bcv140/rep6ayrCEE3jr9i//dmRklGkjW5X+Zo+JpglF2+8p+ NvOwS8tBUO7gF2XoKP4xoezL62yxEhc+g5230L+sbYsf+SByzQrKYYHFvwO9XUgJYNw6 HFpg== X-Forwarded-Encrypted: i=1; AJvYcCWI723x8kcULU4EO/YwrlKQNqQt4kGAYVu80WDUluPMgSEbhHU7GQpTq5EQpe4TvHh4IbY7zooOYXRIfqr4y0Hs@lists.infradead.org X-Gm-Message-State: AOJu0YyBnEbDb5Hz3JZ5tvefpusEWkXbdkUKJkxQGgv982Ej2c6aMxTu Aq+1PxV2a3CyJV2zI1FNEsbtHMxPogI/yO56NwAiMfh1+tiWfpJQkwnpbjDKstM= X-Google-Smtp-Source: AGHT+IGmU9ciHKtvpxRtVIFD3I+x+IdqvRKKSQEPHUiKVg12Y1sJLmKKKX1VujHonF3Ic/bxX9np9w== X-Received: by 2002:a17:906:f58e:b0:a7a:97ca:3059 with SMTP id a640c23a62f3a-a93a03f4a83mr522030066b.34.1727362245093; Thu, 26 Sep 2024 07:50:45 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c294833asm5589966b.98.2024.09.26.07.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:50:44 -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 , Yang Li , Athira Rajeev , Colin Ian King , Yang Jihong , Howard Chu , Ze Gao , Yanteng Si , Sun Haiyong , Jing Zhang , Yicong Yang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 7/7] perf test: Add a test for default perf stat command Date: Thu, 26 Sep 2024 15:48:38 +0100 Message-Id: <20240926144851.245903-8-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926144851.245903-1-james.clark@linaro.org> References: <20240926144851.245903-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-20240926_075046_673266_0B3381AC X-CRM114-Status: GOOD ( 13.94 ) 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. Acked-by: Namhyung Kim Acked-by: Kan Liang 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