Messages in this thread | | | Date | Fri, 8 Nov 2019 12:15:26 +0000 | From | Quentin Perret <> | Subject | Re: NULL pointer dereference in pick_next_task_fair |
| |
On Friday 08 Nov 2019 at 13:00:35 (+0100), Peter Zijlstra wrote: > On Fri, Nov 08, 2019 at 11:02:12AM +0000, Quentin Perret wrote: > > On Thursday 07 Nov 2019 at 20:29:07 (+0100), Peter Zijlstra wrote: > > > I still havne't had food, but this here compiles... > > > > And it seems to work, too :) > > Excellent! > > > > @@ -3929,13 +3929,17 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) > > > } > > > > > > restart: > > > - /* > > > - * Ensure that we put DL/RT tasks before the pick loop, such that they > > > - * can PULL higher prio tasks when we lower the RQ 'priority'. > > > - */ > > > - prev->sched_class->put_prev_task(rq, prev, rf); > > > - if (!rq->nr_running) > > > - newidle_balance(rq, rf); > > > +#ifdef CONFIG_SMP > > > + for (class = prev->sched_class; > > > + class != &idle_sched_class; > > > + class = class->next) { > > > + > > > + if (class->balance(rq, prev, rf)) > > > + break; > > > + } > > > +#endif > > > + > > > + put_prev_task(rq, prev); > > > > Right, that looks much cleaner IMO. I'm thinking if we killed the > > special case for CFS above we could do with a single loop to iterate the > > classes, and you could fold ->balance() in ->pick_next_task() ... > > No, you can't, because then you're back to having to restart the pick > when something happens when we drop the rq halfway down the pick. Which > is something I really wanted to get rid of.
Right, with a single loop you'll have to re-iterate the classes from the start in case of RETRY_TASK, but you're re-iterating all the classes too with this patch. You're doing a little less work in the second loop though, so maybe it's worth it. And I was the one worried about refactoring the code too much close to the release, so maybe that's for another time ;)
Thanks, Quentin
| |