public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Migrated CFS task getting an unfair advantage
@ 2016-03-09  9:22 Pavan Kondeti
  2016-03-09 12:04 ` Peter Zijlstra
  0 siblings, 1 reply; 8+ messages in thread
From: Pavan Kondeti @ 2016-03-09  9:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: peterz

Hi

When a CFS task is enqueued during migration (load balance or change in
affinity), its vruntime is normalized before updating the current and
cfs_rq->min_vruntime. If the current entity is a low priority task or
belongs to a cgroup that has lower cpu.shares and it is the only entity
queued, there is a possibility of big update to the cfs_rq->min_vruntime.
As the migrated task is normalized before this update, it gets an unfair
advantage over tasks queued after this point. If the migrated task is
a CPU hogger, the other CFS tasks queued on this CPU gets starved.

This problem can be simulated by running the below workload:

- create NR_CPU low prio CFS tasks affined to each CPU and put them
under a cgroup with cpu.shares = 52 (1024/20). These tasks run forever.
- create another CFS task which runs forever and periodically hops across
all CPUs by changing the affinity.
- We could see the destination CPU's cfs_rq->min_vruntime falls behind
the migrated task by few hundreds of msec after migration.

If we add the migrated task to destination CPU cfs_rq's rb tree before updating
the current in enqueue_entity(), the cfs_rq->min_vruntime does not go beyond
the newly migrated task. Is this an acceptable solution?

Thanks,
Pavan


-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-05-09 15:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-09  9:22 Migrated CFS task getting an unfair advantage Pavan Kondeti
2016-03-09 12:04 ` Peter Zijlstra
2016-03-09 13:06   ` pavankumar kondeti
2016-03-09 19:00     ` Andrew Hunter
2016-03-09 19:21       ` Peter Zijlstra
2016-03-09 23:48       ` Byungchul Park
2016-05-09 15:28       ` Peter Zijlstra
2016-03-21 11:16   ` [tip:sched/urgent] sched/fair: Fix fairness issue on migration tip-bot for Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox