Re: [PATCH] perf test: Add test case for event group throttling with inactive events
From: Namhyung Kim
Date: Fri Aug 15 2025 - 16:07:18 EST
On Fri, Aug 15, 2025 at 05:23:44AM +0900, Yunseong Kim wrote:
> Hi Namhyung,
>
> Thanks for your reply.
>
> On 8/15/25 5:06 AM, Namhyung Kim wrote:
> > Hi Yunseong,
> >
> > On Wed, Aug 13, 2025 at 04:32:52PM +0000, Yunseong Kim wrote:
> >> A recent UBSAN shift-out-of-bounds report was identified when throttling
> >> event groups that included inactive (PERF_EVENT_STATE_OFF) events.
> >> This occurred because pmu->start()/stop() could be called on these events,
> >> potentially leaving event->hw.idx at -1. This leads to undefined behavior
> >> when PMU code later uses this negative index as a shift exponent.
> >>
> >> The issue need to ensuring perf_event_throttle() and
> >> perf_event_unthrottle() skip inactive events entirely.
> >>
> >> Introduce a new perf test suite, "event group throttle", to verify this
> >> fix and prevent regressions.
> >
> > Thanks for your work!
> >
> > I'm curious what happens if it runs on unfixed kernels. I suspect this
> > should be in the selftest so that it can tie with the kernel fix.
>
> I agree with your point. I believe it's more appropriate for this test to
> be included in "kself test" alongside the kernel fix. I'll modify the
> test case based on Liang's suggestion.
>
> > By having this in the perf tools test suite, you cannot guarantee if the
> > kernel has the fix. And it may turn the kernel into an unstable state
> > easily.
>
> Would it be possible to add this test if it were changed to focus on
> a different aspect?
It depends on how you change it. Can you please share your idea first?
Thanks,
Namhyung