forked from donjohanliebert/hardware_xiaomi
adpf: clean up ADPF trace points
clean up ADPF trace points and use vendor.powerhal.adpf.uclamp.boost_cap instead of vendor.powerhal.adpf.uclamp.cap_ratio. Bug: 191551452 Test: build Change-Id: I457710b1bd9a7adbb55749d7bb915c736dde2751
This commit is contained in:
parent
63fca5e797
commit
d3bc3b8b6f
@ -49,7 +49,7 @@ constexpr char kPowerHalAdpfPidIClamp[] = "vendor.powerhal.adpf.pid.i_clamp";
|
||||
constexpr char kPowerHalAdpfPidD[] = "vendor.powerhal.adpf.pid.d";
|
||||
constexpr char kPowerHalAdpfPidInitialIntegral[] = "vendor.powerhal.adpf.pid.i_init";
|
||||
constexpr char kPowerHalAdpfUclampEnable[] = "vendor.powerhal.adpf.uclamp";
|
||||
constexpr char kPowerHalAdpfUclampCapRatio[] = "vendor.powerhal.adpf.uclamp.cap_ratio";
|
||||
constexpr char kPowerHalAdpfUclampBoostCap[] = "vendor.powerhal.adpf.uclamp.boost_cap";
|
||||
constexpr char kPowerHalAdpfUclampGranularity[] = "vendor.powerhal.adpf.uclamp.granularity";
|
||||
constexpr char kPowerHalAdpfStaleTimeFactor[] = "vendor.powerhal.adpf.stale_timeout_factor";
|
||||
constexpr char kPowerHalAdpfSamplingWindow[] = "vendor.powerhal.adpf.sampling_window";
|
||||
@ -79,31 +79,6 @@ static int sched_setattr(int pid, struct sched_attr *attr, unsigned int flags) {
|
||||
return syscall(__NR_sched_setattr, pid, attr, flags);
|
||||
}
|
||||
|
||||
static inline void TRACE_ADPF_PID(uintptr_t session_id, int32_t uid, int32_t tgid, uint64_t count,
|
||||
int64_t err, int64_t integral, int64_t previous, int64_t p,
|
||||
int64_t i, int64_t d, int32_t output) {
|
||||
if (ATRACE_ENABLED()) {
|
||||
const std::string idstr = StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR, tgid, uid,
|
||||
session_id & 0xffff);
|
||||
std::string sz = StringPrintf("%s-pid.count", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), count);
|
||||
sz = StringPrintf("%s-pid.err", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), err);
|
||||
sz = StringPrintf("%s-pid.accu", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), integral);
|
||||
sz = StringPrintf("%s-pid.prev", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), previous);
|
||||
sz = StringPrintf("%s-pid.pOut", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), p);
|
||||
sz = StringPrintf("%s-pid.iOut", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), i);
|
||||
sz = StringPrintf("%s-pid.dOut", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), d);
|
||||
sz = StringPrintf("%s-pid.output", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), output);
|
||||
}
|
||||
}
|
||||
|
||||
static inline int64_t ns_to_100us(int64_t ns) {
|
||||
return ns / 100000;
|
||||
}
|
||||
@ -131,7 +106,7 @@ static const int64_t sPidIClamp =
|
||||
kPowerHalAdpfPidIClamp, 512) /
|
||||
sPidI));
|
||||
static const int sUclampCap =
|
||||
static_cast<int>(getDoubleProperty(kPowerHalAdpfUclampCapRatio, 0.5) * 1024);
|
||||
::android::base::GetIntProperty<int>(kPowerHalAdpfUclampBoostCap, 512);
|
||||
static const uint32_t sUclampGranularity =
|
||||
::android::base::GetUintProperty<uint32_t>(kPowerHalAdpfUclampGranularity, 5);
|
||||
static const int64_t sStaleTimeFactor =
|
||||
@ -151,9 +126,9 @@ PowerHintSession::PowerHintSession(int32_t tgid, int32_t uid, const std::vector<
|
||||
|
||||
if (ATRACE_ENABLED()) {
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("%s-target", idstr.c_str());
|
||||
std::string sz = StringPrintf("adpf.%s-target", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), (int64_t)mDescriptor->duration.count());
|
||||
sz = StringPrintf("%s-active", idstr.c_str());
|
||||
sz = StringPrintf("adpf.%s-active", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), mDescriptor->is_active.load());
|
||||
}
|
||||
PowerSessionManager::getInstance()->addPowerSession(this);
|
||||
@ -165,11 +140,11 @@ PowerHintSession::~PowerHintSession() {
|
||||
ALOGV("PowerHintSession deleted: %s", mDescriptor->toString().c_str());
|
||||
if (ATRACE_ENABLED()) {
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("%s-target", idstr.c_str());
|
||||
std::string sz = StringPrintf("adpf.%s-target", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), 0);
|
||||
sz = StringPrintf("%s-actl_last", idstr.c_str());
|
||||
sz = StringPrintf("adpf.%s-actl_last", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), 0);
|
||||
sz = sz = StringPrintf("%s-active", idstr.c_str());
|
||||
sz = sz = StringPrintf("adpf.%s-active", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), 0);
|
||||
}
|
||||
delete mDescriptor;
|
||||
@ -192,9 +167,8 @@ int PowerHintSession::setUclamp(int32_t min, int32_t max) {
|
||||
max = std::max(0, max);
|
||||
max = std::max(min, max);
|
||||
if (ATRACE_ENABLED()) {
|
||||
std::string sz =
|
||||
StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-min", mDescriptor->tgid,
|
||||
mDescriptor->uid, reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("adpf.%s-min", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), min);
|
||||
}
|
||||
for (const auto tid : mDescriptor->threadIds) {
|
||||
@ -221,9 +195,8 @@ ndk::ScopedAStatus PowerHintSession::pause() {
|
||||
setUclamp(0, 1024);
|
||||
mDescriptor->is_active.store(false);
|
||||
if (ATRACE_ENABLED()) {
|
||||
std::string sz =
|
||||
StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-active", mDescriptor->tgid,
|
||||
mDescriptor->uid, reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("adpf.%s-active", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), mDescriptor->is_active.load());
|
||||
}
|
||||
updateUniveralBoostMode();
|
||||
@ -236,9 +209,8 @@ ndk::ScopedAStatus PowerHintSession::resume() {
|
||||
mDescriptor->is_active.store(true);
|
||||
mDescriptor->integral_error = std::max(sPidIInit, mDescriptor->integral_error);
|
||||
if (ATRACE_ENABLED()) {
|
||||
std::string sz =
|
||||
StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-active", mDescriptor->tgid,
|
||||
mDescriptor->uid, reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("adpf.%s-active", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), mDescriptor->is_active.load());
|
||||
}
|
||||
updateUniveralBoostMode();
|
||||
@ -267,9 +239,8 @@ ndk::ScopedAStatus PowerHintSession::updateTargetWorkDuration(int64_t targetDura
|
||||
|
||||
mDescriptor->duration = std::chrono::nanoseconds(targetDurationNanos);
|
||||
if (ATRACE_ENABLED()) {
|
||||
std::string sz =
|
||||
StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-target", mDescriptor->tgid,
|
||||
mDescriptor->uid, reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("adpf.%s-target", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), (int64_t)mDescriptor->duration.count());
|
||||
}
|
||||
|
||||
@ -292,9 +263,8 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
|
||||
}
|
||||
if (PowerHintMonitor::getInstance()->isRunning() && isStale()) {
|
||||
if (ATRACE_ENABLED()) {
|
||||
std::string sz = StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-stale",
|
||||
mDescriptor->tgid, mDescriptor->uid,
|
||||
reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("adpf.%s-stale", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), 0);
|
||||
}
|
||||
mDescriptor->integral_error = std::max(sPidIInit, mDescriptor->integral_error);
|
||||
@ -321,28 +291,30 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
|
||||
mDescriptor->integral_error = std::min(sPidIClamp, mDescriptor->integral_error);
|
||||
mDescriptor->integral_error = std::max(-sPidIClamp, mDescriptor->integral_error);
|
||||
}
|
||||
if (ATRACE_ENABLED()) {
|
||||
std::string sz = StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-actl_last",
|
||||
mDescriptor->tgid, mDescriptor->uid,
|
||||
reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
ATRACE_INT(sz.c_str(), actualDurations[length - 1].durationNanos);
|
||||
sz = StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-target", mDescriptor->tgid,
|
||||
mDescriptor->uid, reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
ATRACE_INT(sz.c_str(), (int64_t)mDescriptor->duration.count());
|
||||
sz = StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-sample_size",
|
||||
mDescriptor->tgid, mDescriptor->uid,
|
||||
reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
ATRACE_INT(sz.c_str(), length);
|
||||
}
|
||||
int64_t pOut = static_cast<int64_t>(sPidP * err_sum / (length - start));
|
||||
int64_t iOut = static_cast<int64_t>(sPidI * mDescriptor->integral_error);
|
||||
int64_t dOut = static_cast<int64_t>(sPidD * derivative_sum / dt / (length - start));
|
||||
|
||||
int64_t output = pOut + iOut + dOut;
|
||||
TRACE_ADPF_PID(reinterpret_cast<uintptr_t>(this) & 0xffff, mDescriptor->uid, mDescriptor->tgid,
|
||||
mDescriptor->update_count, err_sum / (length - start),
|
||||
mDescriptor->integral_error, derivative_sum / dt / (length - start), pOut, iOut,
|
||||
dOut, static_cast<int>(output));
|
||||
if (ATRACE_ENABLED()) {
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("adpf.%s-actl_last", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), actualDurations[length - 1].durationNanos);
|
||||
sz = StringPrintf("adpf.%s-target", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), (int64_t)mDescriptor->duration.count());
|
||||
sz = StringPrintf("adpf.%s-sample_size", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), length);
|
||||
sz = StringPrintf("adpf.%s-pid.count", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), mDescriptor->update_count);
|
||||
sz = StringPrintf("adpf.%s-pid.pOut", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), pOut);
|
||||
sz = StringPrintf("adpf.%s-pid.iOut", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), iOut);
|
||||
sz = StringPrintf("adpf.%s-pid.dOut", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), dOut);
|
||||
sz = StringPrintf("adpf.%s-pid.output", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), output);
|
||||
}
|
||||
mDescriptor->update_count++;
|
||||
|
||||
mStaleHandler->updateStaleTimer();
|
||||
@ -392,9 +364,8 @@ bool PowerHintSession::isStale() {
|
||||
|
||||
void PowerHintSession::setStale() {
|
||||
if (ATRACE_ENABLED()) {
|
||||
std::string sz =
|
||||
StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-stale", mDescriptor->tgid,
|
||||
mDescriptor->uid, reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||
const std::string idstr = getIdString();
|
||||
std::string sz = StringPrintf("adpf.%s-stale", idstr.c_str());
|
||||
ATRACE_INT(sz.c_str(), 1);
|
||||
}
|
||||
// Reset to default uclamp value.
|
||||
|
Loading…
Reference in New Issue
Block a user