Skip to content

Commit

Permalink
power: ADPF: dump ADPF session info
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jimmyshiu authored and rayavanindra committed Jul 20, 2024
1 parent 2f953ae commit b3c905e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions power-libperfmgr/aidl/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ binder_status_t Power::dump(int fd, const char **, uint32_t) {
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";
}
Expand Down
7 changes: 7 additions & 0 deletions power-libperfmgr/aidl/PowerHintSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ int PowerHintSession::getUclampMin() {
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");
Expand Down
1 change: 1 addition & 0 deletions power-libperfmgr/aidl/PowerHintSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class PowerHintSession : public BnPowerHintSession {
bool isAppSession();
const std::vector<int> &getTidList() const;
int getUclampMin();
void dumpToStream(std::ostream &stream);

private:
class HintTimerHandler : public MessageHandler {
Expand Down
23 changes: 23 additions & 0 deletions power-libperfmgr/aidl/PowerSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "PowerSessionManager.h"

#include <android-base/file.h>
#include <log/log.h>
#include <perfmgr/HintManager.h>
#include <processgroup/processgroup.h>
Expand Down Expand Up @@ -201,6 +202,28 @@ void PowerSessionManager::handleMessage(const Message &) {
}
}

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!!");
Expand Down
2 changes: 1 addition & 1 deletion power-libperfmgr/aidl/PowerSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class PowerSessionManager : public MessageHandler {
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() {
Expand Down

0 comments on commit b3c905e

Please sign in to comment.