On Wed, Mar 17, 2021 at 1:31 AM Ingo Molnar <mi...@kernel.org> wrote:
>
>
> * Josh Don <josh...@google.com> wrote:
>
> > +static inline u64 resched_latency_check(struct rq *rq)
> > +{
> > +     int latency_warn_ms = READ_ONCE(sysctl_resched_latency_warn_ms);
> > +     bool warn_only_once = (latency_warn_ms == 
> > RESCHED_DEFAULT_WARN_LATENCY_MS);
> > +     u64 need_resched_latency, now = rq_clock(rq);
> > +     static bool warned_once;
> > +
> > +     if (warn_only_once && warned_once)
> > +             return 0;
> > +
> > +     if (!need_resched() || latency_warn_ms < 2)
> > +             return 0;
> > +
> > +     /* Disable this warning for the first few mins after boot */
> > +     if (now < RESCHED_BOOT_QUIET_SEC * NSEC_PER_SEC)
> > +             return 0;
> > +
> > +     if (!rq->last_seen_need_resched_ns) {
> > +             rq->last_seen_need_resched_ns = now;
> > +             rq->ticks_without_resched = 0;
> > +             return 0;
> > +     }
> > +
> > +     rq->ticks_without_resched++;
>
> So AFAICS this will only really do something useful on full-nohz
> kernels with sufficiently long scheduler ticks, right?

Not quite sure what you mean; it is actually the inverse? Since we
rely on the tick to detect the resched latency, on nohz-full we won't
have detection on cpus running a single thread. The ideal scenario is
!nohz-full and tick interval << warn_ms.

> On other kernels the scheduler tick interrupt, when it returns to
> user-space, will trigger a reschedule if it sees a need_resched.

True for the case where we return to userspace, but we could instead
be executing in a non-preemptible region of the kernel. This is where
we've seen/fixed kernel bugs.

Best,
Josh

Reply via email to