summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-05-24 23:25:19 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-05-24 23:25:19 +0000
commitd70df3df2d9698e70b4a88b2335763f30e642b22 (patch)
treeb507ae4608bd2fafe563faa058121efb3da10131
parent993befb369b20a7610136dc5b2592eceaddca69f (diff)
parent5f2d8c987b585ca62fe2d3194776461170b34e39 (diff)
Snap for 10196304 from 5f2d8c987b585ca62fe2d3194776461170b34e39 to udc-release
Change-Id: I563603ca564fc8ea2bde4f693c93c32232518850
-rw-r--r--thermal/thermal-helper.cpp4
-rw-r--r--thermal/utils/thermal_info.h3
-rw-r--r--thermal/utils/thermal_stats_helper.cpp27
3 files changed, 26 insertions, 8 deletions
diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp
index 796da4e..d8883a4 100644
--- a/thermal/thermal-helper.cpp
+++ b/thermal/thermal-helper.cpp
@@ -944,8 +944,8 @@ bool ThermalHelper::readThermalSensor(std::string_view sensor_name, float *temp,
sensor_status.thermal_cached.temp = *temp;
sensor_status.thermal_cached.timestamp = now;
}
-
- thermal_stats_helper_.updateSensorTempStatsByThreshold(sensor_name, *temp);
+ auto real_temp = (*temp) * sensor_info.multiplier;
+ thermal_stats_helper_.updateSensorTempStatsByThreshold(sensor_name, real_temp);
return true;
}
diff --git a/thermal/utils/thermal_info.h b/thermal/utils/thermal_info.h
index da9585a..5b2e8b8 100644
--- a/thermal/utils/thermal_info.h
+++ b/thermal/utils/thermal_info.h
@@ -42,7 +42,8 @@ constexpr std::chrono::milliseconds kMinPollIntervalMs = std::chrono::millisecon
constexpr std::chrono::milliseconds kUeventPollTimeoutMs = std::chrono::milliseconds(300000);
// Max number of time_in_state buckets is 20 in atoms
// VendorSensorCoolingDeviceStats, VendorTempResidencyStats
-constexpr size_t kMaxStatsThresholdCount = 19;
+constexpr int kMaxStatsResidencyCount = 20;
+constexpr int kMaxStatsThresholdCount = kMaxStatsResidencyCount - 1;
enum FormulaOption : uint32_t {
COUNT_THRESHOLD = 0,
diff --git a/thermal/utils/thermal_stats_helper.cpp b/thermal/utils/thermal_stats_helper.cpp
index 27ac319..d9a2a65 100644
--- a/thermal/utils/thermal_stats_helper.cpp
+++ b/thermal/utils/thermal_stats_helper.cpp
@@ -21,6 +21,7 @@
#include <hardware/google/pixel/pixelstats/pixelatoms.pb.h>
#include <algorithm>
+#include <numeric>
#include <string_view>
namespace aidl {
@@ -29,7 +30,8 @@ namespace hardware {
namespace thermal {
namespace implementation {
-constexpr std::string_view kCustomThresholdSetSuffix("-THRESHOLD-LIST-");
+constexpr std::string_view kCustomThresholdSetSuffix("-TH-");
+constexpr std::string_view kCompressedThresholdSuffix("-CMBN-TH");
using aidl::android::frameworks::stats::VendorAtom;
namespace PixelAtoms = ::android::hardware::google::pixel::PixelAtoms;
@@ -109,10 +111,25 @@ bool ThermalStatsHelper::initializeSensorCdevRequestStats(
// Record by all state
if (isRecordByDefaultThreshold(
request_stats_info.record_by_default_threshold_all_or_name_set_, cdev)) {
- // buckets = [0, 1, 2, 3, ...max_state]
- const int default_threshold_time_in_state_size = max_state + 1;
- sensor_cdev_request_stats_map_[sensor][cdev].stats_by_default_threshold =
- StatsRecord(default_threshold_time_in_state_size);
+ // if the number of states is greater / equal(as state starts from 0) than
+ // residency_buckets in atom combine the initial states
+ if (max_state >= kMaxStatsResidencyCount) {
+ // buckets = [max_state -kMaxStatsResidencyCount + 1, ...max_state]
+ // idx = [1, .. max_state - (max_state - kMaxStatsResidencyCount + 1) + 1]
+ // idx = [1, .. kMaxStatsResidencyCount]
+ const auto starting_state = max_state - kMaxStatsResidencyCount + 1;
+ std::vector<int> thresholds(kMaxStatsResidencyCount);
+ std::iota(thresholds.begin(), thresholds.end(), starting_state);
+ const auto logging_name = cdev + kCompressedThresholdSuffix.data();
+ ThresholdList<int> threshold_list(logging_name, thresholds);
+ sensor_cdev_request_stats_map_[sensor][cdev]
+ .stats_by_custom_threshold.emplace_back(threshold_list);
+ } else {
+ // buckets = [0, 1, 2, 3, ...max_state]
+ const auto default_threshold_time_in_state_size = max_state + 1;
+ sensor_cdev_request_stats_map_[sensor][cdev].stats_by_default_threshold =
+ StatsRecord(default_threshold_time_in_state_size);
+ }
LOG(INFO) << "Sensor Cdev user vote stats on basis of all state initialized for ["
<< sensor << "-" << cdev << "]";
}