diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-15 02:02:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-15 02:02:49 -0400 |
commit | d83a4c116c4e723840bf9efc47c33ea40c70691b (patch) | |
tree | 7dfd6585ba69807aba422892e7f4108afdd22b4a | |
parent | f97d10454e4da2aceb44dfa7c59bb43ba9f50199 (diff) | |
parent | d60585c5766e9620d5d83e2b25dc042c7bdada2c (diff) |
Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fix from Ingo Molnar:
"Fix a CPU hotplug related corruption of the load average that got
introduced in this merge window"
* 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
sched/core: Correct off by one bug in load migration calculation
-rw-r--r-- | kernel/sched/core.c | 6 | ||||
-rw-r--r-- | kernel/sched/loadavg.c | 8 | ||||
-rw-r--r-- | kernel/sched/sched.h | 2 |
3 files changed, 9 insertions, 7 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 51d7105f529a..97ee9ac7e97c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -5394,13 +5394,15 @@ void idle_task_exit(void) | |||
5394 | /* | 5394 | /* |
5395 | * Since this CPU is going 'away' for a while, fold any nr_active delta | 5395 | * Since this CPU is going 'away' for a while, fold any nr_active delta |
5396 | * we might have. Assumes we're called after migrate_tasks() so that the | 5396 | * we might have. Assumes we're called after migrate_tasks() so that the |
5397 | * nr_active count is stable. | 5397 | * nr_active count is stable. We need to take the teardown thread which |
5398 | * is calling this into account, so we hand in adjust = 1 to the load | ||
5399 | * calculation. | ||
5398 | * | 5400 | * |
5399 | * Also see the comment "Global load-average calculations". | 5401 | * Also see the comment "Global load-average calculations". |
5400 | */ | 5402 | */ |
5401 | static void calc_load_migrate(struct rq *rq) | 5403 | static void calc_load_migrate(struct rq *rq) |
5402 | { | 5404 | { |
5403 | long delta = calc_load_fold_active(rq); | 5405 | long delta = calc_load_fold_active(rq, 1); |
5404 | if (delta) | 5406 | if (delta) |
5405 | atomic_long_add(delta, &calc_load_tasks); | 5407 | atomic_long_add(delta, &calc_load_tasks); |
5406 | } | 5408 | } |
diff --git a/kernel/sched/loadavg.c b/kernel/sched/loadavg.c index b0b93fd33af9..a2d6eb71f06b 100644 --- a/kernel/sched/loadavg.c +++ b/kernel/sched/loadavg.c | |||
@@ -78,11 +78,11 @@ void get_avenrun(unsigned long *loads, unsigned long offset, int shift) | |||
78 | loads[2] = (avenrun[2] + offset) << shift; | 78 | loads[2] = (avenrun[2] + offset) << shift; |
79 | } | 79 | } |
80 | 80 | ||
81 | long calc_load_fold_active(struct rq *this_rq) | 81 | long calc_load_fold_active(struct rq *this_rq, long adjust) |
82 | { | 82 | { |
83 | long nr_active, delta = 0; | 83 | long nr_active, delta = 0; |
84 | 84 | ||
85 | nr_active = this_rq->nr_running; | 85 | nr_active = this_rq->nr_running - adjust; |
86 | nr_active += (long)this_rq->nr_uninterruptible; | 86 | nr_active += (long)this_rq->nr_uninterruptible; |
87 | 87 | ||
88 | if (nr_active != this_rq->calc_load_active) { | 88 | if (nr_active != this_rq->calc_load_active) { |
@@ -188,7 +188,7 @@ void calc_load_enter_idle(void) | |||
188 | * We're going into NOHZ mode, if there's any pending delta, fold it | 188 | * We're going into NOHZ mode, if there's any pending delta, fold it |
189 | * into the pending idle delta. | 189 | * into the pending idle delta. |
190 | */ | 190 | */ |
191 | delta = calc_load_fold_active(this_rq); | 191 | delta = calc_load_fold_active(this_rq, 0); |
192 | if (delta) { | 192 | if (delta) { |
193 | int idx = calc_load_write_idx(); | 193 | int idx = calc_load_write_idx(); |
194 | 194 | ||
@@ -389,7 +389,7 @@ void calc_global_load_tick(struct rq *this_rq) | |||
389 | if (time_before(jiffies, this_rq->calc_load_update)) | 389 | if (time_before(jiffies, this_rq->calc_load_update)) |
390 | return; | 390 | return; |
391 | 391 | ||
392 | delta = calc_load_fold_active(this_rq); | 392 | delta = calc_load_fold_active(this_rq, 0); |
393 | if (delta) | 393 | if (delta) |
394 | atomic_long_add(delta, &calc_load_tasks); | 394 | atomic_long_add(delta, &calc_load_tasks); |
395 | 395 | ||
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 7cbeb92a1cb9..898c0d2f18fe 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h | |||
@@ -28,7 +28,7 @@ extern unsigned long calc_load_update; | |||
28 | extern atomic_long_t calc_load_tasks; | 28 | extern atomic_long_t calc_load_tasks; |
29 | 29 | ||
30 | extern void calc_global_load_tick(struct rq *this_rq); | 30 | extern void calc_global_load_tick(struct rq *this_rq); |
31 | extern long calc_load_fold_active(struct rq *this_rq); | 31 | extern long calc_load_fold_active(struct rq *this_rq, long adjust); |
32 | 32 | ||
33 | #ifdef CONFIG_SMP | 33 | #ifdef CONFIG_SMP |
34 | extern void cpu_load_update_active(struct rq *this_rq); | 34 | extern void cpu_load_update_active(struct rq *this_rq); |