From nobody Mon Feb 9 13:35:23 2026 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 CFC381ACEDF for ; Tue, 28 Jan 2025 04:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738039080; cv=none; b=JZbPdgi0SzDEt9cMNFxn7dOLLbJyvTUb5ON3W2Ohw4R91wWmSarw6C5ZUTfzpvtu5DjJ1jnzB7IlD6bB0QuB2h3Eox+3LDgbpIpjriqeQtVEjbWGPsv7lg8IOGNzfwjDxjQb2tqfkWO3m+2AsV7aBUAAFsyesJTHU8y5JRwGWZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738039080; c=relaxed/simple; bh=RXkm8/CBiETLLKlDEygxtOcVPiIRsx0Laqc6OH4KyyE=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=G+ImFiwEMy9eRz71i2RO9r9qerx2bXAf588PAD51D5er1IXsLthNnw54gE+kLrPBVGOYkrbt7BOh8R9UjWlc10YdTL+KA6sPFUWSeBvVJUMDs/Dp4eNL0669cAWCD/rWpsq4qvPdzdDlHM3cBgfIiQMNJmYnG5MY9M/XcBQa0r8= 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=TrqT4PHf; arc=none smtp.client-ip=209.85.219.202 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="TrqT4PHf" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e575f472438so12954946276.1 for ; Mon, 27 Jan 2025 20:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738039078; x=1738643878; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=IAZZQEeERPxR9fF5OUC/u0sdru3uMlWZB2AQi6BmOGw=; b=TrqT4PHfWM5o2pACW0rZvneOHQqM/ySF8ok4RztaN3hB9/uVYwcA0cIkf7taLhwDTI P+ngFggPiVDESCxG2ECbdQzvAJbZjPwO4Tzzc+Kcynp4o3wuloro1aJZP9NbBC0cKWX4 Bt7OFHkngLxSIfgnClLpb/eY5qM+LUy7G0RxUo0XNeHh2JdHCe0v4vGeNUiEEcSINepz F9XEwVKp4YDaktzBCFGOPdLaummDtY02JNgVeKXPwbrqzDiAxZSJpGl0YzqgN1aRY+7b Kku4mrEP6qyBXhHEYaoFaH/3adGGl/W+px3MwGahEp8HcLN4Jm9KaJs+gV2LYwl/4IVx bWtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738039078; x=1738643878; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=IAZZQEeERPxR9fF5OUC/u0sdru3uMlWZB2AQi6BmOGw=; b=Wsace4ccF7S8s2rBGoUVm3h4aVnGT3lYDxM9aeuD4IuaYvnGHx5K718TK3E5aNjJFe bPVfpDDO6n52/oVUQpn1vDXx9bCJ7bLgOOKUZYgK9gbbQMoRX0R5+7MDwjrDNF7dXODy CamNyCQt2pWotV102e+2l31BWPJQ3MeaTmtOXqs0N6n0TGA5wVNjdDvkmWTVu82z8xws p8Y3jU7EveufWAugfdyKROxXnV0B8pXAsq+tmrjNiK8TNbxm3gpT+YXrq8WR/0hDXsFO K2rIlz25jSuQehNQ8H1aLWbocgXsRRCOJK7PCt38M71i/Ax+Dwhz3IfQuIui0M2LocQu GQjw== X-Forwarded-Encrypted: i=1; AJvYcCVRZEJFRfqFrMUEeihMeSHBe0PIKiIN3jitauNnHfW2b9s48WDElbuARwbGgDIRAM2BoFcyRVVe+PrNNqk=@vger.kernel.org X-Gm-Message-State: AOJu0YzebaqSEurt/0CECvd4wNfo4RQb5T/I5TOPfJMH+tvUG/HpefKM 7V/SNu35F9LMp+EbOKYPURYE5jMbx3xE3lOs8rUTs2zbte8/HOHcR1IwJt2fzZsLUSmr3RGBaUv 5PHeiLA== X-Google-Smtp-Source: AGHT+IFm2nE0moPwnKm0+CpY1o4uTKWLwhVekmcD2YAVOHIT8V25GLGdN5U24VMCJMM5MPCgFo2eIBQulPga X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2b71:c18d:89c2:8713]) (user=irogers job=sendgmr) by 2002:a25:aab3:0:b0:e57:f577:5564 with SMTP id 3f1490d57ef6-e57f57756dbmr60744276.8.1738039077772; Mon, 27 Jan 2025 20:37:57 -0800 (PST) Date: Mon, 27 Jan 2025 20:37:39 -0800 Message-Id: <20250128043739.256305-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Subject: [PATCH v2] perf test: Skip Intel TPEBS under hypervisor From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Intel TPEBS test skips on non-Intel CPUs. On Intel CPUs under a hypervisor the cache-misses event may not be present. Skip the test under this condition. Refactor the output code to be placed in a file so that on a signal the file can be dumped. This was necessary to catch the issue above as the failing perf record command would fail without output. Signed-off-by: Ian Rogers --- v2: Fix lost :R and use :p with record as it is ignored by perf stat. --- .../perf/tests/shell/test_stat_intel_tpebs.sh | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/t= ests/shell/test_stat_intel_tpebs.sh index 695dcb93bb5e..a330ecdb7ba5 100755 --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh @@ -20,31 +20,39 @@ then exit 2 fi =20 +stat_output=3D$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX) + cleanup() { + rm -rf "${stat_output}" trap - EXIT TERM INT } =20 trap_cleanup() { echo "Unexpected signal in ${FUNCNAME[1]}" + cat "${stat_output}" cleanup exit 1 } trap trap_cleanup EXIT TERM INT =20 -# Use this event for testing because it should exist in all platforms -event=3Dcache-misses:R - -# Hybrid platforms output like "cpu_atom/cache-misses/R", rather than as a= bove -alt_name=3D/cache-misses/R +# Event to be used in tests +event=3Dcache-misses =20 -# Without this cmd option, default value or zero is returned -#echo "Testing without --record-tpebs" -#result=3D$(perf stat -e "$event" true 2>&1) -#[[ "$result" =3D~ $event || "$result" =3D~ $alt_name ]] || exit 1 +if ! perf record -e "${event}:p" -a -o /dev/null sleep 0.01 > "${stat_outp= ut}" 2>&1 +then + echo "Missing ${event} support" + cleanup + exit 2 +fi =20 test_with_record_tpebs() { echo "Testing with --record-tpebs" - result=3D$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1) + if ! perf stat -e "${event}:R" --record-tpebs -a sleep 0.01 > "${stat_ou= tput}" 2>&1 + then + echo "Testing with --record-tpebs [Failed perf stat]" + cat "${stat_output}" + exit 1 + fi =20 # Expected output: # $ perf stat --record-tpebs -e cache-misses:R -a sleep 0.01 @@ -57,16 +65,16 @@ test_with_record_tpebs() { # 0 cache-misses:R # # 0.013963299 seconds time elapsed - if [[ ! "$result" =3D~ "perf record" ]] + if ! grep "perf record" "${stat_output}" then echo "Testing with --record-tpebs [Failed missing perf record]" - echo "$result" + cat "${stat_output}" exit 1 fi - if [[ ! "$result" =3D~ $event && ! "$result" =3D~ $alt_name ]] + if ! grep "${event}:R" "${stat_output}" && ! grep "/${event}/R" "${stat_= output}" then echo "Testing with --record-tpebs [Failed missing event name]" - echo "$result" + cat "${stat_output}" exit 1 fi echo "Testing with --record-tpebs [Success]" --=20 2.48.1.262.g85cc9f2d1e-goog