/* Attempt to migrate a task to a CPU on the preferred node. */
static void numa_migrate_preferred(struct task_struct *p)
{
- /* Success if task is already running on preferred CPU */
- p->numa_migrate_retry = 0;
- if (cpu_to_node(task_cpu(p)) == p->numa_preferred_nid)
+ /* This task has no NUMA fault statistics yet */
+ if (unlikely(p->numa_preferred_nid == -1 || !p->numa_faults))
return;
- /* This task has no NUMA fault statistics yet */
- if (unlikely(p->numa_preferred_nid == -1))
+ /* Periodically retry migrating the task to the preferred node */
+ p->numa_migrate_retry = jiffies + HZ;
+
+ /* Success if task is already running on preferred CPU */
+ if (cpu_to_node(task_cpu(p)) == p->numa_preferred_nid)
return;
/* Otherwise, try migrate to a CPU on the preferred node */
- if (task_numa_migrate(p) != 0)
- p->numa_migrate_retry = jiffies + HZ*5;
+ task_numa_migrate(p);
}
/*
task_numa_placement(p);
- /* Retry task to preferred node migration if it previously failed */
- if (p->numa_migrate_retry && time_after(jiffies, p->numa_migrate_retry))
+ /*
+ * Retry task to preferred node migration periodically, in case it
+ * case it previously failed, or the scheduler moved us.
+ */
+ if (time_after(jiffies, p->numa_migrate_retry))
numa_migrate_preferred(p);
if (migrated)