Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v5 2/2] perf test: Test perf timechart --live
Date: Fri, 23 Oct 2026 06:01:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-182336@kernel.org> (raw)
In-Reply-To: <20261023054952.2503540-3-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf test: unprivileged failure in test_no_events() due to system-wide -a
--

commit a678a998e849226efd51ba949028c49bad18c75e
Author: Alice Rogers <alice.mei.rogers@gmail.com>

perf test: Test perf timechart --live

This commit extends test_ttimechart_python.sh to test --live option
validation, LiveRecorder's perf record subprocess, synthetic live UI
behavior, and live workload recording.

> diff --git a/tools/perf/tests/shell/test_ttimechart_python.sh b/tools/perf/tests/shell/test_ttimechart_python.sh
> index 87b91ed8fc167..c03e71b68991c 100755
> --- a/tools/perf/tests/shell/test_ttimechart_python.sh
> +++ b/tools/perf/tests/shell/test_ttimechart_python.sh

[ ... ]

> @@ -115,6 +145,43 @@ test_no_events() {
>  		err=1
>  		return
>  	fi
> +	# Exercise LiveRecorder's perf record subprocess, control pipe and
> +	# -o output file using task-clock when tracepoints may be unavailable.
> +	rm -f "${clockdata}"
> +	if ! "$PYTHON" - "${PERF_BIN:-perf}" "${clockdata}" \
> +		"$(declare -f workload); workload" > "${output}" 2>&1 <<'EOF'
> +import asyncio
> +import os
> +import sys
> +import ttimechart as tc
> +
> +async def run() -> None:
> +    rec = tc.LiveRecorder(sys.argv[1], False, False, ["bash", "-c", sys.argv[3]], sys.argv[2])
> +    rec.events = lambda: ["task-clock"]
> +    rec.start()
> +    app = tc.TimechartApp("live", False, False, [], live=rec, window=5.0)
> +    try:
> +        async with app.run_test(size=(120, 40)) as pilot:
> +            await pilot.press("space")
> +            await pilot.pause(0.1)
> +            await pilot.press("space")
> +            for _ in range(300):
> +                if app.return_code is not None:
> +                    break
> +                await pilot.pause(0.05)
> +    finally:
> +        rec.stop()
> +    if app.return_code != 1 or not app.data.nr_samples or not os.path.getsize(sys.argv[2]):
> +        raise RuntimeError(f"Unexpected result: rc={app.return_code} samples={app.data.nr_samples}")
> +
> +asyncio.run(run())
> +EOF
> +	then
> +		echo "ttimechart no events test [Failed: LiveRecorder task-clock test]"
> +		cat "${output}"
> +		err=1
> +		return
> +	fi

[Severity: Medium]
Can this cause test_no_events() to fail instead of skip when run by an
unprivileged user on a machine with the default kernel.perf_event_paranoid
setting of 1 or 2?

At the start of test_no_events(), the permission check runs a per-task
recording without -a:

tools/perf/tests/shell/test_ttimechart_python.sh:test_no_events() {
	if ! perf record -e task-clock -o "${clockdata}" -- true > /dev/null 2>&1; then
		echo "ttimechart no events test [Skipped: perf record failed]"
		return
	fi
    ...
}

Because that check opens a per-task software event, it succeeds for
unprivileged users under kernel.perf_event_paranoid = 1 or 2.

However, LiveRecorder.start() unconditionally passes -a for system-wide
recording:

tools/perf/python/ttimechart.py:LiveRecorder.start() {
    ...
            cmd.append("-a")
            if self.workload:
                cmd += ["--", *self.workload]
    ...
}

When kernel.perf_event_paranoid > 0 and the user lacks CAP_PERFMON,
system-wide perf record -a -e task-clock fails with EACCES via
find_get_context() -> perf_allow_cpu(). That leaves app.data.nr_samples
and the output file empty, raising RuntimeError and setting err=1, which
causes the script to exit with 1 (failure) rather than 2 (skip) when
record() subsequently skips.

Should the LiveRecorder task-clock subtest check whether perf record -a -e
task-clock is permitted before running, or only run when system-wide
recording is available?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261023054952.2503540-1-irogers@google.com?part=2

      reply	other threads:[~2026-10-23  6:01 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 18:26 [PATCH v1 00/13] perf timechart/list/treport: Interactive Textual TUIs and perf python session improvements Ian Rogers
2026-10-02 18:26 ` [PATCH v1 01/13] perf session: Don't flush remaining events once processing is done Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 02/13] perf python: Quietly stop processing events when a callback raises Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 03/13] perf python: Lazily copy events and samples from process_events Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 04/13] perf python: Lazily resolve sample callchains Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 05/13] perf python: Release the GIL while processing session events Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 06/13] perf list: Add a --tui option to launch ilist Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 07/13] perf test: Add a test for the ilist script Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 08/13] perf treport: Show the profile while it loads Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-03  9:31   ` Arnaldo Carvalho de Melo
2026-10-02 18:26 ` [PATCH v1 09/13] perf test: Add a test for the treport script Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-03  9:35   ` Arnaldo Carvalho de Melo
2026-10-02 18:26 ` [PATCH v1 10/13] perf timechart: Add an interactive --tui mode Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 11/13] perf test: Add a test for perf timechart --tui Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 12/13] perf timechart: Add a --live mode to the TUI Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-02 18:26 ` [PATCH v1 13/13] perf test: Test perf timechart --live Ian Rogers
2026-10-03  1:33   ` sashiko-bot
2026-10-03  9:10 ` [PATCH v1 00/13] perf timechart/list/treport: Interactive Textual TUIs and perf python session improvements Arnaldo Carvalho de Melo
2026-10-03  9:12   ` Arnaldo Carvalho de Melo
2026-10-03  9:15     ` Arnaldo Carvalho de Melo
2026-10-14  4:22       ` [PATCH v2 0/2] perf timechart: Add --live mode to the TUI and test Ian Rogers
2026-10-14  4:22         ` [PATCH v2 1/2] perf timechart: Add a --live mode to the TUI Ian Rogers
2026-10-14  4:35           ` sashiko-bot
2026-10-14  4:22         ` [PATCH v2 2/2] perf test: Test perf timechart --live Ian Rogers
2026-10-14  4:28           ` sashiko-bot
2026-10-23  4:18         ` [PATCH v3 0/2] perf timechart: Add --live mode to the TUI and test Ian Rogers
2026-10-23  4:18           ` [PATCH v3 1/2] perf timechart: Add a --live mode to the TUI Ian Rogers
2026-10-23  4:37             ` sashiko-bot
2026-10-23  4:18           ` [PATCH v3 2/2] perf test: Test perf timechart --live Ian Rogers
2026-10-23  4:23             ` sashiko-bot
2026-10-23  5:02           ` [PATCH v4 0/2] perf timechart: Add --live mode to the TUI and test Ian Rogers
2026-10-23  5:02             ` [PATCH v4 1/2] perf timechart: Add a --live mode to the TUI Ian Rogers
2026-10-23  5:25               ` sashiko-bot
2026-10-23  5:02             ` [PATCH v4 2/2] perf test: Test perf timechart --live Ian Rogers
2026-10-23  5:07               ` sashiko-bot
2026-10-23  5:49             ` [PATCH v5 0/2] perf timechart: Add --live mode to the TUI and test Ian Rogers
2026-10-23  5:49               ` [PATCH v5 1/2] perf timechart: Add a --live mode to the TUI Ian Rogers
2026-10-23  6:16                 ` sashiko-bot
2026-10-23  5:49               ` [PATCH v5 2/2] perf test: Test perf timechart --live Ian Rogers
2026-10-23  6:01                 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-182336@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox