From patchwork Tue Nov 7 17:44:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 162685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp398360vqo; Tue, 7 Nov 2023 09:44:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8+8BEZpl4ul8jPfGehK9Suxjn6m/2KtNxa80R2lebvndDGBWfOFVGgVd64WYaEAPoXwWC X-Received: by 2002:a17:903:2283:b0:1cc:6f51:b166 with SMTP id b3-20020a170903228300b001cc6f51b166mr21297940plh.65.1699379058971; Tue, 07 Nov 2023 09:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699379058; cv=none; d=google.com; s=arc-20160816; b=zPfmB5y8HnXJ819lBJVukygEjG/4EJaOOK5v8bikvmdNTfwuM1S0bS/n7ONkxN7o7v 1M+swAWd2VjWO7ivOt3kj4CJFcyYv7s5IbX4ko1OQC842TXTgcOmV9i1J0/nKrSaqRxC MWlcMLigoP/QmTMwZhcOjCex5zosNuVRI/LQuYrcg8dsGBeAGYil+kOTLy9aDZETBeat ej+aO1iAId5wPaO9lT5v5ujfgXxrHiXk29QpEpBk5jFk32yqDfBgx3qs/wR01A+85APe Kk2V4OYa9LIrGDWrGJ3ugT4lVZl2aZwWCKSa5AM4cYKL9VLqYYc6eUIqCVjupxyE5EzV DIlw== 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:dkim-signature; bh=nBT4Qn3ykdPyLHYFfj/KO2zDj7sem85B3Ml/EzGwGB4=; fh=XESocjTH1UvQGryUR/ShQ0tppVSp72e0RCZuf7dmCo8=; b=iy38vtNBdb/2M4GJVdF+mpXUxUhnGyR6slO2Czu0g46hChAgqvFDJsjccpVv4rq28S M8qtc2okqkHkXJCakjrxA5q0kGg6yZ+zwmljKfOiVdK9i+1bhR52JuHw/yvd1fxiIHVX iITEIADgo/9vTtQd+bXGGKBQQr3ia8rItJfPW+FX16Her0vAbIuyOIvTHXtfN9vIfa/N 8r5irQV7urG4JrDnpqJMBnh7I4mfIomZvY5x4C65LOxVvOHMfLeFFcr72pMuKhIqB0RT 7C8sEnaQia1LkDwa6z4YyqapOv5cXz6Ld7jgZmkZKTQEW5E17k2C48ODysz702a8DPHI fWLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ZMgK+n/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z20-20020a170903409400b001cc2293b5e0si216647plc.96.2023.11.07.09.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 09:44:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ZMgK+n/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0D1AA82881A5; Tue, 7 Nov 2023 09:44:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234554AbjKGRoO (ORCPT + 32 others); Tue, 7 Nov 2023 12:44:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbjKGRoN (ORCPT ); Tue, 7 Nov 2023 12:44:13 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B31C9120; Tue, 7 Nov 2023 09:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699379051; x=1730915051; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=8APqL6kLTnsH4eX3AVkSK73CanFIhsaw4KsKL+yc3Tc=; b=ZMgK+n/taLFSM6pDCU/M/N/jcgeXwXD+G9rn/42Z0uBeE69MoVRtP3UU QmiaifDF8Cf9XwXUtTeiZWBS+kbj76d9EGUT6U9QJT/vRTKRxjnK3hMJn nrj1V5GfdzvY3I8kCddhjiEIdSBlSPp60cGc8EJprfN8Il1yQas3WPvny 63mwWY2Qpm/GvM0eN1YwJGjLriWKmt/nZrsm50i0FTvnyzVoyH+ySPC0E m6bczo2+rsC9ES/tyNDcyH2BiP8Acj1JvUZcHulPmWOkZpZU7p6XBE6vG fwy4pFMf7BsbPSm8T9rUPjYiUUlFKL0hCsbc5CwHZpi5vEhFWM8HxD8v0 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="393468640" X-IronPort-AV: E=Sophos;i="6.03,284,1694761200"; d="scan'208";a="393468640" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2023 09:44:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="756271088" X-IronPort-AV: E=Sophos;i="6.03,284,1694761200"; d="scan'208";a="756271088" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orsmga007.jf.intel.com with ESMTP; 07 Nov 2023 09:44:10 -0800 From: kan.liang@linux.intel.com To: acme@kernel.org, irogers@google.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, jolsa@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, tinghao.zhang@intel.com, Kan Liang Subject: [PATCH] perf test: Basic branch counter support Date: Tue, 7 Nov 2023 09:44:11 -0800 Message-Id: <20231107174411.1496958-1-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 07 Nov 2023 09:44:18 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781928096356208297 X-GMAIL-MSGID: 1781928096356208297 From: Kan Liang Add a basic test for the branch counter feature. The test verifies that - The new filter can be successfully applied on the supported platforms. - The counter value can be outputted via the perf report -D Signed-off-by: Kan Liang --- tools/perf/tests/shell/record.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh index 4fbc74805d52..2783e867c07c 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -11,6 +11,9 @@ err=0 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) testprog="perf test -w thloop" testsym="test_loop" +cpu_pmu_dir="/sys/bus/event_source/devices/cpu*" +br_cntr_file="/caps/branch_counter_nr" +br_cntr_output="branch stack counters" cleanup() { rm -rf "${perfdata}" @@ -154,10 +157,37 @@ test_workload() { echo "Basic target workload test [Success]" } +test_branch_counter() { + echo "Basic branch counter test" + # Check if the branch counter feature is supported + for dir in $cpu_pmu_dir + do + if [ ! -e "$dir$br_cntr_file" ] + then + echo "Not support branch counter feature [Skipped]" + return + fi + done + if ! perf record -o "${perfdata}" -j any,counter ${testprog} 2> /dev/null + then + echo "Basic branch counter test [Failed record]" + err=1 + return + fi + if ! perf report -i "${perfdata}" -D -q | grep -q "$br_cntr_output" + then + echo "Basic branch record test [Failed missing output]" + err=1 + return + fi + echo "Basic branch counter test [Success]" +} + test_per_thread test_register_capture test_system_wide test_workload +test_branch_counter cleanup exit $err