Re: [tip:sched/core] sched/fair: Use rq_lock/unlock in online_fair_sched_group

From: Phil Auld
Date: Fri Aug 09 2019 - 13:28:43 EST


On Fri, Aug 09, 2019 at 06:21:22PM +0200 Dietmar Eggemann wrote:
> On 8/8/19 1:01 PM, tip-bot for Phil Auld wrote:
>
> [...]
>
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 19c58599e967..d9407517dae9 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -10281,18 +10281,18 @@ err:
> > void online_fair_sched_group(struct task_group *tg)
> > {
> > struct sched_entity *se;
> > + struct rq_flags rf;
> > struct rq *rq;
> > int i;
> >
> > for_each_possible_cpu(i) {
> > rq = cpu_rq(i);
> > se = tg->se[i];
> > -
> > - raw_spin_lock_irq(&rq->lock);
> > + rq_lock(rq, &rf);
> > update_rq_clock(rq);
> > attach_entity_cfs_rq(se);
> > sync_throttle(tg, i);
> > - raw_spin_unlock_irq(&rq->lock);
> > + rq_unlock(rq, &rf);
> > }
> > }
>
> Shouldn't this be:
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index d9407517dae9..1054d2cf6aaa 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -10288,11 +10288,11 @@ void online_fair_sched_group(struct task_group
> *tg)
> for_each_possible_cpu(i) {
> rq = cpu_rq(i);
> se = tg->se[i];
> - rq_lock(rq, &rf);
> + rq_lock_irq(rq, &rf);
> update_rq_clock(rq);
> attach_entity_cfs_rq(se);
> sync_throttle(tg, i);
> - rq_unlock(rq, &rf);
> + rq_unlock_irq(rq, &rf);
> }
> }
>
> Currently, you should get a 'inconsistent lock state' warning with
> CONFIG_PROVE_LOCKING.

Yes, indeed. Sorry about that. Maybe it can be fixed in tip before
it gets any farther? Or do we need a new patch?


Cheers,
Phil

--