diff options
author | Misha Wagner <mishaw@google.com> | 2022-02-16 18:10:02 +0000 |
---|---|---|
committer | Misha Wagner <mishaw@google.com> | 2022-03-25 15:54:53 +0000 |
commit | 8357b5818d8789968ef3062392c35ee156fb10eb (patch) | |
tree | 48142efc4a2cb47f27dfc93f319917d6e2af285e /power-libperfmgr | |
parent | 62bf939e9aec933e36a5bef063192ad501156a18 (diff) |
Don't fail when acpu_stats is non-monotonic.
This seems to happen very rarely. Submitting this client-side fix which
can be rolled back if we find a root cause.
Test: atest libadaptivecpu_test:KernelCpuFeatureReaderTest
Bug: 219960248
Change-Id: Ibbb54e94a7dbea42adf016bcbbc5f3d9fc63f9c9
Merged-In: Ibbb54e94a7dbea42adf016bcbbc5f3d9fc63f9c9
(cherry picked from commit a0d958ddbe4bff7150744d87ea7fa1c9fbf2db0a)
Diffstat (limited to 'power-libperfmgr')
-rw-r--r-- | power-libperfmgr/adaptivecpu/KernelCpuFeatureReader.cpp | 16 | ||||
-rw-r--r-- | power-libperfmgr/adaptivecpu/tests/KernelCpuFeatureReaderTest.cpp | 12 |
2 files changed, 16 insertions, 12 deletions
diff --git a/power-libperfmgr/adaptivecpu/KernelCpuFeatureReader.cpp b/power-libperfmgr/adaptivecpu/KernelCpuFeatureReader.cpp index 794a16e..087f03d 100644 --- a/power-libperfmgr/adaptivecpu/KernelCpuFeatureReader.cpp +++ b/power-libperfmgr/adaptivecpu/KernelCpuFeatureReader.cpp @@ -58,10 +58,10 @@ bool KernelCpuFeatureReader::GetRecentCpuFeatures( // So, we only read the first CPU in each policy. const size_t statsIdx = CPU_POLICY_INDICES[i]; if (stats[statsIdx].weighted_sum_freq < mPreviousStats[statsIdx].weighted_sum_freq) { - LOG(ERROR) << "New weighted_sum_freq is less than old: new=" - << stats[statsIdx].weighted_sum_freq - << ", old=" << mPreviousStats[statsIdx].weighted_sum_freq; - return false; + LOG(WARNING) << "New weighted_sum_freq is less than old: new=" + << stats[statsIdx].weighted_sum_freq + << ", old=" << mPreviousStats[statsIdx].weighted_sum_freq; + mPreviousStats[statsIdx].weighted_sum_freq = stats[statsIdx].weighted_sum_freq; } (*cpuPolicyAverageFrequencyHz)[i] = static_cast<double>(stats[statsIdx].weighted_sum_freq - @@ -70,10 +70,10 @@ bool KernelCpuFeatureReader::GetRecentCpuFeatures( } for (size_t i = 0; i < NUM_CPU_CORES; i++) { if (stats[i].total_idle_time_ns < mPreviousStats[i].total_idle_time_ns) { - LOG(ERROR) << "New total_idle_time_ns is less than old: new=" - << stats[i].total_idle_time_ns - << ", old=" << mPreviousStats[i].total_idle_time_ns; - return false; + LOG(WARNING) << "New total_idle_time_ns is less than old: new=" + << stats[i].total_idle_time_ns + << ", old=" << mPreviousStats[i].total_idle_time_ns; + mPreviousStats[i].total_idle_time_ns = stats[i].total_idle_time_ns; } (*cpuCoreIdleTimesPercentage)[i] = static_cast<double>(stats[i].total_idle_time_ns - diff --git a/power-libperfmgr/adaptivecpu/tests/KernelCpuFeatureReaderTest.cpp b/power-libperfmgr/adaptivecpu/tests/KernelCpuFeatureReaderTest.cpp index f5cd51a..9e0ba03 100644 --- a/power-libperfmgr/adaptivecpu/tests/KernelCpuFeatureReaderTest.cpp +++ b/power-libperfmgr/adaptivecpu/tests/KernelCpuFeatureReaderTest.cpp @@ -107,7 +107,7 @@ TEST(KernelCpuFeatureReaderTest, noFile) { ASSERT_FALSE(reader.Init()); } -TEST(KernelCpuFeatureReaderTest, frequencies_negativeDiff) { +TEST(KernelCpuFeatureReaderTest, frequencies_capsNegativeDiff) { std::unique_ptr<MockFilesystem> filesystem = std::make_unique<MockFilesystem>(); std::unique_ptr<MockTimeSource> timeSource = std::make_unique<MockTimeSource>(); @@ -149,11 +149,13 @@ TEST(KernelCpuFeatureReaderTest, frequencies_negativeDiff) { std::array<double, NUM_CPU_POLICIES> cpuPolicyAverageFrequencyHz; std::array<double, NUM_CPU_CORES> cpuCoreIdleTimesPercentage; - ASSERT_FALSE( + ASSERT_TRUE( reader.GetRecentCpuFeatures(&cpuPolicyAverageFrequencyHz, &cpuCoreIdleTimesPercentage)); + std::array<double, NUM_CPU_POLICIES> expectedFrequencies{{0}}; + ASSERT_EQ(cpuPolicyAverageFrequencyHz, expectedFrequencies); } -TEST(KernelCpuFeatureReaderTest, idleTimes_negativeDiff) { +TEST(KernelCpuFeatureReaderTest, idleTimes_capsNegativeDiff) { std::unique_ptr<MockFilesystem> filesystem = std::make_unique<MockFilesystem>(); std::unique_ptr<MockTimeSource> timeSource = std::make_unique<MockTimeSource>(); @@ -195,8 +197,10 @@ TEST(KernelCpuFeatureReaderTest, idleTimes_negativeDiff) { std::array<double, NUM_CPU_POLICIES> cpuPolicyAverageFrequencyHz; std::array<double, NUM_CPU_CORES> cpuCoreIdleTimesPercentage; - ASSERT_FALSE( + ASSERT_TRUE( reader.GetRecentCpuFeatures(&cpuPolicyAverageFrequencyHz, &cpuCoreIdleTimesPercentage)); + std::array<double, NUM_CPU_CORES> expectedIdleTimes{{0}}; + ASSERT_EQ(cpuCoreIdleTimesPercentage, expectedIdleTimes); } } // namespace pixel |