Patch "sched/fair: Fix wrong negative conversion in find_energy_efficient_cpu()" has been added to the 5.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    sched/fair: Fix wrong negative conversion in find_energy_efficient_cpu()

to the 5.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     sched-fair-fix-wrong-negative-conversion-in-find_ene.patch
and it can be found in the queue-5.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1c63dbec2b68963b66a50d9d3f82221fe31c9d1d
Author: Lukasz Luba <lukasz.luba@xxxxxxx>
Date:   Mon Aug 10 09:30:04 2020 +0100

    sched/fair: Fix wrong negative conversion in find_energy_efficient_cpu()
    
    [ Upstream commit da0777d35f47892f359c3f73ea155870bb595700 ]
    
    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: 1d42509e475cd ("sched/fair: Make EAS wakeup placement consider uclamp restrictions")
    Signed-off-by: Lukasz Luba <lukasz.luba@xxxxxxx>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
    Reviewed-by: Valentin Schneider <valentin.schneider@xxxxxxx>
    Link: https://lkml.kernel.org/r/20200810083004.26420-1-lukasz.luba@xxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1a68a0536adda..51408ebd76c27 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6594,7 +6594,8 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 
 			util = cpu_util_next(cpu, p, cpu);
 			cpu_cap = capacity_of(cpu);
-			spare_cap = cpu_cap - util;
+			spare_cap = cpu_cap;
+			lsub_positive(&spare_cap, util);
 
 			/*
 			 * Skip CPUs that cannot satisfy the capacity request.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux