aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelly Rossmoyer <krossmo@google.com>2022-04-25 04:17:11 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-04-25 04:17:11 +0000
commitdb5398e4da108b82409873f2b7e82ee306e5dd00 (patch)
tree28bfd4a3132103c24f7608c766901b0664d53735
parentf799b375bb167c0175e36202c2cc1be363714de0 (diff)
parent20b039192d90f6dcbce3905cfe108c5ba8205440 (diff)
downloadgs-common-android13-mainline-media-swcodec-release.tar.gz
Revert "powerstats: timeout mechanism for AoC data provider" am: 20b039192daml_wif_331910020aml_wif_331810010aml_wif_331710030aml_wif_331613000aml_wif_331511020aml_wif_331414000aml_wif_331310070aml_wif_331112000aml_wif_331016070aml_wif_330910030aml_wif_330810040aml_tz4_332714070aml_tz4_332714050aml_tz4_332714010aml_tz4_331910000aml_tz4_331314030aml_tz4_331314020aml_tz4_331314010aml_tz4_331012050aml_tz4_331012040aml_tz4_331012000aml_tet_331910040aml_tet_331820050aml_tet_331711040aml_tet_331511160aml_tet_331511000aml_tet_331412030aml_tet_331312080aml_tet_331117000aml_tet_331012080aml_tet_330911010aml_tet_330812150aml_swc_331911000aml_swc_331712000aml_swc_331612000aml_swc_331511000aml_swc_331410000aml_swc_331318000aml_swc_331116000aml_swc_331012020aml_sta_331910000aml_sta_331811000aml_sta_331711010aml_sta_331610000aml_sta_331511000aml_sta_331410000aml_sta_331311000aml_sta_331010010aml_sta_330910000aml_sdk_331812000aml_sdk_331811100aml_sdk_331811000aml_sdk_331412000aml_sdk_331410000aml_sdk_331310010aml_sdk_331111000aml_sdk_330810050aml_sdk_330810010aml_sch_331113000aml_sch_331111000aml_res_331820000aml_res_331611010aml_res_331512000aml_res_331314010aml_res_331114000aml_res_331011050aml_res_330910000aml_res_330810000aml_per_331913010aml_per_331812030aml_per_331710050aml_per_331611010aml_per_331512020aml_per_331411000aml_per_331313010aml_per_331115020aml_per_331019040aml_per_330912010aml_per_330811030aml_neu_331310000aml_neu_331113000aml_net_331910030aml_net_331812010aml_net_331710000aml_net_331610000aml_net_331412000aml_net_331313030aml_net_331313010aml_net_331110020aml_net_331011030aml_net_330910010aml_net_330811010aml_mpr_331918000aml_mpr_331812020aml_mpr_331711020aml_mpr_331613010aml_mpr_331512020aml_mpr_331412040aml_mpr_331311080aml_mpr_331112050aml_mpr_331112030aml_mpr_331011070aml_mpr_330911040aml_mpr_330811020aml_med_331911000aml_med_331712010aml_med_331612000aml_med_331511000aml_med_331410000aml_med_331318000aml_med_331115000aml_med_331012020aml_ips_331910010aml_ips_331312000aml_ips_331310000aml_ips_331111030aml_ips_331014020aml_ext_331814220aml_ext_331412000aml_ext_331312000aml_ext_331112010aml_ext_331012020aml_doc_331120000aml_con_331413000aml_con_331411000aml_con_331312000aml_con_331115000aml_con_331011010aml_cbr_331910000aml_cbr_331810000aml_cbr_331710020aml_cbr_331610010aml_cbr_331510000aml_cbr_331411000aml_cbr_331310010aml_cbr_331111030aml_cbr_331013010aml_cbr_330911010aml_cbr_330810000aml_art_331813100aml_art_331813010aml_art_331711080aml_art_331612010aml_art_331413030aml_art_331314010aml_art_331113000aml_art_331012050aml_adb_331610000aml_adb_331314020aml_adb_331113120aml_adb_331011050aml_adb_331011040android13-mainline-wifi-releaseandroid13-mainline-tzdata4-releaseandroid13-mainline-tethering-releaseandroid13-mainline-sdkext-releaseandroid13-mainline-scheduling-releaseandroid13-mainline-resolv-releaseandroid13-mainline-permission-releaseandroid13-mainline-os-statsd-releaseandroid13-mainline-networking-releaseandroid13-mainline-mediaprovider-releaseandroid13-mainline-media-swcodec-releaseandroid13-mainline-media-releaseandroid13-mainline-ipsec-releaseandroid13-mainline-extservices-releaseandroid13-mainline-conscrypt-releaseandroid13-mainline-cellbroadcast-releaseandroid13-mainline-art-releaseandroid13-mainline-adbd-releaseaml_tz4_332714010
Original change: https://googleplex-android-review.googlesource.com/c/device/google/gs-common/+/17935512 Change-Id: I007a15138c6544da71f64d27d5b4b48daf0f2c4c Ignore-AOSP-First: this is an automerge Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--powerstats/AocStateResidencyDataProvider.cpp98
-rw-r--r--powerstats/include/AocStateResidencyDataProvider.h7
2 files changed, 9 insertions, 96 deletions
diff --git a/powerstats/AocStateResidencyDataProvider.cpp b/powerstats/AocStateResidencyDataProvider.cpp
index 574a23d..c64496d 100644
--- a/powerstats/AocStateResidencyDataProvider.cpp
+++ b/powerstats/AocStateResidencyDataProvider.cpp
@@ -17,8 +17,6 @@
#include "AocStateResidencyDataProvider.h"
#include <android-base/logging.h>
-#include <chrono>
-#include <pthread.h>
namespace aidl {
namespace android {
@@ -26,23 +24,12 @@ namespace hardware {
namespace power {
namespace stats {
-struct async_data_t {
- pthread_cond_t *cond;
- pthread_mutex_t *lock;
- uint64_t timeoutMillis;
- std::unordered_map<std::string, std::vector<StateResidency>> *residencies;
- std::unordered_map<std::string,
- std::vector<std::unique_ptr<GenericStateResidencyDataProvider>>> *providers;
-};
-
AocStateResidencyDataProvider::AocStateResidencyDataProvider(std::vector<std::pair<std::string,
- std::string>> ids, std::vector<std::pair<std::string, std::string>> states,
- const uint64_t timeoutMillis) {
+ std::string>> ids, std::vector<std::pair<std::string, std::string>> states) {
// AoC stats are reported in ticks of 244.140625ns. The transform
// function converts ticks to milliseconds.
// 1000000 / 244.140625 = 4096.
static const uint64_t AOC_CLK = 4096;
- static const uint64_t TIMEOUT_MILLIS = 120;
std::function<uint64_t(uint64_t)> aocTickToMs = [](uint64_t a) { return a / AOC_CLK; };
GenericStateResidencyDataProvider::StateResidencyConfig config = {
.entryCountSupported = true,
@@ -67,17 +54,13 @@ AocStateResidencyDataProvider::AocStateResidencyDataProvider(std::vector<std::pa
mProviders[id.first].push_back(std::move(sdp));
}
}
- mStateCount = states.size();
- mTimeoutMillis = timeoutMillis == 0 ? TIMEOUT_MILLIS : timeoutMillis;
}
-void *getStateResidenciesAsync(void *arg) {
- struct timespec start, end;
- struct async_data_t *async = (struct async_data_t*)arg;
- uint64_t timeoutUs = async->timeoutMillis * 1000;
-
+bool AocStateResidencyDataProvider::getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
// States from the same power entity are merged.
- for (const auto &providerList : *async->providers) {
+ bool ret = true;
+ for (const auto &providerList : mProviders) {
int32_t stateId = 0;
std::string curEntity = providerList.first;
std::vector<StateResidency> stateResidencies;
@@ -85,18 +68,7 @@ void *getStateResidenciesAsync(void *arg) {
// Iterate over each provider in the providerList, appending each of the states
for (const auto &provider : providerList.second) {
std::unordered_map<std::string, std::vector<StateResidency>> residency;
-
- clock_gettime(CLOCK_REALTIME, &start);
- provider->getStateResidencies(&residency);
- clock_gettime(CLOCK_REALTIME, &end);
- uint64_t elapsedUs =
- ((end.tv_sec - start.tv_sec) * 1000000) + ((end.tv_nsec - start.tv_nsec) / 1000);
-
- if (elapsedUs >= timeoutUs) {
- LOG(WARNING) << "getStateResidencies latency for " << curEntity
- << " exceeds time allowed: " << elapsedUs << " us";
- return 0;
- }
+ ret &= provider->getStateResidencies(&residency);
// Each provider should only return data for curEntity but checking anyway
if (residency.find(curEntity) != residency.end()) {
@@ -112,64 +84,8 @@ void *getStateResidenciesAsync(void *arg) {
}
}
- async->residencies->emplace(curEntity, stateResidencies);
+ residencies->emplace(curEntity, stateResidencies);
}
-
- pthread_mutex_lock(async->lock);
- pthread_cond_signal(async->cond);
- pthread_mutex_unlock(async->lock);
-
- return 0;
-}
-
-bool AocStateResidencyDataProvider::getStateResidencies(
- std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
- bool ret = true;
- int condResult = 0;
- pthread_t tid;
- pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
- pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
- std::unordered_map<std::string, std::vector<StateResidency>> stateResidencies;
- struct timespec start, timeout;
- struct async_data_t async = {
- .cond = &cond,
- .lock = &lock,
- .timeoutMillis = mTimeoutMillis,
- .residencies = &stateResidencies,
- .providers = &mProviders
- };
-
- pthread_create(&tid, NULL, &getStateResidenciesAsync, (void*)&async);
-
- clock_gettime(CLOCK_REALTIME, &start);
-
- uint64_t expirationMillis = mTimeoutMillis * mStateCount;
- timeout.tv_sec = start.tv_sec + expirationMillis / 1000;
- uint64_t nsec = start.tv_nsec + (expirationMillis % 1000) * 1000000;
- if (nsec < 1000000000) {
- timeout.tv_nsec = nsec;
- } else {
- timeout.tv_sec += 1;
- timeout.tv_nsec = nsec - 1000000000;
- }
-
- pthread_mutex_lock(&lock);
- condResult = pthread_cond_timedwait(&cond, &lock, &timeout);
- pthread_mutex_unlock(&lock);
-
- if (condResult != 0) {
- if (condResult == ETIMEDOUT) {
- LOG(WARNING) << __func__ << " latency for AoC timeout: " << expirationMillis << " ms";
- } else {
- LOG(ERROR) << "Failed to wait for the condition variable: " << condResult;
- }
- ret = false;
- } else {
- for (const auto &residency : stateResidencies) {
- residencies->emplace(residency.first, residency.second);
- }
- }
-
return ret;
}
diff --git a/powerstats/include/AocStateResidencyDataProvider.h b/powerstats/include/AocStateResidencyDataProvider.h
index 150f335..5008912 100644
--- a/powerstats/include/AocStateResidencyDataProvider.h
+++ b/powerstats/include/AocStateResidencyDataProvider.h
@@ -27,8 +27,7 @@ namespace stats {
class AocStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
public:
AocStateResidencyDataProvider(std::vector<std::pair<std::string, std::string>> ids,
- std::vector<std::pair<std::string, std::string>> states,
- const uint64_t timeoutMillis);
+ std::vector<std::pair<std::string, std::string>> states);
~AocStateResidencyDataProvider() = default;
bool getStateResidencies(
std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
@@ -37,12 +36,10 @@ class AocStateResidencyDataProvider : public PowerStats::IStateResidencyDataProv
private:
std::unordered_map<std::string /* entity name */,
std::vector<std::unique_ptr<GenericStateResidencyDataProvider>> /* providers */> mProviders;
- int32_t mStateCount;
- uint64_t mTimeoutMillis;
};
} // namespace stats
} // namespace power
} // namespace hardware
} // namespace android
-} // namespace aidl
+} // namespace aidl \ No newline at end of file