From patchwork Tue Sep 10 15:16:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13798802 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 E8272EDE99D for ; Tue, 10 Sep 2024 15:27:24 +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=gzYejL55jw2kalTO5A0DRq7hhLyM8T3G+Vfejwo9sVk=; b=xhqxJ+W+5JEzUH0TT8ReO72qCJ O0vf82q3z/vtzZmWng0DjjR0IA8j7ZZlZLfNS1nTwj6ED+FzYxnC6Y0e/sUj1x5q6U6eih/C8UM0S qrkgDdY9r6d7BCgETOKivWQUyTM1/Ri64ERGvF4Z2L1jVBF1mK2f0b3bAH0kh+EolFPjaKmLYC+LF YYqJsAFbU0E/iReS79ylKFkLMzCWrqjqrO3NbxW9vddcIvuV6kAJXd4bXhKj6VllRlqUTGrGT+Vb7 BbYGq/o8bECCmnF1AjCD6BWUcWSbwrYElDZGY8qMM8RCQv+YKfDlh5lk1UiJ0Pr2NqM2tYAAsaTQr bYH0aKpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1so2lv-000000066hv-3uhg; Tue, 10 Sep 2024 15:27:15 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1so2du-0000000638j-2Bqj for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 15:19:00 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-37747c1d928so3558446f8f.1 for ; Tue, 10 Sep 2024 08:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725981536; x=1726586336; 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=gzYejL55jw2kalTO5A0DRq7hhLyM8T3G+Vfejwo9sVk=; b=pX+BX/vqKSq2ud4LxuQmkpr8AE33vH9GZQRLQm5JpQha0az0MI6Y4paseRBiSeR7aI tl+o+RQtH3ZoWq0YT68nIX7c2kPbLhI7wpJ/1DIrruebSILkx5/MHfi0ygK56t82BRhB kD22Z4dTNPspyg5W6s/33dgGOtw812ubhmpjAw+5DeY+z2Bmdb4rO/0LIcd7Tjd0GDdG mgBmFk7fWpvhuPq6UCLF7ydkRxwP7AbWNDHzRa/vYC6PwFV6Hz+edVtwrIO6ZI9RlZuM zbO1MQRTxhxz82XRK/fNqEK1NCm8UgJkIRhOk4ImWeEcqaoW1MlCYT+X33wZ6Ln2M8xr A/Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725981536; x=1726586336; 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=gzYejL55jw2kalTO5A0DRq7hhLyM8T3G+Vfejwo9sVk=; b=eZfplilkfHxBhzHeFlUAILzzs0OUJ3WUjhmhvZIyvPtlnfYkeJdkK/jQS/pm02ggik JYgCbPJuFGO2yFEhhSPTrYGorpxjKvHIG2ORl/eGPu5mUEECCY5n7egD86Ju8jjru/Rt lJoeG0RuDHXPRNvl1QQtLKj7K/l43MLFCwNorAsmc+rfLTEb1IiwhM7X/qJX/WyZZ8xe eVgloR3RQD/FWMxBNFbci3hmTgJkb0xUazEgVYKoq/Yrko/xiZCxgyq6s0QHbhuRq8xI PgDXlbYB4gMOZJfvMunijXToBw6Dh+GbOnuKNIZxEFZRDIanvBZTtnCupsv5aGXB/7VJ 6zqA== X-Forwarded-Encrypted: i=1; AJvYcCUzlP2EuEkb5RVrOKYSXurNkZ/dcowfRsXvOKIP3XO0h8DItuYmqwMp9wSJft5NsBhgEYjGbktOiv3fktxW1AG+@lists.infradead.org X-Gm-Message-State: AOJu0YzcKdVNXjJGG/wLkxDMIY3hCENk2fNgKzDnfeKbsFr/1PJEFufo twzzalX44da8yZppPvx5/HnjbEgxRpHH1FZE3OoTBgh3Re12LeDR+dqjDfVMj5s= X-Google-Smtp-Source: AGHT+IHy/RhwX57CcCqc82tipU7Ic/6+Q/to0vq5e7VGq8SEkdeQH7tu0qUqClXsdQ0xyoyauIPQiA== X-Received: by 2002:a05:6000:d05:b0:374:b399:ad6e with SMTP id ffacd0b85a97d-378895f20damr9927699f8f.35.1725981536253; Tue, 10 Sep 2024 08:18:56 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895665517sm9440844f8f.36.2024.09.10.08.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 08:18:55 -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 , Athira Rajeev , Dominique Martinet , Yang Jihong , Colin Ian King , Howard Chu , Ze Gao , Yanteng Si , Jing Zhang , Sun Haiyong , Yicong Yang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 7/7] perf test: Add a test for default perf stat command Date: Tue, 10 Sep 2024 16:16:25 +0100 Message-Id: <20240910151640.907359-8-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910151640.907359-1-james.clark@linaro.org> References: <20240910151640.907359-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-20240910_081858_589875_E142D589 X-CRM114-Status: GOOD ( 14.66 ) 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 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