From nobody Sun Apr 5 16:28:27 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A709369981 for ; Mon, 23 Mar 2026 20:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774297455; cv=none; b=RCRCrv1MdbZxs9ZoMonET9opNjjeZjrb5mv91CwDiS9lGGKAEXywTucVYGmqdLgu7e/iykcnDxYv3yjtZWFGit1W9b68q5DFqC1gJ2zKcwEr7tyYiVPuX2uJIsOg+Dz3YL2jP/OIDh5I993ufcAlJZNoOOhmNR62wsKOZWCZJ3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774297455; c=relaxed/simple; bh=X8gFJpfagRDCL4PplhNHhmcJxYbTuG4VUhA+lAQFQdE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YKR/Eren9KvNS2IHiL2rpzb/b1UfuGoThHjNEgJbgGR6YByPN5r++or9ey3xmJJn3omhyuSsdG+RXk8OQuH2UEm98PZXn7l5C7MbB42lxZCvaNdL5DVkrjisu130Za31t1G2xBJ0ZznRU9yVoc99zxQwNpSJlrC45IaVZr3AIKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=M2xANuM/; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="M2xANuM/" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-128edc72e5bso6377011c88.1 for ; Mon, 23 Mar 2026 13:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774297453; x=1774902253; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dLDd1xOv31Pm+FHVm56FRbOcRw38zRd0ih5wpwcouGs=; b=M2xANuM/lhThL+CMhliN7wAOcQ1KiUwsiYs0BdZoEfGdYlX6Y3JulhK+ibExRYMUh7 IldQ72g9TIvq6eLduZpLTwFWmxT3fR3thGQFHMPHwBNet+Be77/bmN08a1pdOmPN14Ws nO58vBv4NTQ1djnpJBs0GChz6pgvNjjW1sXZiRP4fu9pCp5K9mRg+OWRldlx63yfltO0 HOC6cJsB28if46FcNqnNFtw0VQ4sNZ8tsgWAGHbBI7mWlWmN8cJ7d0RERke5VbzL9qUF kpTQjcHsM58qeAHzhLGbXGsYlcPhc4TmPI5gKsXCyE4DypGkWfRwAvJPac2xZ61LROa2 YAiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774297453; x=1774902253; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dLDd1xOv31Pm+FHVm56FRbOcRw38zRd0ih5wpwcouGs=; b=HqCfYs5m2YON0f9rKziaTxxxVQ+V1B1oKFpVAfzXocArwVxzhkkTj//uAad1vsrThp PaqHj0adVP41pEXc8z7nf0JPK7dwmUFp73CdBhRc71jq973WNsBGCqdbFDClWUZq7D0g qKUGiDlXRYt9PwrCMA8ys/hmaL8Rz+wz59UsVZdpNZTiHjtTkMDFNYCRgBnwdMl6IdyP cjctJvlrdBGYDpOcDGoQGFuvG1bDsVL32SWHwEayL+gy3JwA8sZQqErGb2GPzZyg8lyp eUHFqGP0YQXu3c+OgtbKJlHIrM20ID8/k9vrGKsYWgFp/OqL6RvqP//0P6hRYIOJs6uS 09Bw== X-Forwarded-Encrypted: i=1; AJvYcCVAHjHn7d6/ZGpsdmc0IAsGSsRnuDNiAD/80fWt9bD2JGW8UpKtb8q7oddOhiXgJ4ufqNG819sp7TI/X+8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz++8Aw2VaJBdU2kBG9GmFYO8Vucxz1jPtOs8niSoDLEf+KhKhv Bmb1+B/0u6Ch/KGdK+H9l/DYrgN07GBmZdaOWVViVL7Ndu45VMM6Yrz8aaUvR3qQY5NnJ3xIFcM p1S90sczZFA== X-Received: from dlec14-n2.prod.google.com ([2002:a05:701b:428e:20b0:128:dcb1:bc27]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:c95:b0:12a:7f25:44ed with SMTP id a92af1059eb24-12a7f2546bfmr2495819c88.40.1774297452921; Mon, 23 Mar 2026 13:24:12 -0700 (PDT) Date: Mon, 23 Mar 2026 13:24:09 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.53.0.1018.g2bb0e51243-goog Message-ID: <20260323202409.194123-1-irogers@google.com> Subject: [RFC PATCH v1] perf test: Fix perf stat --bpf-counters on hybrid machines From: Ian Rogers To: irogers@google.com Cc: acme@kernel.org, adrian.hunter@intel.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@kernel.org, namhyung@kernel.org, peterz@infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Events on hardware PMUs may open on >1 hardware PMU on hybrid machines. Unfortunately multiplexing introduces a scaling issue as reported in: https://lore.kernel.org/lkml/20250716223924.825772-1-irogers@google.com/ Switch to using task-clock which as a software event runs on all CPUs and has a single PMU. Signed-off-by: Ian Rogers Acked-by: Namhyung Kim --- tools/perf/tests/shell/stat_bpf_counters.sh | 35 +++++++++++---------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tools/perf/tests/shell/stat_bpf_counters.sh b/tools/perf/tests= /shell/stat_bpf_counters.sh index f43e28a136d3..58f7dc9692ac 100755 --- a/tools/perf/tests/shell/stat_bpf_counters.sh +++ b/tools/perf/tests/shell/stat_bpf_counters.sh @@ -5,6 +5,7 @@ set -e =20 workload=3D"perf test -w sqrtloop" +event=3Dtask-clock =20 # check whether $2 is within +/- 20% of $1 compare_number() @@ -25,15 +26,15 @@ compare_number() =20 check_counts() { - base_instructions=3D$1 - bpf_instructions=3D$2 + base_count=3D$(echo "$1"|sed -e 's/[^0-9]*\([0-9]*\).*/\1/') + bpf_count=3D$(echo "$2"|sed -e 's/[^0-9]*\([0-9]*\).*/\1/') =20 - if [ "$base_instructions" =3D "&1 | awk '/instructions/ {print $1}') - bpf_instructions=3D$(perf stat --no-big-num --bpf-counters -e instruction= s -- $workload 2>&1 | awk '/instructions/ {print $1}') - check_counts $base_instructions $bpf_instructions - compare_number $base_instructions $bpf_instructions + base_count=3D$(perf stat --no-big-num -e "$event" -- $workload 2>&1 | awk= "/$event/ {print \$1}") + bpf_count=3D$(perf stat --no-big-num --bpf-counters -e "$event" -- $workl= oad 2>&1 | awk "/$event/ {print \$1}") + check_counts "$base_count" "$bpf_count" + compare_number "$base_count" "$bpf_count" echo "[Success]" } =20 test_bpf_modifier() { printf "Testing bpf event modifier " - stat_output=3D$(perf stat --no-big-num -e instructions/name=3Dbase_instru= ctions/,instructions/name=3Dbpf_instructions/b -- $workload 2>&1) - base_instructions=3D$(echo "$stat_output"| awk '/base_instructions/ {prin= t $1}') - bpf_instructions=3D$(echo "$stat_output"| awk '/bpf_instructions/ {print = $1}') - check_counts $base_instructions $bpf_instructions - compare_number $base_instructions $bpf_instructions + stat_output=3D$(perf stat --no-big-num -e "$event/name=3Dbase_$event/,$ev= ent/name=3Dbpf_$event/b" -- $workload 2>&1) + base_count=3D$(echo "$stat_output"| awk "/base_$event/ {print \$1}") + bpf_count=3D$(echo "$stat_output"| awk "/bpf_$event/ {print \$1}") + check_counts "$base_count" "$bpf_count" + compare_number "$base_count" "$bpf_count" echo "[Success]" } =20 # skip if --bpf-counters is not supported -if ! perf stat -e instructions --bpf-counters true > /dev/null 2>&1; then +if ! perf stat -e $event --bpf-counters true > /dev/null 2>&1; then if [ "$1" =3D "-v" ]; then echo "Skipping: --bpf-counters not supported" - perf --no-pager stat -e instructions --bpf-counters true || true + perf --no-pager stat -e $event --bpf-counters true || true fi exit 2 fi --=20 2.53.0.1018.g2bb0e51243-goog