Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14b93353 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "consolidate subsystem sleep state atoms"

parents e9b8e09f c8b7f227
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ statsd_common_src := \
    src/config/ConfigManager.cpp \
    src/external/StatsPuller.cpp \
    src/external/StatsCompanionServicePuller.cpp \
    src/external/ResourcePowerManagerPuller.cpp \
    src/external/SubsystemSleepStatePuller.cpp \
    src/external/CpuTimePerUidPuller.cpp \
    src/external/CpuTimePerUidFreqPuller.cpp \
    src/external/StatsPullerManagerImpl.cpp \
+13 −37
Original line number Diff line number Diff line
@@ -94,9 +94,8 @@ message Atom {
        MobileBytesTransfer mobile_bytes_transfer = 10002;
        MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 10003;
        KernelWakelock kernel_wakelock = 10004;
        PlatformSleepState platform_sleep_state = 10005;
        SleepStateVoter sleep_state_voter = 10006;
        SubsystemSleepState subsystem_sleep_state = 10007;
        SubsystemSleepState subsystem_sleep_state = 10005;
        // 10006 and 10007 are free to use.
        CpuTimePerFreq cpu_time_per_freq = 10008;
        CpuTimePerUid cpu_time_per_uid = 10009;
        CpuTimePerUidFreq cpu_time_per_uid_freq = 10010;
@@ -1027,44 +1026,21 @@ message KernelWakelock {
}

/**
 * Pulls PowerStatePlatformSleepState.
 *
 * Definition here:
 *   hardware/interfaces/power/1.0/types.hal
 */
message PlatformSleepState {
    optional string name = 1;
    optional uint64 residency_in_msec_since_boot = 2;
    optional uint64 total_transitions = 3;
    optional bool supported_only_in_suspend = 4;
}

/**
 * Pulls PowerStateVoter.
 *
 * Definition here:
 * Pulls low power state information. This includes platform and subsystem sleep state information,
 * PowerStatePlatformSleepState, PowerStateVoter or PowerStateSubsystemSleepState as defined in
 *   hardware/interfaces/power/1.0/types.hal
 */
message SleepStateVoter {
    optional string platform_sleep_state_name = 1;
    optional string voter_name = 2;
    optional uint64 total_time_in_msec_voted_for_since_boot = 3;
    optional uint64 total_number_of_times_voted_since_boot = 4;
}

/**
 * Pulls PowerStateSubsystemSleepState.
 *
 * Definition here:
 *   hardware/interfaces/power/1.1/types.hal
 */
message SubsystemSleepState {
    optional string subsystem_name = 1;
    optional string subsystem_sleep_state_name = 2;
    optional uint64 residency_in_msec_since_boot = 3;
    optional uint64 total_transitions = 4;
    optional uint64 last_entry_timestamp_ms = 5;
    optional bool supported_only_in_suspend = 6;
    // Name should be in the format of XXX.YYY where XXX is subsystem name,
    // YYY is corresponding voter name.
    // If there are no voters, the format should just be XXX (with no dot).
    // XXX and YYY should not contain a "." in it.
    optional string name = 1;
    // The number of times it entered, or voted for entering the sleep state
    optional uint64 count = 2;
    // The length of time spent in, or spent voting for, the sleep state
    optional uint64 timeMs = 3;
}

/**
+2 −6
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#include <climits>
#include "CpuTimePerUidFreqPuller.h"
#include "CpuTimePerUidPuller.h"
#include "ResourcePowerManagerPuller.h"
#include "SubsystemSleepStatePuller.h"
#include "StatsCompanionServicePuller.h"
#include "StatsPullerManagerImpl.h"
#include "StatsService.h"
@@ -58,13 +58,9 @@ StatsPullerManagerImpl::StatsPullerManagerImpl()
    mPullers.insert({android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG,
                     make_shared<StatsCompanionServicePuller>(
                             android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG)});
    mPullers.insert({android::util::PLATFORM_SLEEP_STATE,
                     make_shared<ResourcePowerManagerPuller>(android::util::PLATFORM_SLEEP_STATE)});
    mPullers.insert({android::util::SLEEP_STATE_VOTER,
                     make_shared<ResourcePowerManagerPuller>(android::util::SLEEP_STATE_VOTER)});
    mPullers.insert(
            {android::util::SUBSYSTEM_SLEEP_STATE,
             make_shared<ResourcePowerManagerPuller>(android::util::SUBSYSTEM_SLEEP_STATE)});
             make_shared<SubsystemSleepStatePuller>()});
    mPullers.insert({android::util::CPU_TIME_PER_FREQ, make_shared<StatsCompanionServicePuller>(android::util::CPU_TIME_PER_FREQ)});
    mPullers.insert({android::util::CPU_TIME_PER_UID, make_shared<CpuTimePerUidPuller>()});
    mPullers.insert({android::util::CPU_TIME_PER_UID_FREQ, make_shared<CpuTimePerUidFreqPuller>()});
+12 −22
Original line number Diff line number Diff line
@@ -30,10 +30,10 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "external/ResourcePowerManagerPuller.h"
#include "external/SubsystemSleepStatePuller.h"
#include "external/StatsPuller.h"

#include "ResourcePowerManagerPuller.h"
#include "SubsystemSleepStatePuller.h"
#include "logd/LogEvent.h"
#include "statslog.h"

@@ -73,10 +73,10 @@ bool getPowerHal() {
    return gPowerHalV1_0 != nullptr;
}

ResourcePowerManagerPuller::ResourcePowerManagerPuller(int tagId) : StatsPuller(tagId) {
SubsystemSleepStatePuller::SubsystemSleepStatePuller() : StatsPuller(android::util::SUBSYSTEM_SLEEP_STATE) {
}

bool ResourcePowerManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* data) {
bool SubsystemSleepStatePuller::PullInternal(vector<shared_ptr<LogEvent>>* data) {
    std::lock_guard<std::mutex> lock(gPowerHalMutex);

    if (!getPowerHal()) {
@@ -89,8 +89,6 @@ bool ResourcePowerManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* data
    data->clear();

    Return<void> ret;
    if (mTagId == android::util::PLATFORM_SLEEP_STATE ||
        mTagId == android::util::SLEEP_STATE_VOTER) {
        ret = gPowerHalV1_0->getPlatformLowPowerStats(
                [&data, timestamp](hidl_vec<PowerStatePlatformSleepState> states, Status status) {
                    if (status != Status::SUCCESS) return;
@@ -98,12 +96,11 @@ bool ResourcePowerManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* data
                    for (size_t i = 0; i < states.size(); i++) {
                        const PowerStatePlatformSleepState& state = states[i];

                        auto statePtr = make_shared<LogEvent>(android::util::PLATFORM_SLEEP_STATE,
                        auto statePtr = make_shared<LogEvent>(android::util::SUBSYSTEM_SLEEP_STATE,
                                                              timestamp);
                        statePtr->write(state.name);
                        statePtr->write(state.residencyInMsecSinceBoot);
                        statePtr->write(state.totalTransitions);
                        statePtr->write(state.supportedOnlyInSuspend);
                        statePtr->write(state.residencyInMsecSinceBoot);
                        statePtr->init();
                        data->push_back(statePtr);
                        VLOG("powerstate: %s, %lld, %lld, %d", state.name.c_str(),
@@ -111,12 +108,11 @@ bool ResourcePowerManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* data
                             (long long)state.totalTransitions,
                             state.supportedOnlyInSuspend ? 1 : 0);
                        for (auto voter : state.voters) {
                            auto voterPtr = make_shared<LogEvent>(android::util::SLEEP_STATE_VOTER,
                            auto voterPtr = make_shared<LogEvent>(android::util::SUBSYSTEM_SLEEP_STATE,
                                                                  timestamp);
                            voterPtr->write(state.name);
                            voterPtr->write(voter.name);
                            voterPtr->write(voter.totalTimeInMsecVotedForSinceBoot);
                            voterPtr->write((std::string)state.name + "." + (std::string)voter.name);
                            voterPtr->write(voter.totalNumberOfTimesVotedSinceBoot);
                            voterPtr->write(voter.totalTimeInMsecVotedForSinceBoot);
                            voterPtr->init();
                            data->push_back(voterPtr);
                            VLOG("powerstatevoter: %s, %s, %lld, %lld", state.name.c_str(),
@@ -131,9 +127,7 @@ bool ResourcePowerManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* data
            gPowerHalV1_0 = nullptr;
            return false;
        }
    }

    if (mTagId == android::util::SUBSYSTEM_SLEEP_STATE) {
        // Trying to cast to IPower 1.1, this will succeed only for devices supporting 1.1
        sp<android::hardware::power::V1_1::IPower> gPowerHal_1_1 =
                android::hardware::power::V1_1::IPower::castFrom(gPowerHalV1_0);
@@ -150,12 +144,9 @@ bool ResourcePowerManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* data
                                            subsystem.states[j];
                                    auto subsystemStatePtr = make_shared<LogEvent>(
                                        android::util::SUBSYSTEM_SLEEP_STATE, timestamp);
                                    subsystemStatePtr->write(subsystem.name);
                                    subsystemStatePtr->write(state.name);
                                    subsystemStatePtr->write(state.residencyInMsecSinceBoot);
                                    subsystemStatePtr->write((std::string)subsystem.name + "." + (std::string)state.name);
                                    subsystemStatePtr->write(state.totalTransitions);
                                    subsystemStatePtr->write(state.lastEntryTimestampMs);
                                    subsystemStatePtr->write(state.supportedOnlyInSuspend);
                                    subsystemStatePtr->write(state.residencyInMsecSinceBoot);
                                    subsystemStatePtr->init();
                                    data->push_back(subsystemStatePtr);
                                    VLOG("subsystemstate: %s, %s, %lld, %lld, %lld",
@@ -168,7 +159,6 @@ bool ResourcePowerManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* data
                        }
                    });
        }
    }
    return true;
}

+2 −2
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@ namespace statsd {
/**
 * Reads hal for sleep states
 */
class ResourcePowerManagerPuller : public StatsPuller {
class SubsystemSleepStatePuller : public StatsPuller {
public:
    ResourcePowerManagerPuller(int tagId);
    SubsystemSleepStatePuller();
    bool PullInternal(vector<std::shared_ptr<LogEvent>>* data) override;
};

Loading