]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commit
sched/fair: Fix and optimize the fork() path
authorPeter Zijlstra <peterz@infradead.org>
Thu, 16 Jun 2016 16:51:48 +0000 (18:51 +0200)
committermobile promotions <svcmobile_promotions@nvidia.com>
Mon, 15 Aug 2016 21:05:20 +0000 (14:05 -0700)
commit4d0e77be8fb7a195fb79f769c04b5195a6442618
treea9062c0923c5542e46aa31295e1186c8fe26b41c
parent8c8d43b2ab41f0f197291f0897f1eeb8940c8516
sched/fair: Fix and optimize the fork() path

The task_fork_fair() callback already calls __set_task_cpu() and takes
rq->lock.

If we move the sched_class::task_fork callback in sched_fork() under
the existing p->pi_lock, right after its set_task_cpu() call, we can
avoid doing two such calls and omit the IRQ disabling on the rq->lock.

Change to __set_task_cpu() to skip the migration bits, this is a new
task, not a migration. Similarly, make wake_up_new_task() use
__set_task_cpu() for the same reason, the task hasn't actually
migrated as it hasn't ever ran.

This cures the problem of calling migrate_task_rq_fair(), which does
remove_entity_from_load_avg() on tasks that have never been added to
the load avg to begin with.

This bug would result in transiently messed up load_avg values, averaged
out after a few dozen milliseconds. This is probably the reason why
this bug was not found for such a long time.

Reported-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from upstream commit e210bffd39d01b649c94b820c28ff112673266dd)

Change-Id: I144a551b55b44317b354e26b21913398a9903809
Signed-off-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-on: http://git-master/r/1195367
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Puneet Saxena <puneets@nvidia.com>
Reviewed-by: Matthew Longnecker <mlongnecker@nvidia.com>
kernel/sched/core.c
kernel/sched/fair.c