Re: [PATCH v10 00/29] perf tool: Add evsel to perf_sample

From: Ian Rogers

Date: Mon Apr 13 2026 - 13:01:58 EST


On Mon, Apr 13, 2026 at 9:40 AM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> On Sun, Apr 12, 2026 at 05:52:57PM -0700, Ian Rogers wrote:
> > On Sun, Apr 12, 2026 at 1:10 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> > >
> > > Hi Ian,
> > >
> > > On Sat, Apr 11, 2026 at 07:08:03PM -0700, Ian Rogers wrote:
> > > > Nearly all perf code ends up passing an evsel with the perf_sample,
> > > > which is problematic if you want to rewrite the evsel such as with
> > > > off-CPU processing - all uses of the evsel need fixing up. Previously
> > > > I'd mailed this patch as an RFC with everything combined:
> > > > https://lore.kernel.org/lkml/20260126071822.447368-1-irogers@xxxxxxxxxx/
> > > > and there was a request to break it up.
> > > >
> > > > v10: Changes to some of the bounds checks as prompted by Sashiko.
> > > >
> > > > v9: Clean up some error path nits caught by Sashiko and simple bound
> > > > checks Sashiko recommended.
> > > > https://lore.kernel.org/linux-perf-users/20260411191710.524998-1-irogers@xxxxxxxxxx/
> > > >
> > > > v8: Fix address sanitizer issues with kwork and move patches, along
> > > > with bound check additions, to end of series.
> > > > https://lore.kernel.org/linux-perf-users/20260411065718.372240-1-irogers@xxxxxxxxxx/
> > > >
> > > > v7: Separate out kwork work->name to a strdup into its own patch, now patch 4.
> > > > https://lore.kernel.org/linux-perf-users/20260408072601.210837-1-irogers@xxxxxxxxxx/
> > > >
> > > > v6: Address more Sashiko feedback.
> > > > https://lore.kernel.org/lkml/20260404034325.3172592-1-irogers@xxxxxxxxxx/
> > > >
> > > > v5: Address feedback from Sashiko and Namhyung.
> > > > https://lore.kernel.org/lkml/20260403204017.2919994-1-irogers@xxxxxxxxxx/
> > > >
> > > > v4: Fix more sashiko issues: bounds checks, memory safety, making
> > > > refactors better, inconsistent evsels, mmap2 buildid injection
> > > > choice of evsel, mismatched function arguments.
> > > > https://sashiko.dev/#/patchset/20260320080835.724836-1-irogers%40google.com
> > > > https://lore.kernel.org/lkml/20260320192627.368357-1-irogers@xxxxxxxxxx/
> > > >
> > > > v3: Fix various sashiko review comments particularly about unintended
> > > > behavior changes.
> > > > https://lore.kernel.org/lkml/20260320080835.724836-1-irogers@xxxxxxxxxx/
> > > >
> > > > v2: Add review feedback on the first 2 patches from Namhyung, fix a
> > > > missed evsel assignment running event2evsel in builtin-inject.
> > > > https://lore.kernel.org/lkml/20260319232334.287517-1-irogers@xxxxxxxxxx/
> > > >
> > > > v1: https://lore.kernel.org/lkml/20260209174032.4142096-1-irogers@xxxxxxxxxx/
> > > >
> > > > Ian Rogers (29):
> > > > perf sample: Fix documentation typo
> > > > perf tool: Remove evsel from tool APIs that pass the sample
> > > > perf kvm: Don't pass evsel with sample
> > > > perf evsel: Refactor evsel tracepoint sample accessors perf_sample
> > > > perf trace: Don't pass evsel with sample
> > > > perf callchain: Don't pass evsel and sample
> > > > perf lock: Only pass sample to handlers
> > > > perf lock: Constify trace_lock_handler variables
> > > > perf hist: Remove evsel parameter from inc samples functions
> > > > perf db-export: Remove evsel from struct export_sample
> > > > perf hist: Remove evsel from struct hist_entry_iter
> > > > perf report: Directly use sample->evsel to avoid computing from
> > > > sample->id
> > > > perf annotate: Don't pass evsel to add_sample
> > > > perf inject: Don't pass evsel with sample
> > > > perf kmem: Don't pass evsel with sample
> > > > perf kwork: Don't pass evsel with sample
> > > > perf sched: Don't pass evsel with sample
> > > > perf timechart: Don't pass evsel with sample
> > > > perf trace: Don't pass evsel with sample
> > > > perf evlist: Try to avoid computing evsel from sample
> > > > perf script: Don't pass evsel with sample
> > > > perf s390-sample-raw: Don't pass evsel or its PMU with sample
> > > > perf evsel: Don't pass evsel with sample
> > > > perf kmem: Add bounds checks to tracepoint read values
> > > > perf sched: Bounds check CPU in sched switch events
> > > > perf timechart: Bounds check CPU
> > > > perf evsel: Add bounds checking to trace point raw data accessors
> > > > perf kwork: Fix address sanitizer issues
> > > > perf kwork: Fix memory management of kwork_work
> > >
> > > I've picked the first 23 patches to tmp.perf-tools-next as the rest
> > > still has some issues. Also I've touched some commits to either remove
> > > some parts or split them into separate commits.
> > >
> > > Please take a look.
> >
> > Hi Namhyung,
> >
> > thanks for doing this but I've done a similar clean up. To totally
> > separate the evsel refactoring from the rest of the changes, to fix
> > the address sanitizer issues with kwork, etc. I'll incorporate your
> > changes and then resend the series.
>
> Thanks, I'd like to merge what's in the tmp.perf-tools-next unless
> there's a serious mistake. You can rebase the rest changes on top.

I'd drop what's in tmp.perf-tools-next. Otherwise we're putting fixes
on top of fixes. Looking at v12 the sashiko issues are all minor and
the progression of the patches is more granular and natural.

Thanks,
Ian

> Thanks,
> Namhyung
>