From patchwork Wed Sep 25 14:13:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13812042 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 A7DB0CF9C71 for ; Wed, 25 Sep 2024 14:24: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=ODdlKFq2yo+wpxcR2RtzNa0ArGaQotdno3xb1lEd+xc=; b=ux2RqGRQvXXGc6JFNKDTzMDmM7 Gi4cexMbwWZriO+pgP4dL5aM3KQjHoESnN3Bx+gGzSL53ThqhuPkkMB4Ve+ykLgIhaucMS2qiuk+1 KvP+x/HBjwW0PVe9lOBOH3pKX+wizDXgcJKwUjm58cHKawDR3tvdOZj68vPFfqyL/anKramCf07tq +b4W9trbnCE/ehSv//bo2f6qjgR6SIJPjNZfeKsvXUxN7vjFxtwIgcoY7joYB43dBz2OBFN4ydTsk p4d41plooowjsDEllMZ8xq9qAVdD6HAWzeDFScNlCBer3t4lYbtcC5XoPefWOKrdYmkc4dJL7LNX7 RNcg/hIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stSwK-00000005bzE-07dJ; Wed, 25 Sep 2024 14:24:24 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stSod-00000005Zr6-2XnH for linux-arm-kernel@lists.infradead.org; Wed, 25 Sep 2024 14:16:29 +0000 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5c241feb80dso1896549a12.0 for ; Wed, 25 Sep 2024 07:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727273785; x=1727878585; 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=Zw2Qr+1odyAmq/rC//Yj1VPxET/bu6kjBC45RGKWJu61ViwM4bPsqpnlNe9sas0mYF R73xREyCAnU8afwVchMFCXcKZ4/6vXXQsFr1zM1sbxF2Lw/r5Ycma2Jtyab2eM9gyx/R toEpCFuq0WxbO4aUxnclqYZnTKneEq+4F054OrI+LwL8NkvZGd2WE0tKpBydpyN6Gj20 Wdco2akyL1QNTu6iu5F7ELrBnyK8TLYGGjZ8wVhkTpPZzYKSsAnB+W84Tuh3MuO80TRE NHBegIi7b/B0gZwinDRiWyopxYrU/rkvoQob4W46pikP0VI1hcBqgdzOKwAIpjC225tV 1Q0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727273785; x=1727878585; 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=Rm+hK4cpdifmrjIsEVHUEUmxQk6378tIXnpbFz9D/dCnLvRyvM3kKtTDP2ShdAiUsh 3rK73CewnNQHyOPceW6xQXOTE4z3vbsfSE4TZjjGiJcSHL/F4BuuNw283ou1RPCRa/Nl +BOkYvR31vZj8BV1mbLJTvgqhssz8/N1Emad6nIFvfrfh2sCM1Qn7bS5p0eUlklV49YU Oidvvdd9VOMdHXOJ1atVeYOhKeTDbpTME8cdsbStQJwznRjrY5iPO+aDPJeotgRU2zfW OD5jAAkUyp3habPrbESFK5ChLyDbMu66ZlmNshWymX62efN9LfqP3VZIsVBi4fTHcSX1 xwUQ== X-Forwarded-Encrypted: i=1; AJvYcCXuIore59124UtaeDOImRXca7KqCYAe1w1orHsVth/Dta3WMZkb4+G5+OLlC9EuZu1EhnpIEVO5V4fJy/nV4TWl@lists.infradead.org X-Gm-Message-State: AOJu0YyyS5jMEqgifjxAP1xkUIxqRBBor9kMmc8LeAJv87g3exRyNBT9 wUCkj03sPn2hLURCzrpTybBf0VxFd5zUueu2213Wu2nbzrv9AxboUy3XyeyRV3w= X-Google-Smtp-Source: AGHT+IG2TxNwhu+N9jupV3mIiqoC9ylXfNDjHqjjJvslXkqzozyl4LotdvwzRG2eQ43GgUpz5d3ZJw== X-Received: by 2002:a05:6402:35c4:b0:5c3:d8fb:df6a with SMTP id 4fb4d7f45d1cf-5c720a2e8d8mr3371349a12.14.1727273785455; Wed, 25 Sep 2024 07:16:25 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c5cf4968f4sm1888005a12.27.2024.09.25.07.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 07:16:24 -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 , Colin Ian King , Yang Jihong , Yang Li , Athira Rajeev , 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 v8 7/7] perf test: Add a test for default perf stat command Date: Wed, 25 Sep 2024 15:13:45 +0100 Message-Id: <20240925141357.1033087-8-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240925141357.1033087-1-james.clark@linaro.org> References: <20240925141357.1033087-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-20240925_071627_656857_7BBEFCEA X-CRM114-Status: GOOD ( 14.39 ) 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