lkml.org 
[lkml]   [2014]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 1/2] sched/update_avg: avoid negative time
    Date
    rq->avg_idle try to reflect the average idle time between the cpu idle
    and first wakeup. But in the function, it maybe get a negative value
    if old avg_idle is too small. Then this negative value will be double
    counted in next time calculation. Guess that is not the original purpose,
    so recalibrate it to zero.

    Signed-off-by: Alex Shi <alex.shi@linaro.org>
    ---
    kernel/sched/core.c | 3 +++
    1 file changed, 3 insertions(+)

    diff --git a/kernel/sched/core.c b/kernel/sched/core.c
    index 30eb011..af9121c6 100644
    --- a/kernel/sched/core.c
    +++ b/kernel/sched/core.c
    @@ -1358,6 +1358,9 @@ static void update_avg(u64 *avg, u64 sample)
    {
    s64 diff = sample - *avg;
    *avg += diff >> 3;
    +
    + if (*avg < 0)
    + *avg = 0;
    }
    #endif

    --
    1.8.1.2


    \
     
     \ /
      Last update: 2014-01-21 07:21    [W:8.551 / U:0.240 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site