Re: [PATCH -next v2] sched/fair: fix -Wunused-but-set-variable warnings
From: Qian Cai
Date: Mon Sep 16 2019 - 09:45:52 EST
Ingo, I saw you sent a pull request to Linus including the commit introduced the
warnings,
https://lkml.org/lkml/2019/9/16/309
but seems not yet picked up the fix here,
https://lore.kernel.org/lkml/20190903141554.GS2349@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
et/
On Tue, 2019-09-10 at 16:58 -0400, Qian Cai wrote:
> On Tue, 2019-09-03 at 16:15 +0200, Peter Zijlstra wrote:
> > On Tue, Sep 03, 2019 at 09:03:26AM -0400, Qian Cai wrote:
> > > Ingo or Peter, please take a look at this trivial patch. Still see the warning
> > > in linux-next every day.
> > >
> > > On Tue, 2019-08-20 at 14:40 -0400, Qian Cai wrote:
> > > > 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@xxxxxx>
> >
> > Rewrote the Changelog like so:
>
> Looks good. I suppose it still need Ingo to pick it up, as today's tip/auto-
> latest still show those warnings.
>
> >
> > ---
> > Subject: sched/fair: Fix -Wunused-but-set-variable warnings
> > From: Qian Cai <cai@xxxxxx>
> > Date: Tue, 20 Aug 2019 14:40:55 -0400
> >
> > Commit de53fd7aedb1 ("sched/fair: Fix low cpu usage with high
> > throttling by removing expiration of cpu-local slices") 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.
> >
> > Fixes: de53fd7aedb1 ("sched/fair: Fix low cpu usage with high throttling by removing expiration of cpu-local slices")
> > Signed-off-by: Qian Cai <cai@xxxxxx>
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> > Reviewed-by: Ben Segall <bsegall@xxxxxxxxxx>
> > Reviewed-by: Dave Chiluk <chiluk+linux@xxxxxxxxxx>
> > Cc: mingo@xxxxxxxxxx
> > Cc: pauld@xxxxxxxxxx
> > Link: https://lkml.kernel.org/r/1566326455-8038-1-git-send-email-cai@xxxxxx
> > ---
> > kernel/sched/fair.c | 19 ++++++-------------
> > 1 file changed, 6 insertions(+), 13 deletions(-)
> >
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -4386,21 +4386,16 @@ static inline u64 sched_cfs_bandwidth_sl
> > }
> >
> > /*
> > - * 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)
> > @@ -5021,15 +5016,13 @@ static void init_cfs_rq_runtime(struct c
> >
> > 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);
> > }
> >