Commit b8cb776
UPSTREAM: 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 commit e210bffd39d01b649c94b820c28ff112673266dd)
Change-Id: Icbddbaa6e8c1071859673d8685bc3f38955cf144
Signed-off-by: Brendan Jackman <brendan.jackman@arm.com>
Signed-off-by: Chris Redpath <chris.redpath@arm.com>1 parent ba876f4 commit b8cb776
2 files changed
Lines changed: 17 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2300 | 2300 | | |
2301 | 2301 | | |
2302 | 2302 | | |
2303 | | - | |
2304 | | - | |
2305 | | - | |
2306 | 2303 | | |
2307 | 2304 | | |
2308 | 2305 | | |
| |||
2311 | 2308 | | |
2312 | 2309 | | |
2313 | 2310 | | |
2314 | | - | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
2315 | 2318 | | |
2316 | 2319 | | |
2317 | 2320 | | |
| |||
2453 | 2456 | | |
2454 | 2457 | | |
2455 | 2458 | | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
2456 | 2462 | | |
2457 | | - | |
| 2463 | + | |
2458 | 2464 | | |
2459 | 2465 | | |
2460 | 2466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4712 | 4712 | | |
4713 | 4713 | | |
4714 | 4714 | | |
4715 | | - | |
| 4715 | + | |
4716 | 4716 | | |
4717 | 4717 | | |
4718 | 4718 | | |
| |||
9904 | 9904 | | |
9905 | 9905 | | |
9906 | 9906 | | |
9907 | | - | |
9908 | 9907 | | |
9909 | | - | |
9910 | | - | |
9911 | | - | |
9912 | 9908 | | |
| 9909 | + | |
9913 | 9910 | | |
9914 | 9911 | | |
9915 | 9912 | | |
9916 | 9913 | | |
9917 | | - | |
9918 | | - | |
9919 | | - | |
9920 | | - | |
9921 | | - | |
9922 | | - | |
9923 | | - | |
9924 | | - | |
9925 | | - | |
9926 | | - | |
9927 | | - | |
9928 | | - | |
9929 | | - | |
9930 | | - | |
| 9914 | + | |
| 9915 | + | |
9931 | 9916 | | |
| 9917 | + | |
9932 | 9918 | | |
9933 | 9919 | | |
9934 | 9920 | | |
| |||
9941 | 9927 | | |
9942 | 9928 | | |
9943 | 9929 | | |
9944 | | - | |
9945 | | - | |
| 9930 | + | |
9946 | 9931 | | |
9947 | 9932 | | |
9948 | 9933 | | |
| |||
0 commit comments