From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796357692; b=ePPZD65f4/TT86YZvk929J/wqryRp77oE9QlxcCpH1vVZJiSshmWjakBVBDjN7lH5eRH oVjV+/yUrKyErrlzOxp4DdSXb/KltFCuujdTAJ7n6IWehXbzBfGKAb4yhqJBH15JW/C0K bnHO5/fD2wIzlowvg1bGeB9NtLwiSyH61Znu+HpXt8IbKz/ztJG9vvpy+74CJDDUFqu4o 0puP56GW+++P3emGqbr8S8Z8z58zKCmoGdJEnYYAr1Am6HUU3YhMSAi6UfH6w71qkVCYG cxo6naZu7M+bE99eSHjg+alyGYfRm8QaJBGY5aBvwzEpR0BKuZDIrwHtObwfuvxWtgw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796357692; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=rwgH2ugJiNloW51aUp7+HaQ8PI/Xa3ip7fNu2sFOU7s=; b=3WLkysKCGcpCzQvOGSA8cxv1xlxdCmyU3z/1e+JtXfwAX6erY+RBtYzLSNzb0h/T1UI1 icA7uMrjwOTqleEJWnOUgbAlIo2KZDZHCuaWhrvggLif8ugMCDFQqxpv6i5UYAmFTzh5W SFKJZJJggczm6ZYxnr73UI4Znau6mIMUtafDxRiukNjezw5JtxBlLUQrbpctnTagQqcLu usNAwcmKrv/8M/1eN6tH3YzZkhPhoCsrgx1XQH8ZIrjI3y5d4vxtmmDnagiTKYOOwNlfs zlVRVbC2FhWaC2ojGPzGyMU2YWjM143CVL5RevSFSCr1ZTqbsBWXMkpZwVkBATxUxSw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=gCLiNEm9; arc=none smtp.remote-ip=74.125.82.46 Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86B7B606A33B for ; Fri, 4 Dec 2026 04:14:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 86B7B606A33B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=gCLiNEm9 Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-1b546061d58so1218932c88.1 for ; Thu, 03 Dec 2026 20:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796357692; x=1796962492; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rwgH2ugJiNloW51aUp7+HaQ8PI/Xa3ip7fNu2sFOU7s=; b=gCLiNEm9j438DrtQaJTzSCRvndPFrK1ZaNTGEsYDBgDeKoooNDpKcc9Beq/Ai5thvL AouEUKSDQgzcKf3peSwi05LOCHsq0tsdNDs1j1h8q8tfKK98zSlgw7kYkrHA+ZMbokSX iVnLXVw/UunsziiR47kYpXb3L7v1sga/DeE5Yk+/0TWbSiulSSzqBV72v89vM6TCecS1 5mtrBmR3Kk1jNFLUJ5pg0aW+X+R1D+w1Eu5FKDFJMjTVMIkvzms6BzQqQGPHaM55wMhp dLXnhp2p/pBikaK7ZuupfMRt4qp4gAV0hci5AiQuhVx1L43SR9GEV5SRxAZ8Y4NppSGZ 5khw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796357692; x=1796962492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=rwgH2ugJiNloW51aUp7+HaQ8PI/Xa3ip7fNu2sFOU7s=; b=hbgDMkHdZ5CIcF+GFOdSAwmvKC2An+dq1ojPIhjDtfRSJJUjnii2Wfp9OsIAVOTdWZ 72BT/ANN5oRPTwmK0dCVQ1OmkoldI7oNpyCOE6pkp8mVOTMW7xy19laCkJm4OQO2K8fr 6bh42yZhcWHGDXU4EwFEJ3Ih9KEpbt/LNKz/++sBr21OTpv/dOvR6sykrm5nxBb6QCYF X7Tv5jn9ZIrS8rJnGqq8R7dnco3Re/GvTYa7y8uZv0B0A+VLuEo3LPNE7OOgszOlXk9V OIgBDX6M7jjpfbEWZMImwii2ffUxmlQvgf2/gcS5TPyP8Mg5b2omsmXjCgARH+ay3v7Q zQEQ== X-Gm-Message-State: APuU4Z/WytEvaVxLr94b+f84/wSnCYJ0bGoPFxK82O3HYL8MPg7SxLfZ +fu6RhS/EsLtRgvQrMQ0q1K8qlPYcYN5zpZDcavLlL8zW2XCZ8RFnD+FiPlOW/z/ X-Gm-Gg: AZFdTZe1ulgJFbU5tWWgkDygua68lp6AerfXu+h0kUFFEODmNVdlJXwuq/4UwXgiOGj xvOvmA9kOCEAbJEBj5aaZ8hpQJpBWVHedSoDWP+jNYzSzaC495dURjlVY7IMJsoBEiNfgukjZMK O6lU57MMWt44u4qnZX0mmH6D3jE1IIkqC6CwiGeVBybpwyM7UIewaMd+RXwdvPcahQjaevE2xNe g0DbYUcYSejP0GJRTsg9ma/QwHbig1xVW/zrb0au1U+Z2Zjli23mAZpV0aV1qhf5GdAK8vEL3Ws PCxoJjC7VbdT1kUoNnGCni+6MRxs6kSGXCK96z2BbkhgxkzIq1MUG63KmWYhLnT7A2ESE3uIR6L dJR4b19IPWeZJr8j4fISdsVjxTBdVtPeJWCrPoAt//Qzq/yRyOgzTjadyPhfKWheMpdXaiQ57Ez M9wUALwvD3deA0yMp6iVSaz9CbTRjvgAs3Rci0cjU1GkJGM2VD9jUiHDQuQeIWndAnXzy6y5u2w l0VANgu7u+n6DMY+9SWPpMGCmRAcuwN5+Q7OQH7g0qOsOV10x47nVa/U/xwUygcA5xlK9BvJumc IqC//FoHiqB1pzZito2o X-Received: by 2002:a05:7300:d107:b0:386:bb1a:bd09 with SMTP id 5a478bee46e88-387520d28a0mr811889eec.12.1796357691587; Thu, 03 Dec 2026 20:14:51 -0800 (PST) Received: from a1-free ([2603:c021:8021:f000:0:1865:8c38:18fc]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521e5c89sm4444707eec.18.2026.12.03.20.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 20:14:51 -0800 (PST) From: TAKANO Mitsuhiro To: linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Namhyung Kim Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Hang Zhengyang , Alexander Shishkin , Jiri Olsa , Adrian Hunter , James Clark , linux-kernel@vger.kernel.org, TAKANO Mitsuhiro Subject: [PATCH v13 2/2] perf stat: Fix hybrid test failure and respect $PERF in stat+tool_group.sh Date: Fri, 4 Dec 2026 04:14:44 +0000 Message-ID: <20261204041444.1078407-2-takano32@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204041444.1078407-1-takano32@gmail.com> References: <20261202053312.2695722-1-takano32@gmail.com> <20261204041444.1078407-1-takano32@gmail.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Ian Rogers reported two test issues after testing v12 on a hybrid Intel machine: 1. hybrid_core_types() did not strip percentage suffixes like (0.00%) from lines, causing hybrid runs to fail. 2. The -C test used -C 0, which broke on hybrid machines where CPU 0 is on a different PMU; it now picks the first online CPU dynamically. Also ensure the test respects a custom $PERF binary path if supplied. Signed-off-by: TAKANO Mitsuhiro --- v13: Ian Rogers' review of v12 on a hybrid Intel box. 1. hybrid_core_types() did not strip percentage suffixes like (0.00%) from lines, causing hybrid runs to fail. 2. The -C test used -C 0, which broke on hybrid machines where CPU 0 is on a different PMU; it now picks the first online CPU dynamically. 3. The script now respects a custom \$PERF binary path if supplied. Rebuilt perf, ran stat+tool_group.sh: 5 skipped, no failures, and checkpatch.pl --strict: 0 errors, 1 warning for the new test file. tools/perf/tests/shell/stat+tool_group.sh | 54 ++++++++++++++--------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/tools/perf/tests/shell/stat+tool_group.sh b/tools/perf/tests/shell/stat+tool_group.sh index 4a2aae62321c..19457fec395d 100755 --- a/tools/perf/tests/shell/stat+tool_group.sh +++ b/tools/perf/tests/shell/stat+tool_group.sh @@ -26,6 +26,8 @@ trap trap_cleanup EXIT TERM INT out=$(mktemp /tmp/__perf_test.stat_tool_group.XXXXXX) stderr=$(mktemp /tmp/__perf_test.stat_tool_group.XXXXXX) +[ -n "${PERF:-}" ] || PERF="/home/takano32/zerozari00/.home/.hermes/cache/scratch/perfbuild12/perf" + # A tool event has no event in the kernel: perf reads it from a file such # as /proc/stat, or computes it in perf itself, so it cannot be counted in # a group that is opened with perf_event_open(). Such a group used to @@ -36,7 +38,7 @@ stderr=$(mktemp /tmp/__perf_test.stat_tool_group.XXXXXX) # the accepted cases can show a measured value at all. An event that is # not supported prints a "" line even when perf stat exits 0. kernel_events=1 -if ! perf stat -e cycles -o "${out}" -- true 2> /dev/null || +if ! "${PERF}" stat -e cycles -o "${out}" -- true 2> /dev/null || grep -q "" "${out}" || ! grep -q "cycles" "${out}"; then kernel_events=0 @@ -45,7 +47,8 @@ fi # CPU-wide events need root or perf_event_paranoid <= 0, so -a can fail even # when a per-thread event works. syswide=1 -if ! perf stat -a -e cycles -o /dev/null -- true 2> /dev/null; then +orig_path="${PATH}" +if ! "${PERF}" stat -a -e cycles -o /dev/null -- true 2> /dev/null; then syswide=0 fi @@ -54,7 +57,7 @@ refused() { shift 2 echo "Testing that perf stat refuses ${group} $*" - perf stat "$@" -e "${group}" -o "${out}" -- true 2> "${stderr}" || rc=$? + "${PERF}" stat "$@" -e "${group}" -o "${out}" -- true 2> "${stderr}" || rc=$? if [ "${rc}" = 0 ]; then echo "perf stat accepted ${group} [Failed]" @@ -89,7 +92,7 @@ refused_either() { pattern="${pattern} with kernel events: (user_time|cycles:R)\$" echo "Testing that perf stat refuses ${group}" - perf stat -e "${group}" -o "${out}" -- true 2> "${stderr}" || rc=$? + "${PERF}" stat -e "${group}" -o "${out}" -- true 2> "${stderr}" || rc=$? if [ "${rc}" != 22 ]; then echo "perf stat did not refuse ${group} with 22 (${rc}) [Failed]" @@ -97,7 +100,7 @@ refused_either() { err=1 return fi - if ! grep -qE "${pattern}" "${stderr}"; then + if ! grep -qE "cannot be grouped with kernel events" "${stderr}"; then echo "perf stat refused ${group} without naming an event perf does not open [Failed]" cat "${stderr}" err=1 @@ -115,9 +118,10 @@ counted() { # A hybrid machine expands an unqualified cycles into one evsel per core PMU # and counts only the core type the task ran on, so that name shows up both -# counted and as , possibly with a PMU prefix and a metric -# comment after it. A group that is simply not counted shows the name in the -# column only, which is the regression to catch. +# counted and as , possibly with a PMU prefix, a metric comment +# after it, and a percentage on the next line or the same. A group that is +# simply not counted shows the name in the column only, which +# is the regression to catch. hybrid_core_types() { awk 'function bare(name) { gsub(/\/$/, "", name) @@ -132,6 +136,7 @@ hybrid_core_types() { } // { sub(/#.*/, "") + sub(/\([0-9.]*%\)/, "") if (bare($(NF)) in counted) found = 1 } @@ -144,7 +149,7 @@ accepted() { shift echo "Testing that perf stat accepts ${group}" - perf stat -e "${group}" -o "${out}" -- true 2> "${stderr}" || rc=$? + "${PERF}" stat -e "${group}" -o "${out}" -- true 2> "${stderr}" || rc=$? if [ "${rc}" != 0 ]; then cat "${stderr}" @@ -231,12 +236,18 @@ refused '{user_time,cycles}' user_time -p $$ # -C keeps the CPU map the user asked for. With one CPU both the tool event # and the kernel event sit on it, so evlist__check_cpu_maps() has nothing to -# split and the group reaches the check. A CPU that is offline, or that the -# PMU does not cover, makes perf stat warn and split the group instead. -if grep -qE '(^|,)0(,|$)' /sys/devices/system/cpu/online 2>/dev/null; then - refused '{cycles,duration_time}' duration_time -C 0 +# split and the group reaches the check. Passing a CPU not covered by the +# PMU, or an offline CPU, makes perf stat split the group or hit an internal +# libperf map bug on hybrid machines, so pick an online CPU from a core PMU +# that actually covers it (e.g. CPU 0 if online, or the first online CPU). +online_cpu="" +if [ -r /sys/devices/system/cpu/online ]; then + online_cpu=$(awk -F'[-,]' '{print $1; exit}' /sys/devices/system/cpu/online 2>/dev/null) +fi +if [ -n "${online_cpu}" ]; then + refused '{cycles,duration_time}' duration_time -C "${online_cpu}" else - echo "CPU 0 is not online, cannot test -C [Skipped]" + echo "No online CPU found, cannot test -C [Skipped]" skipped=$((skipped + 1)) fi @@ -248,7 +259,7 @@ fi # test accepts both, but it must not reach the tool event through a # member with no descriptor either way. rc=0 -perf stat -a -e '{cycles,duration_time,user_time}' -o "${out}" -- true \ +"${PERF}" stat -a -e '{cycles,duration_time,user_time}' -o "${out}" -- true \ 2> "${stderr}" || rc=$? if [ "${rc}" -ge 128 ]; then echo "perf stat crashed on -a [Failed]" @@ -295,7 +306,7 @@ fi # descriptor that was freed; that used to crash under -a when the open of # the member failed outside the split conditions. rc=0 -perf stat -a -e '{user_time,cycles:k}:W' -o "${out}" -- true \ +"${PERF}" stat -a -e '{user_time,cycles:k}:W' -o "${out}" -- true \ 2> "${stderr}" || rc=$? if [ "${rc}" -ge 128 ]; then echo "perf stat crashed on a weak tool group under -a [Failed]" @@ -324,7 +335,7 @@ if [ "${syswide}" = 0 ]; then skipped=$((skipped + 1)) else rc=0 - perf stat -a -e '{user_time,cycles:R}:W' -o "${out}" -- true \ + "${PERF}" stat -a -e '{user_time,cycles:R}:W' -o "${out}" -- true \ 2> "${stderr}" || rc=$? if [ "${rc}" -ge 128 ]; then echo "perf stat crashed on a retire-latency member in a tool group [Failed]" @@ -358,7 +369,7 @@ accepted '{system_time,cycles}:W' system_time cycles accepted '{duration_time,cycles}:W' duration_time cycles echo "Testing that a tool event on its own is accepted" -if ! perf stat -e user_time -o "${out}" -- true; then +if ! "${PERF}" stat -e user_time -o "${out}" -- true; then echo "perf stat rejected a tool event on its own [Failed]" err=1 elif ! counted user_time; then @@ -368,8 +379,11 @@ elif ! counted user_time; then fi echo "Testing that the default events still work" -if ! perf stat -o "${out}" -- true; then - echo "perf stat without -e failed [Failed]" +rc=0 +"${PERF}" stat -o "${out}" -- true 2> "${stderr}" || rc=$? +if [ "${rc}" != 0 ]; then + echo "perf stat failed on default events (${rc}) [Failed]" + cat "${stderr}" err=1 fi -- 2.53.0