sm6375-common: power-libperfmgr: ADPF: refine StaleTimeHandler
Bug: 256515601 Test: build Change-Id: Ia7f80c838961b837733c457b189f16c6433cf3c3
This commit is contained in:
parent
745fd98bfd
commit
acaad7596c
2 changed files with 16 additions and 28 deletions
|
@ -352,7 +352,6 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
|
||||||
mDescriptor->current_min + static_cast<int>(output));
|
mDescriptor->current_min + static_cast<int>(output));
|
||||||
next_min = std::max(static_cast<int>(adpfConfig->mUclampMinLow), next_min);
|
next_min = std::max(static_cast<int>(adpfConfig->mUclampMinLow), next_min);
|
||||||
setSessionUclampMin(next_min);
|
setSessionUclampMin(next_min);
|
||||||
mStaleTimerHandler->updateTimer(getStaleTime());
|
|
||||||
|
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
@ -384,7 +383,12 @@ bool PowerHintSession::isActive() {
|
||||||
|
|
||||||
bool PowerHintSession::isTimeout() {
|
bool PowerHintSession::isTimeout() {
|
||||||
auto now = std::chrono::steady_clock::now();
|
auto now = std::chrono::steady_clock::now();
|
||||||
return now >= getStaleTime();
|
time_point<steady_clock> staleTime =
|
||||||
|
mLastUpdatedTime.load() +
|
||||||
|
nanoseconds(static_cast<int64_t>(
|
||||||
|
mDescriptor->duration.count() *
|
||||||
|
HintManager::GetInstance()->GetAdpfProfile()->mStaleTimeFactor));
|
||||||
|
return now >= staleTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<int> &PowerHintSession::getTidList() const {
|
const std::vector<int> &PowerHintSession::getTidList() const {
|
||||||
|
@ -432,31 +436,19 @@ void PowerHintSession::wakeup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
time_point<steady_clock> PowerHintSession::getStaleTime() {
|
|
||||||
return mLastUpdatedTime.load() +
|
|
||||||
nanoseconds(static_cast<int64_t>(
|
|
||||||
mDescriptor->duration.count() *
|
|
||||||
HintManager::GetInstance()->GetAdpfProfile()->mStaleTimeFactor));
|
|
||||||
}
|
|
||||||
|
|
||||||
void PowerHintSession::StaleTimerHandler::updateTimer() {
|
void PowerHintSession::StaleTimerHandler::updateTimer() {
|
||||||
time_point<steady_clock> staleTime =
|
auto now = std::chrono::steady_clock::now();
|
||||||
std::chrono::steady_clock::now() +
|
nanoseconds staleDuration = std::chrono::nanoseconds(
|
||||||
nanoseconds(static_cast<int64_t>(
|
static_cast<int64_t>(mSession->mDescriptor->duration.count() *
|
||||||
mSession->mDescriptor->duration.count() *
|
HintManager::GetInstance()->GetAdpfProfile()->mStaleTimeFactor));
|
||||||
HintManager::GetInstance()->GetAdpfProfile()->mStaleTimeFactor));
|
mStaleTime.store(now + staleDuration);
|
||||||
updateTimer(staleTime);
|
int64_t next = static_cast<int64_t>(staleDuration.count());
|
||||||
}
|
|
||||||
|
|
||||||
void PowerHintSession::StaleTimerHandler::updateTimer(time_point<steady_clock> staleTime) {
|
|
||||||
mStaleTime.store(staleTime);
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(mMessageLock);
|
std::lock_guard<std::mutex> guard(mMessageLock);
|
||||||
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mStaleTimerHandler);
|
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mStaleTimerHandler);
|
||||||
PowerHintMonitor::getInstance()->getLooper()->sendMessage(mSession->mStaleTimerHandler,
|
PowerHintMonitor::getInstance()->getLooper()->sendMessageDelayed(
|
||||||
NULL);
|
next, mSession->mStaleTimerHandler, NULL);
|
||||||
}
|
}
|
||||||
mIsMonitoring.store(true);
|
|
||||||
if (ATRACE_ENABLED()) {
|
if (ATRACE_ENABLED()) {
|
||||||
const std::string idstr = mSession->getIdString();
|
const std::string idstr = mSession->getIdString();
|
||||||
std::string sz = StringPrintf("adpf.%s-timer.stale", idstr.c_str());
|
std::string sz = StringPrintf("adpf.%s-timer.stale", idstr.c_str());
|
||||||
|
@ -480,12 +472,11 @@ void PowerHintSession::StaleTimerHandler::handleMessage(const Message &) {
|
||||||
next, mSession->mStaleTimerHandler, NULL);
|
next, mSession->mStaleTimerHandler, NULL);
|
||||||
} else {
|
} else {
|
||||||
mSession->setStale();
|
mSession->setStale();
|
||||||
mIsMonitoring.store(false);
|
|
||||||
}
|
}
|
||||||
if (ATRACE_ENABLED()) {
|
if (ATRACE_ENABLED()) {
|
||||||
const std::string idstr = mSession->getIdString();
|
const std::string idstr = mSession->getIdString();
|
||||||
std::string sz = StringPrintf("adpf.%s-timer.stale", idstr.c_str());
|
std::string sz = StringPrintf("adpf.%s-timer.stale", idstr.c_str());
|
||||||
ATRACE_INT(sz.c_str(), mIsMonitoring ? 0 : 1);
|
ATRACE_INT(sz.c_str(), next > 0 ? 0 : 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,10 +92,8 @@ class PowerHintSession : public BnPowerHintSession {
|
||||||
private:
|
private:
|
||||||
class StaleTimerHandler : public MessageHandler {
|
class StaleTimerHandler : public MessageHandler {
|
||||||
public:
|
public:
|
||||||
StaleTimerHandler(PowerHintSession *session)
|
StaleTimerHandler(PowerHintSession *session) : mSession(session), mIsSessionDead(false) {}
|
||||||
: mSession(session), mIsMonitoring(false), mIsSessionDead(false) {}
|
|
||||||
void updateTimer();
|
void updateTimer();
|
||||||
void updateTimer(time_point<steady_clock> staleTime);
|
|
||||||
void handleMessage(const Message &message) override;
|
void handleMessage(const Message &message) override;
|
||||||
void setSessionDead();
|
void setSessionDead();
|
||||||
|
|
||||||
|
@ -104,7 +102,6 @@ class PowerHintSession : public BnPowerHintSession {
|
||||||
std::mutex mClosedLock;
|
std::mutex mClosedLock;
|
||||||
std::mutex mMessageLock;
|
std::mutex mMessageLock;
|
||||||
std::atomic<time_point<steady_clock>> mStaleTime;
|
std::atomic<time_point<steady_clock>> mStaleTime;
|
||||||
std::atomic<bool> mIsMonitoring;
|
|
||||||
bool mIsSessionDead;
|
bool mIsSessionDead;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue