Commit 1e3910c7 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Cheng Jian
Browse files

cpuidle: menu: Avoid computations when result will be discarded

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>		# openEuler_contributor
Tested-by: default avatarkernelbot <kernel-bot@kylinos.cn>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
parent ff7d1fc3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment