From nobody Mon Feb 9 10:26:51 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 C735F748D for ; Mon, 27 Jan 2025 21:17:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738012666; cv=none; b=RxeH6UvWAQYzC6icm70ULGdQDsCf4Oybl/YurI8Ghl+QW2Bp2qszOmi5fRvUWl8UW3AOXm/MxrnRSwe0Qc8UPI+ZARaloKQsrCI/brqkiktximxHJFvhj6/O1RZV8TX3hqwRm2RVBfGj/qRAHmZR7uPmbPnCvg8irU4ZMPYGd2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738012666; c=relaxed/simple; bh=/BUu3mEM3rCKji5mZxUeA/2/5w1poUKM7wvA/jnX+ao=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=Gn3momTND7laF3OpOkAijIoYqbLjCMgIs4pA5x8n4Xb+2Wocn1fv1ZaN5aCRxrhzDbAbP6mQRqQvYdEE+bJhutZWUMQ9MqTEh4yZKxn97FRzxvIK3KRHmD2LQ6ysBrX2IQToWesetjKC8y9buTw54oghxUwYbG7xnm81o3R6ng0= 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=SrhJ7eiu; arc=none smtp.client-ip=209.85.219.201 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="SrhJ7eiu" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e575f472438so12232287276.1 for ; Mon, 27 Jan 2025 13:17:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738012663; x=1738617463; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=bP3LjJM2yqm7ZF1bzjxMchIFOPBg28Ep2NfICJoxEig=; b=SrhJ7eiuYWCO5+NlEPHJBPmlsvyrBq0CP2rJpzuMGP64OlFh9KRzRUruVoqK6ObCKq f//Lp13oRzWJ9e0GVOdOyk1GZILp7wmRcRsrPqjgKDebOJIe6q6i65hsYOKAYIcm+KkZ Pc/4lmFOpbTLz10DzDvDnKY/pvzD0VWJ6w52N0BVJCvKBIq5hMywl2X1mMUScN5mcHgu 4+nBLTwPOtYbc29uBXnMl0cvNEkjpsggtFeHQz+wuBguth/6fkLm0qDfsOqz/GLWoA9n Vrph3K2Moulrn77NJE6LEBojY6iO/C2P6iYMOZL5cdAIz9KfnfOMbWgQh2CT0nt5CbvB 9s6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738012663; x=1738617463; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bP3LjJM2yqm7ZF1bzjxMchIFOPBg28Ep2NfICJoxEig=; b=BH/eK7E0nFEAu/+TS3SCkSoDs5Nta5p2EwQ/GQ21grg8CWCjAJHrV6xm67uWSYZPRU rcKMHwcM2m9nITlrgc44FcHby20ERZVqlUAUxW4stXO4mZ5iKq5h+AUTn+PwxyJO8zeQ tzI3LKgKGWebKmAZ7QEw2xl6g9tMNlIv/ODBpFGdRRHEADnN0lMBYii1T55Agn8pKGhc 2eCUdokHVaC5TO5bz6q/szZOdLG5Lm8OYwsM971wZQrKJONTOXuvBa9X1nTlwNenNY2x 1SmyMVKivGtDYeVl181ZZ+wbd75M5s1UIBNTrBw+VsmUnrDWMFhkBMv05jPgUNs459Om Xayg== X-Forwarded-Encrypted: i=1; AJvYcCWkvHerNGEs8z9biJOTA3up9y/LsCGTMKhBSBWt/HUK85Z0S8F6HLOkyUDyHZ5SUjQYgEtWrHGnWqD3SaY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy8hEe5S5kquwTcoAplbACGMp8P827CEALk/EeQtWynXPB7UeRu Ek3tXHTPsWI4QI63FfcQwcw4G9QV6/WPCMvjIQxtLodoZtD1jos53gsfLVygzAewprjC8sBII1c 6jXFUKA== X-Google-Smtp-Source: AGHT+IFLyWZwAHPDf3bUMlxmeXS5Vi2qWI6NmUZnoCT3gdOdbk12QZL0AWwKmFqrPa3VVAeJiyPjXHBXSNKy X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:8343:7b31:63b1:a4be]) (user=irogers job=sendgmr) by 2002:a25:aab3:0:b0:e57:f577:5564 with SMTP id 3f1490d57ef6-e57f57756dbmr58057276.8.1738012662727; Mon, 27 Jan 2025 13:17:42 -0800 (PST) Date: Mon, 27 Jan 2025 13:17:37 -0800 Message-Id: <20250127211737.179059-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 v1] 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 --- .../perf/tests/shell/test_stat_intel_tpebs.sh | 35 +++++++++++-------- 1 file changed, 21 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..1b61b219cd2f 100755 --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh @@ -20,31 +20,38 @@ 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 stat -e "${event}:p" --record-tpebs -a sleep 0.01 +then + echo "Missing ${event} support" + 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}" --record-tpebs -a sleep 0.01 > "${stat_outp= ut}" 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 +64,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