Avoid integer underflow involving maxFreqCount.
If a device does not have any policy directories under /sys/devices/system/cpu/cpufreq this would previously lead to the cputimeinstate subsystem being initialized with an empty set of policy frequencies. This would lead to integer underflows in various loops that enumerate the frequencies when subtracting 1 from a maxFreqCount variable calculated as 0, resulting in us spending a significant amount of time in these loops, likely leading to an ANR in system_server since at least the loop in clearUidTimes is executed while holding the BatteryStatsImpl lock. Fix the problem by skipping the initialization of cputimeinstate if there are no policy directories. Bug: 142352330 Bug: 178231152 Change-Id: I2ec1e8de0fe2a40ed100c8f14e6ca3f6d6285b82
Loading
Please register or sign in to comment