Re: [PATCH v2] perf/core: Optimize event reschedule for a PMU
From: Peter Zijlstra
Date: Mon Aug 05 2024 - 05:07:16 EST
On Sat, Aug 03, 2024 at 10:08:32AM -0700, Namhyung Kim wrote:
> > @@ -2802,9 +2821,10 @@ static int __perf_install_in_context(void *info)
> > #endif
> >
> > if (reprogram) {
> > - ctx_sched_out(ctx, EVENT_TIME);
> > + ctx_update_time(cpuctx, ctx);
>
> So you don't want to stop the context time while adding or enabling a new
> event, right? Then I'm not sure if it's needed to update the time here as
> it'll be updated in the ctx_sched_out() again.
>
> Also calling ctx_sched_out() will clear EVENT_TIME when is_active has
> no EVENT_ALL and it'll stop the context time anyway, right?
>
Hmm, I knew I was missing something. Let me ponder rhat a bit more, and
maybe read some of the history on this thing back to remember what exact
issue was being fixed here.
>
>
> > add_event_to_ctx(event, ctx);
> > - ctx_resched(cpuctx, task_ctx, get_event_type(event));
> > + ctx_resched(cpuctx, task_ctx, event->pmu_ctx->pmu,
> > + get_event_type(event));
> > } else {
> > add_event_to_ctx(event, ctx);
> > }