]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sched/numa: Fix a possible divide-by-zero
authorXie XiuQi <xiexiuqi@huawei.com>
Sat, 20 Apr 2019 08:34:16 +0000 (16:34 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Aug 2019 11:39:16 +0000 (12:39 +0100)
commitf007a3d2a304a1d78aca6c761ad4436504d5063a
tree67e1374183ccb8075e9df8f4eaa26a17ed784544
parent2d399f685b07d23fdd4a8d3b1a1ea8c9f2dd9457
sched/numa: Fix a possible divide-by-zero

commit a860fa7b96e1a1c974556327aa1aee852d434c21 upstream.

sched_clock_cpu() may not be consistent between CPUs. If a task
migrates to another CPU, then se.exec_start is set to that CPU's
rq_clock_task() by update_stats_curr_start(). Specifically, the new
value might be before the old value due to clock skew.

So then if in numa_get_avg_runtime() the expression:

  'now - p->last_task_numa_placement'

ends up as -1, then the divider '*period + 1' in task_numa_placement()
is 0 and things go bang. Similar to update_curr(), check if time goes
backwards to avoid this.

[ peterz: Wrote new changelog. ]
[ mingo: Tweaked the code comment. ]

Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: cj.chengjian@huawei.com
Link: http://lkml.kernel.org/r/20190425080016.GX11158@hirez.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
kernel/sched/fair.c