sm6375-common: power-libperfmgr: improve adpf logic

Cache active state and reduce log spam
Add value tracing into libperfmgr
Use adaptive stale timeout based on rate limit

Bug: 191331719
Bug: 191296994
Bug: 177493042
Test: boot
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I1c1484c9277209bf68bd287ceae83e2b37684c62
This commit is contained in:
Wei Wang 2024-07-18 20:16:00 +05:30 committed by Anand S
commit e5e88cf477
No known key found for this signature in database
GPG key ID: 3B2983FA448B3D61
6 changed files with 84 additions and 73 deletions

View file

@ -55,7 +55,8 @@ Power::Power(std::shared_ptr<HintManager> hm)
: mHintManager(hm),
mInteractionHandler(nullptr),
mSustainedPerfModeOn(false),
mAdpfRate(::android::base::GetIntProperty(kPowerHalAdpfRateProp, kPowerHalAdpfRateDefault)) {
mAdpfRateNs(
::android::base::GetIntProperty(kPowerHalAdpfRateProp, kPowerHalAdpfRateDefault)) {
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
mInteractionHandler->Init();
@ -81,7 +82,7 @@ Power::Power(std::shared_ptr<HintManager> hm)
}
// Now start to take powerhint
LOG(INFO) << "PowerHAL ready to take hints, Adpf update rate: " << mAdpfRate;
LOG(INFO) << "PowerHAL ready to take hints, Adpf update rate: " << mAdpfRateNs;
}
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
@ -200,7 +201,6 @@ binder_status_t Power::dump(int fd, const char **, uint32_t) {
if (!::android::base::WriteStringToFd(buf, fd)) {
PLOG(ERROR) << "Failed to dump state to fd";
}
// TODO(jimmyshiu@): dump weak_ptr of PowerHintSession
fsync(fd);
return STATUS_OK;
}
@ -209,7 +209,7 @@ ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid,
const std::vector<int32_t> &threadIds,
int64_t durationNanos,
std::shared_ptr<IPowerHintSession> *_aidl_return) {
if (mAdpfRate == -1) {
if (mAdpfRateNs <= 0) {
*_aidl_return = nullptr;
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
@ -218,15 +218,15 @@ ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid,
*_aidl_return = nullptr;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
std::shared_ptr<IPowerHintSession> session =
ndk::SharedRefBase::make<PowerHintSession>(tgid, uid, threadIds, durationNanos);
std::shared_ptr<IPowerHintSession> session = ndk::SharedRefBase::make<PowerHintSession>(
tgid, uid, threadIds, durationNanos, nanoseconds(mAdpfRateNs));
*_aidl_return = session;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t *outNanoseconds) {
*outNanoseconds = mAdpfRate;
if (mAdpfRate == -1) {
*outNanoseconds = mAdpfRateNs;
if (mAdpfRateNs <= 0) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}