diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-06-01 14:21:44 -0300 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-06-03 16:31:03 -0300 |
| commit | d38bee6d8082c23635faa5473162291d228ca96e (patch) | |
| tree | 7aef7763d4eb3ee5486031d61d18f55705c7efa7 | |
| parent | 43f827251af596072834fd6eb2b562468d1990d5 (diff) | |
| download | linux-d38bee6d8082c23635faa5473162291d228ca96e.tar.gz linux-d38bee6d8082c23635faa5473162291d228ca96e.zip | |
perf sched: Include file offset in event skip messages
Add the perf.data file offset to the CPU out-of-bounds and
machine__resolve failure messages emitted when samples are skipped in
process_sched_switch_event(), process_sched_runtime_event(), and
timehist_sched_change_event(). Also switch event type from raw integer
to perf_event__name() string for readability.
Reviewed-by: Ian Rogers <irogers@google.com>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/perf/builtin-sched.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 812a1b0d56d6..9ec8e049e19b 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1792,8 +1792,10 @@ static int process_sched_switch_event(const struct perf_tool *tool, u32 prev_pid = perf_sample__intval(sample, "prev_pid"), next_pid = perf_sample__intval(sample, "next_pid"); + /* perf.data is untrusted input — CPU may be absent or corrupted */ if (this_cpu < 0 || this_cpu >= MAX_CPUS) { - pr_warning("Out-of-bound sample CPU %d. Skipping sample\n", this_cpu); + pr_warning("WARNING: at offset %#" PRIx64 ": out-of-bound sample CPU %d, skipping sample\n", + sample->file_offset, this_cpu); return 0; } @@ -1819,8 +1821,10 @@ static int process_sched_runtime_event(const struct perf_tool *tool, { struct perf_sched *sched = container_of(tool, struct perf_sched, tool); + /* perf.data is untrusted input — CPU may be absent or corrupted */ if (sample->cpu >= MAX_CPUS) { - pr_warning("Out-of-bound sample CPU %u. Skipping sample\n", sample->cpu); + pr_warning("WARNING: at offset %#" PRIx64 ": out-of-bound sample CPU %u, skipping sample\n", + sample->file_offset, sample->cpu); return 0; } @@ -2786,15 +2790,18 @@ static int timehist_sched_change_event(const struct perf_tool *tool, int rc = 0; const char state = perf_sample__taskstate(sample, "prev_state"); + /* perf.data is untrusted input — CPU may be absent or corrupted */ if (sample->cpu >= MAX_CPUS) { - pr_warning("Out-of-bound sample CPU %d. Skipping sample\n", sample->cpu); + pr_warning("WARNING: at offset %#" PRIx64 ": out-of-bound sample CPU %d, skipping sample\n", + sample->file_offset, sample->cpu); return 0; } addr_location__init(&al); if (machine__resolve(machine, &al, sample) < 0) { - pr_err("problem processing %d event. skipping it\n", - event->header.type); + pr_err("problem processing %s (%u) event at offset %#" PRIx64 ", skipping it\n", + perf_event__name(event->header.type), event->header.type, + sample->file_offset); rc = -1; goto out; } |
