sm6375-common: power-libperfmgr: ADPF: Fix updateHintBoost blocks the binder thread
post the task into a looper thread. Bug: 232992641 Test: Manually playing UIBench -> Transitions -> ActivityTransition Change-Id: Ibd241834f904b4c87a51363e766e110d2818d496
This commit is contained in:
parent
620a6da869
commit
fbcc05b19b
6 changed files with 43 additions and 16 deletions
|
@ -77,7 +77,10 @@ Power::Power()
|
|||
|
||||
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
||||
LOG(DEBUG) << "Power setMode: " << toString(type) << " to: " << enabled;
|
||||
if (HintManager::GetInstance()->GetAdpfProfile() &&
|
||||
HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
|
||||
PowerSessionManager::getInstance()->updateHintMode(toString(type), enabled);
|
||||
}
|
||||
switch (type) {
|
||||
#ifdef TAP_TO_WAKE_NODE
|
||||
case Mode::DOUBLE_TAP_TO_WAKE:
|
||||
|
@ -137,7 +140,10 @@ ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
|
|||
|
||||
ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
||||
LOG(DEBUG) << "Power setBoost: " << toString(type) << " duration: " << durationMs;
|
||||
if (HintManager::GetInstance()->GetAdpfProfile() &&
|
||||
HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
|
||||
PowerSessionManager::getInstance()->updateHintBoost(toString(type), durationMs);
|
||||
}
|
||||
switch (type) {
|
||||
case Boost::INTERACTION:
|
||||
if (mSustainedPerfModeOn) {
|
||||
|
|
|
@ -47,7 +47,10 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
|||
} else {
|
||||
HintManager::GetInstance()->EndHint(mode);
|
||||
}
|
||||
if (HintManager::GetInstance()->GetAdpfProfile() &&
|
||||
HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
|
||||
PowerSessionManager::getInstance()->updateHintMode(mode, enabled);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
@ -61,7 +64,10 @@ ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aid
|
|||
|
||||
ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t durationMs) {
|
||||
LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
|
||||
if (HintManager::GetInstance()->GetAdpfProfile() &&
|
||||
HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
|
||||
PowerSessionManager::getInstance()->updateHintBoost(boost, durationMs);
|
||||
}
|
||||
|
||||
if (durationMs > 0) {
|
||||
HintManager::GetInstance()->DoHint(boost, std::chrono::milliseconds(durationMs));
|
||||
|
|
|
@ -145,7 +145,7 @@ PowerHintSession::PowerHintSession(int32_t tgid, int32_t uid, const std::vector<
|
|||
}
|
||||
PowerSessionManager::getInstance()->addPowerSession(this);
|
||||
// init boost
|
||||
wakeup();
|
||||
setSessionUclampMin(HintManager::GetInstance()->GetAdpfProfile()->mUclampMinInit);
|
||||
ALOGV("PowerHintSession created: %s", mDescriptor->toString().c_str());
|
||||
}
|
||||
|
||||
|
@ -161,10 +161,6 @@ PowerHintSession::~PowerHintSession() {
|
|||
sz = sz = StringPrintf("adpf.%s-active", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), 0);
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mSessionLock);
|
||||
mSessionClosed.store(true);
|
||||
}
|
||||
delete mDescriptor;
|
||||
}
|
||||
|
||||
|
@ -265,11 +261,16 @@ ndk::ScopedAStatus PowerHintSession::close() {
|
|||
if (!mSessionClosed.compare_exchange_strong(sessionClosedExpectedToBe, true)) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
|
||||
}
|
||||
// Remove the session from PowerSessionManager first to avoid racing.
|
||||
PowerSessionManager::getInstance()->removePowerSession(this);
|
||||
setSessionUclampMin(0);
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mSessionLock);
|
||||
mSessionClosed.store(true);
|
||||
}
|
||||
mDescriptor->is_active.store(false);
|
||||
mEarlyBoostHandler->setSessionDead();
|
||||
mStaleTimerHandler->setSessionDead();
|
||||
setSessionUclampMin(0);
|
||||
PowerSessionManager::getInstance()->removePowerSession(this);
|
||||
updateUniveralBoostMode();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
@ -439,8 +440,7 @@ void PowerHintSession::updateWorkPeriod(const std::vector<WorkDuration> &actualD
|
|||
}
|
||||
const WorkDuration ¤t = actualDurations.back();
|
||||
int64_t curr_start = current.timeStampNanos - current.durationNanos;
|
||||
int64_t period = mDescriptor->duration.count();
|
||||
period = curr_start - mLastStartedTimeNs;
|
||||
int64_t period = curr_start - mLastStartedTimeNs;
|
||||
if (period > 0 && period < mDescriptor->duration.count() * 2) {
|
||||
// Accounting workload period with moving average for the last 10 workload.
|
||||
mWorkPeriodNs = 0.9 * mWorkPeriodNs + 0.1 * period;
|
||||
|
|
|
@ -112,7 +112,8 @@ class PowerHintSession : public BnPowerHintSession {
|
|||
|
||||
class EarlyBoostHandler : public MessageHandler {
|
||||
public:
|
||||
EarlyBoostHandler(PowerHintSession *session) : mSession(session) {}
|
||||
EarlyBoostHandler(PowerHintSession *session)
|
||||
: mSession(session), mIsMonitoring(false), mIsSessionDead(false) {}
|
||||
void updateTimer(time_point<steady_clock> boostTime);
|
||||
void handleMessage(const Message &message) override;
|
||||
void setSessionDead();
|
||||
|
|
|
@ -97,7 +97,7 @@ void PowerSessionManager::updateHintBoost(const std::string &boost, int32_t dura
|
|||
ALOGV("PowerSessionManager::updateHintBoost: boost: %s, durationMs: %d", boost.c_str(),
|
||||
durationMs);
|
||||
if (boost.compare("DISPLAY_UPDATE_IMMINENT") == 0) {
|
||||
wakeSessions();
|
||||
PowerHintMonitor::getInstance()->getLooper()->sendMessage(mWakeupHandler, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,10 @@ void PowerSessionManager::handleMessage(const Message &) {
|
|||
}
|
||||
}
|
||||
|
||||
void PowerSessionManager::WakeupHandler::handleMessage(const Message &) {
|
||||
PowerSessionManager::getInstance()->wakeSessions();
|
||||
}
|
||||
|
||||
void PowerSessionManager::dumpToFd(int fd) {
|
||||
std::ostringstream dump_buf;
|
||||
std::lock_guard<std::mutex> guard(mLock);
|
||||
|
|
|
@ -61,6 +61,13 @@ class PowerSessionManager : public MessageHandler {
|
|||
return instance;
|
||||
}
|
||||
|
||||
private:
|
||||
class WakeupHandler : public MessageHandler {
|
||||
public:
|
||||
WakeupHandler() {}
|
||||
void handleMessage(const Message &message) override;
|
||||
};
|
||||
|
||||
private:
|
||||
void wakeSessions();
|
||||
std::optional<bool> isAnyAppSessionActive();
|
||||
|
@ -71,6 +78,7 @@ class PowerSessionManager : public MessageHandler {
|
|||
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
|
||||
std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
|
||||
std::unordered_map<int, std::unordered_set<PowerHintSession *>> mTidSessionListMap;
|
||||
sp<WakeupHandler> mWakeupHandler;
|
||||
bool mActive; // protected by mLock
|
||||
/**
|
||||
* mLock to pretect the above data objects opertions.
|
||||
|
@ -82,7 +90,9 @@ class PowerSessionManager : public MessageHandler {
|
|||
: kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost,
|
||||
"ADPF_DISABLE_TA_BOOST")),
|
||||
mActive(false),
|
||||
mDisplayRefreshRate(60) {}
|
||||
mDisplayRefreshRate(60) {
|
||||
mWakeupHandler = sp<WakeupHandler>(new WakeupHandler());
|
||||
}
|
||||
PowerSessionManager(PowerSessionManager const &) = delete;
|
||||
void operator=(PowerSessionManager const &) = delete;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue