]> git.baikalelectronics.ru Git - kernel.git/commit
sched/fair: Fix wrong negative conversion in find_energy_efficient_cpu()
authorLukasz Luba <lukasz.luba@arm.com>
Mon, 10 Aug 2020 08:30:04 +0000 (09:30 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 26 Aug 2020 10:41:57 +0000 (12:41 +0200)
commit62c5608ec12bc41e7ab4bf1e312ab9d17afc49d6
treef8331fb265b93c0addddf8ece95d0b8b12fd523f
parente62d4e69c860c8306ec54b88fd797f23a0b61f4d
sched/fair: Fix wrong negative conversion in find_energy_efficient_cpu()

In find_energy_efficient_cpu() 'cpu_cap' could be less that 'util'.
It might be because of RT, DL (so higher sched class than CFS), irq or
thermal pressure signal, which reduce the capacity value.
In such situation the result of 'cpu_cap - util' might be negative but
stored in the unsigned long. Then it might be compared with other unsigned
long when uclamp_rq_util_with() reduced the 'util' such that is passes the
fits_capacity() check.

Prevent this situation and make the arithmetic more safe.

Fixes: 0719c0e4b1b04 ("sched/fair: Make EAS wakeup placement consider uclamp restrictions")
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Link: https://lkml.kernel.org/r/20200810083004.26420-1-lukasz.luba@arm.com
kernel/sched/fair.c