From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796358511; b=St1upYE3hJ96ltBZb18LC08XSzZfeSQKJoPUpW5Cr8BzrNgZ56VOOtsLEqgjZ/bZlrNs In7oZxKD7/POd3ecPLUEr5oaZ0bz1rP8PAt6zOla2cgCw1WkkUmwKwCdJlskvU/VGTkRZ 2dioX8SdbQluRuEn7dORr2dE1AnKmkQAf1mMgVaQeYfw9Pg6AzO5yXhOcyAAQmbIWGMVj dUhDgxI8WBi5xfBHysz+U6FzjrdwyqVSMcSsiS+4WRN5cfh7TK+pBE3gZnH8pSp/ZATZZ lRwy4K8CjHZDvDoMhl+YGHPHo+GsLNl4+rCZk3WRMqtCjcZ+psaCTyQCj268n23VAiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796358511; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=L6tUEMJqOJsUU14DvYP4tQzmsXfzyczEXcw/B9IArtQ=; b=MU9dbcl6qLYsXmFRrurQ7Eor1QibPj2DtxoYey/Eh5A1f8RxkuNggi+bZpb9ej5B+k8o UXiHGOfKyN/Arl+GTyd7qms8YhQsGNWiGhRMvoQib8oLsPiC0g7GYUbwNi/d8RA5AFk10 WSsPm43kqJlxCI4dG3KHzP53QMYdiI7f7iBrsRkfNQ6TFzpccpoTTZSsQU1xHXvapmAwL 3rvFFQC9jEfKLa9VABWj9YJgeWPwJFmQmJkwvhx+Ayi8WQ8YHJpP8ZXp2t4xwoCFi+Kqi 1kXbhzfyL5KHoBD06AwkGjBfkiP1oyUv3LA3VufViPDN9fsSxWSrD/2GD2/8g7HFQCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NaaAkLlP; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E8AF606A68A for ; Fri, 4 Dec 2026 04:28:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NaaAkLlP Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDFAA1F000CE; Fri, 4 Dec 2026 04:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796358510; bh=L6tUEMJqOJsUU14DvYP4tQzmsXfzyczEXcw/B9IArtQ=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=NaaAkLlPALjVrK22f5ps23PokebKfpYgTTR0r/Ln+MVmhUrrqCvKsxOp/waivCWBa y1y0lr5wCZyHVhcHJg/zRdNVZ9WczZ776q2+CuWcU5E2V22WJmiGdddXmUYYnapptN H6ab4wpYVX+1KCWpHzniQGdxI2ngkK9vcd3rWdAAkza7C0CpTN3WwkQjp3Jx/2hzeI AhDoEv6EL2e0z3aDpqv2N+INHVoEX32vVTsiLb4uBiPXb7iDh3pOhNeqPMLymyIlYf +AhlDYeYwO/m4fVmmb3uOp8DAtNu7A8G2q/GUPYkrO59k9m4u11wKcdmP5GJpxLTbg d7YVkMTw3loOw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v13 2/2] perf stat: Fix hybrid test failure and respect $PERF in stat+tool_group.sh Reply-To: sashiko-reviews@lists.linux.dev To: "TAKANO Mitsuhiro" , linux-perf-users@vger.kernel.org In-Reply-To: <20261204041444.1078407-2-takano32@gmail.com> References: <20261202053312.2695722-1-takano32@gmail.com> <20261204041444.1078407-1-takano32@gmail.com> <20261204041444.1078407-2-takano32@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 04:28:30 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [Medium] perf: hardcoded local PERF fallback path breaks stat+tool_group.sh - [Medium] perf: -C hybrid test still selects CPU 0 instead of a core PMU CPU - [Medium] perf: hybrid_core_types() masks uncounted events via any-match logic - [Low] perf: hybrid_core_types() omits percentage stripping on counted lines - [Low] perf: refused_either() ignores pattern and weakens stderr assertion - [Low] perf: unused orig_path variable left in stat+tool_group.sh -- commit f4bf103458da72ae9c4983ff105e9599ecdb3196 Author: TAKANO Mitsuhiro perf stat: Fix hybrid test failure and respect $PERF in stat+tool_group.sh This commit updates stat+tool_group.sh to strip percentage suffixes in hybrid_core_types(), select an online CPU dynamically for the -C test, and use a configurable PERF binary path. > diff --git a/tools/perf/tests/shell/stat+tool_group.sh b/tools/perf/tests= /shell/stat+tool_group.sh > index 4a2aae62321c0..19457fec395d4 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=3D$(mktemp /tmp/__perf_test.stat_tool_group.XXXXXX) > stderr=3D$(mktemp /tmp/__perf_test.stat_tool_group.XXXXXX) > =20 > +[ -n "${PERF:-}" ] || PERF=3D"/home/takano32/zerozari00/.home/.hermes/ca= che/scratch/perfbuild12/perf" > + [Severity: Medium] Should the fallback PERF path default to "perf" instead of a local build directory? perf test runs shell scripts via shell_test__run() without setting PERF, relying on setup_path() putting the perf binary on PATH. This hardcoded path makes every perf stat call fail with status 127 on other machines, and risks running an untrusted binary on multi-user hosts. [ ... ] > @@ -45,7 +47,8 @@ fi > # CPU-wide events need root or perf_event_paranoid <=3D 0, so -a can fai= l even > # when a per-thread event works. > syswide=3D1 > -if ! perf stat -a -e cycles -o /dev/null -- true 2> /dev/null; then > +orig_path=3D"${PATH}" > +if ! "${PERF}" stat -a -e cycles -o /dev/null -- true 2> /dev/null; then > syswide=3D0 > fi [Severity: Low] Is orig_path leftover debugging code? It is never referenced anywhere in stat+tool_group.sh. [ ... ] > @@ -89,7 +92,7 @@ refused_either() { > pattern=3D"${pattern} with kernel events: (user_time|cycles:R)\$" > =20 > echo "Testing that perf stat refuses ${group}" > - perf stat -e "${group}" -o "${out}" -- true 2> "${stderr}" || rc=3D$? > + "${PERF}" stat -e "${group}" -o "${out}" -- true 2> "${stderr}" || rc= =3D$? > =20 > if [ "${rc}" !=3D 22 ]; then > echo "perf stat did not refuse ${group} with 22 (${rc}) [Failed]" > @@ -97,7 +100,7 @@ refused_either() { > err=3D1 > 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 n= ot open [Failed]" > cat "${stderr}" > err=3D1 [Severity: Low] Was dropping ${pattern} here intentional? This leaves pattern unused and stops verifying the error prefix and named event, contradicting the failure message below it and going unmentioned in the commit message. If hybrid PMU prefixes on cycles:R broke the match, allowing an optional PMU prefix in pattern would preserve the check. [ ... ] > @@ -132,6 +136,7 @@ hybrid_core_types() { > } > // { > sub(/#.*/, "") > + sub(/\([0-9.]*%\)/, "") [Severity: Low] Should percentage suffixes also be stripped in the FNR =3D=3D NR pass above? print_running_std() appends (%.2f%%) whenever run !=3D ena on counted lines too. When a counted hybrid event is multiplexed without a # metric comment, $(NF) becomes the percentage token instead of the event name, so hybrid_core_types() fails to match the line. > if (bare($(NF)) in counted) > found =3D 1 > } [Severity: Medium] Can hybrid_core_types() mask an uncounted event in multi-event groups? Setting found =3D 1 on any matching line lets the awk script succeed even if another line has no counted counterpart. If cycles is hybrid-split while instructions is on all core types, accepted() marks the test skipped instead of failed. [ ... ] > @@ -231,12 +236,18 @@ refused '{user_time,cycles}' user_time -p $$ > =20 > # -C keeps the CPU map the user asked for. With one CPU both the tool e= vent > # and the kernel event sit on it, so evlist__check_cpu_maps() has nothin= g 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; th= en > - refused '{cycles,duration_time}' duration_time -C 0 > +# split and the group reaches the check. Passing a CPU not covered by t= he > +# PMU, or an offline CPU, makes perf stat split the group or hit an inte= rnal > +# 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=3D"" > +if [ -r /sys/devices/system/cpu/online ]; then > + online_cpu=3D$(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=3D$((skipped + 1)) > fi [Severity: Medium] Does this still pass -C 0 on hybrid Intel machines and fail the test? The awk command only reads /sys/devices/system/cpu/online without checking any PMU cpus mask, so online_cpu is still 0 on systems with ranges like 0-23. Unlike the previous grep, which skipped range syntax, this now actively runs -C 0. pmu_read_sysfs() sorts core_pmus alphabetically, so {cycles,duration_time} groups {cpu_atom/cycles/, duration_time}. When CPU 0 belongs to cpu_core, __perf_evlist__propagate_maps() intersects cpu_atom's CPUs with {0} to an empty map and removes the leader. evlist__check_cpu_maps() then detaches duration_time before check_unopened_in_group() runs, so perf stat exits 0 instead of 22 and refused() fails. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204041444.1078= 407-1-takano32@gmail.com?part=3D2