• R
    cpuidle: menu: Avoid computations when result will be discarded · 1e3910c7
    Rafael J. Wysocki 提交于
    mainline inclusion
    from mainline-5.14-rc7
    commit f1c8e410
    category: bugfix
    bugzilla: https://gitee.com/openeuler/kernel/issues/I48J5M
    CVE: NA
    
    -------------------------------------------------
    
    bug: 73520
    
    If the minimum interval taken into account in the average computation
    loop in get_typical_interval() is less than the expected idle
    duration determined so far, the resultant average cannot be greater
    than that value as well and the entire return result of the function
    is going to be discarded anyway going forward.
    
    In that case, it is a waste of time to carry out the remaining
    computations in get_typical_interval(), so avoid that by returning
    early if the minimum interval is not below the expected idle duration.
    
    [liuyun01@kylinos.cn: in theory, this patch did not do much work, but
    due to the addition of the previous patch eee4b653 ("cpuidle:
    menu: Avoid overflows when computing variance"), the value of thresh
    was adjusted from UINT_MAX to INT_MAX, which led to the possibility
    of dividing by 0, which eventually led to panic.]
    
    Fixes: eee4b653 ("cpuidle: menu: Avoid overflows when computing variance")
    (cherry-picked from f1c8e410)
    Cc: stable
    Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>		# openEuler_contributor
    Tested-by: Nkernelbot <kernel-bot@kylinos.cn>
    Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
    Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
    1e3910c7
menu.c 19.0 KB