Re: [PATCH 04/19] sched/numa: Set preferred_node based on best_cpu

From: Srikar Dronamraju
Date: Mon Jun 04 2018 - 08:53:33 EST


* Peter Zijlstra <peterz@xxxxxxxxxxxxx> [2018-06-04 14:18:00]:

> On Mon, Jun 04, 2018 at 03:30:13PM +0530, Srikar Dronamraju wrote:
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index ea32a66..94091e6 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -1725,8 +1725,9 @@ static int task_numa_migrate(struct task_struct *p)
> > * Tasks that are "trapped" in such domains cannot be migrated
> > * elsewhere, so there is no point in (re)trying.
> > */
> > - if (unlikely(!sd)) {
> > - p->numa_preferred_nid = task_node(p);
> > + if (unlikely(!sd) && p->numa_preferred_nid != task_node(p)) {
> > + /* Set the new preferred node */
> > + sched_setnuma(p, task_node(p));
> > return -EINVAL;
> > }
> >
>
> That looks dodgy.. this would allow things to continue with !sd.

Okay so are we suggesting something like the below?

if (unlikely(!sd)) {
/* Set the new preferred node */
sched_setnuma(p, task_node(p));
return -EINVAL;
}

The reason for using sched_setnuma was to make sure we account numa
tasks correctly.