public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Phil Auld <pauld@redhat.com>
To: bsegall@google.com
Cc: Dave Chiluk <chiluk+linux@indeed.com>, Qian Cai <cai@lca.pw>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next v2] sched/fair: fix -Wunused-but-set-variable warnings
Date: Fri, 23 Aug 2019 14:03:42 -0400	[thread overview]
Message-ID: <20190823180342.GC14209@pauld.bos.csb> (raw)
In-Reply-To: <xm26h867iyfx.fsf@bsegall-linux.svl.corp.google.com>

On Fri, Aug 23, 2019 at 10:28:02AM -0700 bsegall@google.com wrote:
> Dave Chiluk <chiluk+linux@indeed.com> writes:
> 
> > On Wed, Aug 21, 2019 at 12:36 PM <bsegall@google.com> wrote:
> >>
> >> Qian Cai <cai@lca.pw> writes:
> >>
> >> > The linux-next commit "sched/fair: Fix low cpu usage with high
> >> > throttling by removing expiration of cpu-local slices" [1] introduced a
> >> > few compilation warnings,
> >> >
> >> > kernel/sched/fair.c: In function '__refill_cfs_bandwidth_runtime':
> >> > kernel/sched/fair.c:4365:6: warning: variable 'now' set but not used
> >> > [-Wunused-but-set-variable]
> >> > kernel/sched/fair.c: In function 'start_cfs_bandwidth':
> >> > kernel/sched/fair.c:4992:6: warning: variable 'overrun' set but not used
> >> > [-Wunused-but-set-variable]
> >> >
> >> > Also, __refill_cfs_bandwidth_runtime() does no longer update the
> >> > expiration time, so fix the comments accordingly.
> >> >
> >> > [1] https://lore.kernel.org/lkml/1558121424-2914-1-git-send-email-chiluk+linux@indeed.com/
> >> >
> >> > Signed-off-by: Qian Cai <cai@lca.pw>
> >>
> >> Reviewed-by: Ben Segall <bsegall@google.com>
> >>
> >> > ---
> >> >
> >> > v2: Keep hrtimer_forward_now() in start_cfs_bandwidth() per Ben.
> >> >
> >> >  kernel/sched/fair.c | 19 ++++++-------------
> >> >  1 file changed, 6 insertions(+), 13 deletions(-)
> >> >
> >> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> >> > index 84959d3285d1..06782491691f 100644
> >> > --- a/kernel/sched/fair.c
> >> > +++ b/kernel/sched/fair.c
> >> > @@ -4354,21 +4354,16 @@ static inline u64 sched_cfs_bandwidth_slice(void)
> >> >  }
> >> >
> >> >  /*
> >> > - * Replenish runtime according to assigned quota and update expiration time.
> >> > - * We use sched_clock_cpu directly instead of rq->clock to avoid adding
> >> > - * additional synchronization around rq->lock.
> >> > + * Replenish runtime according to assigned quota. We use sched_clock_cpu
> >> > + * directly instead of rq->clock to avoid adding additional synchronization
> >> > + * around rq->lock.
> >> >   *
> >> >   * requires cfs_b->lock
> >> >   */
> >> >  void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b)
> >> >  {
> >> > -     u64 now;
> >> > -
> >> > -     if (cfs_b->quota == RUNTIME_INF)
> >> > -             return;
> >> > -
> >> > -     now = sched_clock_cpu(smp_processor_id());
> >> > -     cfs_b->runtime = cfs_b->quota;
> >> > +     if (cfs_b->quota != RUNTIME_INF)
> >> > +             cfs_b->runtime = cfs_b->quota;
> >> >  }
> >> >
> >> >  static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg)
> >> > @@ -4989,15 +4984,13 @@ static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq)
> >> >
> >> >  void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
> >> >  {
> >> > -     u64 overrun;
> >> > -
> >> >       lockdep_assert_held(&cfs_b->lock);
> >> >
> >> >       if (cfs_b->period_active)
> >> >               return;
> >> >
> >> >       cfs_b->period_active = 1;
> >> > -     overrun = hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period);
> >> > +     hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period);
> >> >       hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED);
> >> >  }
> >
> > Looks good.
> > Reviewed-by: Dave Chiluk <chiluk+linux@indeed.com>
> >
> > Sorry for the slow response, I was on vacation.
> >
> > @Ben do you think it would be useful to still capture overrun, and
> > WARN on any overruns?  We wouldn't expect overruns, but their
> > existence would indicate an over-loaded node or too short of a
> > cfs_period.  Additionally, it would be interesting to see if we could
> > capture the offset between when the bandwidth was refilled, and when
> > the timer was supposed to fire.  I've always done all my calculations
> > assuming that the timer fires and is handled exceedingly close to the
> > time it was supposed to fire.  Although, if the node is running that
> > overloaded you probably have many more problems than worrying about
> > timer warnings.
> 
> That "overrun" there is not really an overrun - it's the number of
> complete periods the timer has been inactive for. It was used so that a
> given tg's period timer would keep the same
> phase/offset/whatever-you-call-it, even if it goes idle for a while,
> rather than having the next period start N ms after a task wakes up.
> 
> Also, poor choices by userspace is not generally something the kernel
> generally WARNs on, as I understand it.

I don't think it matters in the start_cfs_bandwidth case, anyway. We do 
effectively check in sched_cfs_period_timer. 

Cleanup looks okay to me as well.


Cheers,
Phil

-- 

  reply	other threads:[~2019-08-23 18:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 18:40 [PATCH -next v2] sched/fair: fix -Wunused-but-set-variable warnings Qian Cai
2019-08-21 17:36 ` bsegall
2019-08-23 14:48   ` Dave Chiluk
2019-08-23 17:28     ` bsegall
2019-08-23 18:03       ` Phil Auld [this message]
2019-09-03 13:03 ` Qian Cai
2019-09-03 14:15   ` Peter Zijlstra
2019-09-10 20:58     ` Qian Cai
2019-09-16 13:45       ` Qian Cai
2019-09-27  8:10 ` [tip: sched/urgent] sched/fair: Fix " tip-bot2 for Qian Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190823180342.GC14209@pauld.bos.csb \
    --to=pauld@redhat.com \
    --cc=bsegall@google.com \
    --cc=cai@lca.pw \
    --cc=chiluk+linux@indeed.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox