Re: [PATCH] sched/fair: add !se->on_rq check before dequeue entity

From: chenqiwu
Date: Thu Feb 20 2020 - 09:42:58 EST


>
> Hmm i have been too quick in my reply. I wanted to say:
> AFAICT, there is no other way to dequeue a task from a cfs_rq for
> which the group entity is not enqueued

But we should notice the potential racy pathes called by deactivate_task().
For example:
One path is dequeue a task from its cfs_rq called by schedule():
__schedule
deactivate_task
dequeue_task
dequeue_task_fair

Another path is trying to migrate the same task to a CPU on the preferred node:
numa_migrate_preferred
task_numa_migrate
migrate_swap
stop_two_cpus
migrate_swap_stop
__migrate_swap_task
deactivate_task
dequeue_task_fair

There could be a racy if the task is dequeued form its cfs_rq in parallel.