power: ADPF: dump ADPF session info
Dump current ADPF profile and ADPF session list into bugreport.
Bug: 204444691
Test: adb root && adb shell dumpsys android.hardware.power.IPower/default
Test: gpaste/6469309887938560
Change-Id: I17c0d615051f5e51c2e1fe99d17c402f9a65679a
diff --git a/aidl/power-libperfmgr/Power.cpp b/aidl/power-libperfmgr/Power.cpp
index 70f313f..f1820aa 100644
--- a/aidl/power-libperfmgr/Power.cpp
+++ b/aidl/power-libperfmgr/Power.cpp
@@ -202,6 +202,7 @@
boolToString(mSustainedPerfModeOn)));
// Dump nodes through libperfmgr
HintManager::GetInstance()->DumpToFd(fd);
+ PowerSessionManager::getInstance()->dumpToFd(fd);
if (!::android::base::WriteStringToFd(buf, fd)) {
PLOG(ERROR) << "Failed to dump state to fd";
}
diff --git a/aidl/power-libperfmgr/PowerHintSession.cpp b/aidl/power-libperfmgr/PowerHintSession.cpp
index 32de767..0507096 100644
--- a/aidl/power-libperfmgr/PowerHintSession.cpp
+++ b/aidl/power-libperfmgr/PowerHintSession.cpp
@@ -200,6 +200,13 @@
return mDescriptor->current_min;
}
+void PowerHintSession::dumpToStream(std::ostream &stream) {
+ stream << "ID.Min.Act.Stale(" << getIdString();
+ stream << ", " << mDescriptor->current_min;
+ stream << ", " << mDescriptor->is_active;
+ stream << ", " << isStale() << ")";
+}
+
ndk::ScopedAStatus PowerHintSession::pause() {
if (mSessionClosed) {
ALOGE("Error: session is dead");
diff --git a/aidl/power-libperfmgr/PowerHintSession.h b/aidl/power-libperfmgr/PowerHintSession.h
index bf4280f..203cfbb 100644
--- a/aidl/power-libperfmgr/PowerHintSession.h
+++ b/aidl/power-libperfmgr/PowerHintSession.h
@@ -90,6 +90,7 @@
bool isAppSession();
const std::vector<int> &getTidList() const;
int getUclampMin();
+ void dumpToStream(std::ostream &stream);
private:
class HintTimerHandler : public MessageHandler {
diff --git a/aidl/power-libperfmgr/PowerSessionManager.cpp b/aidl/power-libperfmgr/PowerSessionManager.cpp
index 284bd7a..984b0d0 100644
--- a/aidl/power-libperfmgr/PowerSessionManager.cpp
+++ b/aidl/power-libperfmgr/PowerSessionManager.cpp
@@ -19,6 +19,7 @@
#include "PowerSessionManager.h"
+#include <android-base/file.h>
#include <log/log.h>
#include <perfmgr/HintManager.h>
#include <processgroup/processgroup.h>
@@ -201,6 +202,28 @@
}
}
+void PowerSessionManager::dumpToFd(int fd) {
+ std::ostringstream dump_buf;
+ std::lock_guard<std::mutex> guard(mLock);
+ dump_buf << "========== Begin PowerSessionManager ADPF list ==========\n";
+ for (PowerHintSession *s : mSessions) {
+ s->dumpToStream(dump_buf);
+ dump_buf << " Tid:Ref[";
+ for (size_t i = 0, len = s->getTidList().size(); i < len; i++) {
+ int t = s->getTidList()[i];
+ dump_buf << t << ":" << mTidSessionListMap[t].size();
+ if (i < len - 1) {
+ dump_buf << ", ";
+ }
+ }
+ dump_buf << "]\n";
+ }
+ dump_buf << "========== End PowerSessionManager ADPF list ==========\n";
+ if (!::android::base::WriteStringToFd(dump_buf.str(), fd)) {
+ ALOGE("Failed to dump one of session list to fd:%d", fd);
+ }
+}
+
void PowerSessionManager::enableSystemTopAppBoost() {
if (HintManager::GetInstance()->IsHintSupported(kDisableBoostHintName)) {
ALOGV("PowerSessionManager::enableSystemTopAppBoost!!");
diff --git a/aidl/power-libperfmgr/PowerSessionManager.h b/aidl/power-libperfmgr/PowerSessionManager.h
index 0c97a2d..5cf14c2 100644
--- a/aidl/power-libperfmgr/PowerSessionManager.h
+++ b/aidl/power-libperfmgr/PowerSessionManager.h
@@ -52,8 +52,8 @@
void removePowerSession(PowerHintSession *session);
void setUclampMin(PowerHintSession *session, int min);
void setUclampMinLocked(PowerHintSession *session, int min);
-
void handleMessage(const Message &message) override;
+ void dumpToFd(int fd);
// Singleton
static sp<PowerSessionManager> getInstance() {