From nobody Sat Feb 7 16:53:12 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 1F37A2DCBE0 for ; Wed, 3 Dec 2025 21:47:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764798446; cv=none; b=H7gzJsOyqeYyabPU2WiX0ocX+bKjDaO6ug3Ll4z3BmHzf4FlOo0+la35gfFvgCVkuOrAI+DHxsytb/UFJyd4LjajrJor29nECmzryFbny9b6GHEN7KaHGNjDlVJ1eAAnhHtFUlNiwHt5s/s1JVmaLUj5sMr+9m6onOGmarDoNAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764798446; c=relaxed/simple; bh=Gx3JjXPhyf4K31F1oSQwVaIDiiuTokaWZT2VKxSeKlU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=B5JbH0zwUg+0AtIT6FUF0jfWuF1SeuWjfRJruU50ztkZ2lLfxhrA20FMQEoR5tK/ELZPdbBBP+anmg4XlXu2dDHF5tgT668e54+ozGy1oewtolo4GYXsThj03gOISiSRLzZE7uqMPO/ACJxEEUsrhe9tcPx0FdfhGa+ZN2STMyI= 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=tI4GGQM0; arc=none smtp.client-ip=209.85.215.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="tI4GGQM0" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-bc240cdb249so195657a12.3 for ; Wed, 03 Dec 2025 13:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764798444; x=1765403244; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=cl5+8xbClVweIwNwbXuJK+Q4qhM9Nu7TLMnqmk8eKXk=; b=tI4GGQM0LcERqu5GoBHJmVW9dOAMYJtH0FhvLy5JyWyeQ2fBL8VOwXJke4RvjwyHfK JO5uuYnX5CWXvdk5BFsUlB04BQinqUY0ZRtX7bCR6GtYIM8gaLlekZFOwB/g7uFdwXKs ui0rxL3FwR1P1FbZ2Tu8BiEm+Zvmq0kIELovkXsd+k56LEyHF7GQLn7kNFcn/5BWfuwt VvH1u+sUEjH4dtj26rSDif1MKV9TaTV8GBRtEJDBG2LF7mJeZiNNsL27BbX/0mJHcqBB BF2EkXXi4iGn0XZXY3Re+JAv1dHMU3bAh1T6+TMQhWezmg1UAgZtLBnFSCkc15s5O5Jl HAlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764798444; x=1765403244; h=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=cl5+8xbClVweIwNwbXuJK+Q4qhM9Nu7TLMnqmk8eKXk=; b=LAz8pPF0MVkFWJ7B4S6QfHE9n8khlyEfmXWjsbfpWI/lOGgixlXDBEWqqA2q4E+lYd XLmVYMQg+gyPo5uxBfuMNkxaG7MBsjb7/UUSrPsCMIIskPD9+PyvKN16/HO67A0q4wrH H63Tz7iyO6LEYy8DpMl3gkrZmgGf31oOepCdHFpuW5MxU6jAIiFct0dbb1fHvuKM4LpK fQIZ8g1qCcCLIJwsI6oOXY2cz8Okk/+2WWpfl4OBxQVlEOIVxak7tu+WI78VpVD5J0ZS 8xiAMuXCgjMKgkY3PwbzlZLiRAgO29CfzxCTJnej7YILzIZk58Y0azh7g+YWwBNL0hTv 1DRw== X-Forwarded-Encrypted: i=1; AJvYcCUoo8ASk12Q1Tf3QXYFtvFE4UDwqpvyKoAKBU1qqD/ygm8xyNwnlq1NalxN44/nuHRPEzApCNLI8wghHNM=@vger.kernel.org X-Gm-Message-State: AOJu0YyXas0/9D4thkHi3dXFKCijdDJNGesrqxkz1E2IWa3mNR4k0oXc XpSVIi1dU+deNAI05NKrClDZ1IvTEmOxsU1iUHrDuzM26SRwMtJEZL9wLQjTQHARy2EaDDopdQW lnvdVltAuMg== X-Google-Smtp-Source: AGHT+IHoOO93hzmFFlcQIYCbtgZj5ffz/3Wxhh2XCDCoisunfP+n6KCvgGin6yHxpV1LaAnMC1gvdiILhBSD X-Received: from dlbpk8.prod.google.com ([2002:a05:7022:3848:b0:119:49ca:6bb0]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:18ad:b0:2a4:3593:466b with SMTP id 5a478bee46e88-2aba422c066mr382160eec.7.1764798444290; Wed, 03 Dec 2025 13:47:24 -0800 (PST) Date: Wed, 3 Dec 2025 13:47:05 -0800 In-Reply-To: <20251203214706.112174-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251203214706.112174-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.177.g9f829587af-goog Message-ID: <20251203214706.112174-7-irogers@google.com> Subject: [PATCH v2 6/7] perf tests stat: Add test for error for an offline CPU From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Thomas Richter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a test that if an offline CPU is requested perf stat will fail. ``` $ perf test -vv "perf stat tests" 101: perf stat tests: Reported-by: Thomas Richter --- start --- test child forked, pid 46965 Basic stat command test Basic stat command test [Success] Null stat command test Null stat command test [Success] Offline CPU stat command test (cpu 8) Offline CPU stat command test [Success] stat record and report test stat record and report test [Success] stat record and script test stat record and script test [Success] stat repeat weak groups test stat repeat weak groups test [Success] Topdown event group test Topdown event group test [Success] Topdown weak groups test Topdown weak groups test [Skipped event parsing failed] cputype test cputype test [Success] hybrid test hybrid test [Success] ---- end(0) ---- 101: perf stat tests : Ok ``` Reported-by: Thomas Richter Closes: https://lore.kernel.org/linux-perf-users/94313b82-888b-4f42-9fb0-45= 85f9e90080@linux.ibm.com/ Signed-off-by: Ian Rogers --- tools/perf/tests/shell/stat.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh index 7885e875caf4..0b2f0f88ca16 100755 --- a/tools/perf/tests/shell/stat.sh +++ b/tools/perf/tests/shell/stat.sh @@ -27,6 +27,32 @@ test_null_stat() { echo "Null stat command test [Success]" } =20 +find_offline_cpu() { + for i in $(seq 1 4096) + do + if [[ ! -f /sys/devices/system/cpu/cpu$i/online || \ + $(cat /sys/devices/system/cpu/cpu$i/online) =3D=3D "0" ]] + then + echo $i + return + fi + done + echo "Failed to find offline CPU" + exit 1 +} + +test_offline_cpu_stat() { + cpu=3D$(find_offline_cpu) + echo "Offline CPU stat command test (cpu $cpu)" + if ! perf stat "-C$cpu" -e cycles true 2>&1 | grep -E -q "No supported e= vents found." + then + echo "Offline CPU stat command test [Failed]" + err=3D1 + return + fi + echo "Offline CPU stat command test [Success]" +} + test_stat_record_report() { echo "stat record and report test" if ! perf stat record -e task-clock -o - true | perf stat report -i - 2>= &1 | \ @@ -224,6 +250,7 @@ test_hybrid() { =20 test_default_stat test_null_stat +test_offline_cpu_stat test_stat_record_report test_stat_record_script test_stat_repeat_weak_groups --=20 2.52.0.177.g9f829587af-goog