From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Swapnil Sapkal <swapnil.sapkal@amd.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] perf sched: Avoid segv if tp_handler not set
Date: Thu, 26 Mar 2026 16:20:00 -0700 [thread overview]
Message-ID: <acW_IHQVZnxIETdd@google.com> (raw)
In-Reply-To: <20260321061448.810525-1-irogers@google.com>
On Fri, Mar 20, 2026 at 11:14:47PM -0700, Ian Rogers wrote:
> Doing a `perf sched record` then `perf sched stats report` crashes as
> the tp_handler isn't set. Add extra checks that tp_handler is set
> before accessing through it.
Oh.. unintended use case. :) Probably better to add a dummy handler
for `perf sched stats report`.
Thanks,
Namhyung
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/builtin-sched.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index d083e2bb7703..196f263ff667 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -1525,7 +1525,7 @@ static int process_sched_wakeup_event(const struct perf_tool *tool,
> {
> struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
>
> - if (sched->tp_handler->wakeup_event)
> + if (sched->tp_handler && sched->tp_handler->wakeup_event)
> return sched->tp_handler->wakeup_event(sched, evsel, sample, machine);
>
> return 0;
> @@ -1809,7 +1809,7 @@ static int process_sched_switch_event(const struct perf_tool *tool,
> sched->nr_context_switch_bugs++;
> }
>
> - if (sched->tp_handler->switch_event)
> + if (sched->tp_handler && sched->tp_handler->switch_event)
> err = sched->tp_handler->switch_event(sched, evsel, sample, machine);
>
> sched->curr_pid[this_cpu] = next_pid;
> @@ -1823,7 +1823,7 @@ static int process_sched_runtime_event(const struct perf_tool *tool,
> {
> struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
>
> - if (sched->tp_handler->runtime_event)
> + if (sched->tp_handler && sched->tp_handler->runtime_event)
> return sched->tp_handler->runtime_event(sched, evsel, sample, machine);
>
> return 0;
> @@ -1840,7 +1840,7 @@ static int perf_sched__process_fork_event(const struct perf_tool *tool,
> perf_event__process_fork(tool, event, sample, machine);
>
> /* and then run additional processing needed for this command */
> - if (sched->tp_handler->fork_event)
> + if (sched->tp_handler && sched->tp_handler->fork_event)
> return sched->tp_handler->fork_event(sched, event, machine);
>
> return 0;
> @@ -1853,7 +1853,7 @@ static int process_sched_migrate_task_event(const struct perf_tool *tool,
> {
> struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
>
> - if (sched->tp_handler->migrate_task_event)
> + if (sched->tp_handler && sched->tp_handler->migrate_task_event)
> return sched->tp_handler->migrate_task_event(sched, evsel, sample, machine);
>
> return 0;
> --
> 2.53.0.959.g497ff81fa9-goog
>
next prev parent reply other threads:[~2026-03-26 23:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 6:14 [PATCH v1 1/2] perf sched: Avoid segv if tp_handler not set Ian Rogers
2026-03-21 6:14 ` [PATCH v1 2/2] perf tests sched stats: Write output to temp file Ian Rogers
2026-03-23 10:41 ` Swapnil Sapkal
2026-03-23 10:39 ` [PATCH v1 1/2] perf sched: Avoid segv if tp_handler not set Swapnil Sapkal
2026-03-26 23:20 ` Namhyung Kim [this message]
2026-04-01 5:59 ` Ian Rogers
2026-04-03 2:42 ` Namhyung Kim
2026-04-03 15:29 ` Ian Rogers
2026-04-06 17:53 ` Namhyung Kim
2026-05-05 21:56 ` Ian Rogers
2026-05-06 13:10 ` Arnaldo Carvalho de Melo
2026-05-06 16:17 ` Namhyung Kim
2026-05-06 17:12 ` Ian Rogers
2026-05-06 18:54 ` Namhyung Kim
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=acW_IHQVZnxIETdd@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=swapnil.sapkal@amd.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.