Re: [PATCH 3/6] sched/numa: Notify the scheduling class of preferred node changes
From: K Prateek Nayak
Date: Tue Oct 27 2026 - 01:33:07 EST
Hello Andrea,
On 10/27/2026 9:43 AM, Andrea Righi wrote:
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -8331,8 +8331,13 @@ int migrate_task_to(struct task_struct *p, int target_cpu)
> void sched_setnuma(struct task_struct *p, int nid)
> {
> guard(task_rq_lock)(p);
> - scoped_guard (sched_change, p, DEQUEUE_SAVE)
> + scoped_guard (sched_change, p, DEQUEUE_SAVE) {
> + bool changed = p->numa_preferred_nid != nid;
Don't the callers of sched_setnuma() already check for this?
Only one that doesn't is task_numa_migrate() but
numa_migrate_preferred() only calls it when
"task_node(p) == p->numa_preferred_nid" is false and "!sd "case resets
"p->numa_preferred_nid" to "task_node(p)" when the task cannot be
migrated.
Afaict, "changed" is always true here. Is there a scenario that I might
be missing?
> +
> p->numa_preferred_nid = nid;
> + if (changed && p->sched_class->numa_node_changed)
> + p->sched_class->numa_node_changed(task_rq(p), p, nid);
> + }
> }
> #endif /* CONFIG_NUMA_BALANCING */
--
Thanks and Regards,
Prateek