Re: [RFC][PATCH 9/9] cpuidle: Use local_clock_noinstr()

From: Peter Zijlstra
Date: Tue May 09 2023 - 15:03:56 EST


On Tue, May 09, 2023 at 06:18:08PM +0200, Rafael J. Wysocki wrote:
> On Mon, May 8, 2023 at 11:34 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> > --- a/drivers/cpuidle/poll_state.c
> > +++ b/drivers/cpuidle/poll_state.c
> > @@ -15,7 +15,7 @@ static int __cpuidle poll_idle(struct cp
> > {
> > u64 time_start;
> >
> > - time_start = local_clock();
> > + time_start = local_clock_noinstr();
> >
> > dev->poll_time_limit = false;
> >
> > @@ -32,7 +32,7 @@ static int __cpuidle poll_idle(struct cp
> > continue;
> >
> > loop_count = 0;
> > - if (local_clock() - time_start > limit) {
> > + if (local_clock_noinstr() - time_start > limit) {
> > dev->poll_time_limit = true;
> > break;
> > }
> >
>
> The above LGTM, but the teo governors uses local_clock() too. Should
> it use the _noinstr() version?

Only the callsites from noinstr or __cpuidle functions, IIRC the
governors are neither and should be OK.