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

Commit fde6958b authored by Misha Wagner's avatar Misha Wagner
Browse files

Change CpuTimePerThreadFreq to contain all frequencies in one atom

Test: make, flash, inspect pull-source output
Bug: 120016054
Change-Id: I56de3aec85d5f82339eb4eb876a1349d66698a63
parent 72c86100
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -3331,10 +3331,27 @@ message CpuTimePerThreadFreq {
    optional string process_name = 4;
    // Name of the thread taken from `/proc/$PID/task/$TID/comm`
    optional string thread_name = 5;
    // What frequency the CPU was running at, in KHz
    optional int32 frequency_khz = 6;
    // Time spent in frequency in milliseconds, since thread start.
    optional int32 time_millis = 7;

    // Report eight different frequencies, and how much time is spent in each frequency. Frequencies
    // are given in KHz, and time is given in milliseconds since the thread started. All eight
    // frequencies are given here as the alternative is sending eight separate atoms. This method
    // significantly reduces the amount of data created
    optional int32 frequency1_khz = 6;
    optional int32 time1_millis = 7;
    optional int32 frequency2_khz = 8;
    optional int32 time2_millis = 9;
    optional int32 frequency3_khz = 10;
    optional int32 time3_millis = 11;
    optional int32 frequency4_khz = 12;
    optional int32 time4_millis = 13;
    optional int32 frequency5_khz = 14;
    optional int32 time5_millis = 15;
    optional int32 frequency6_khz = 16;
    optional int32 time6_millis = 17;
    optional int32 frequency7_khz = 18;
    optional int32 time7_millis = 19;
    optional int32 frequency8_khz = 20;
    optional int32 time8_millis = 21;
}

/**
+1 −1
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
          5 * NS_PER_SEC /* min cool-down in seconds*/,
          new StatsCompanionServicePuller(android::util::PROCESS_CPU_TIME)}},
        {android::util::CPU_TIME_PER_THREAD_FREQ,
         {{7},
         {{7, 9, 11, 13, 15, 17, 19, 21},
          1 * NS_PER_SEC,
          new StatsCompanionServicePuller(android::util::CPU_TIME_PER_THREAD_FREQ)}},
        // DeviceCalculatedPowerUse.
+15 −9
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
            // "zygote64",
    };

    private static final int CPU_TIME_PER_THREAD_FREQ_NUM_FREQUENCIES = 8;

    static final class CompanionHandler extends Handler {
        CompanionHandler(Looper looper) {
@@ -1654,6 +1655,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
            return;
        }
        int[] cpuFrequencies = mKernelCpuThreadReader.getCpuFrequenciesKhz();
        if (cpuFrequencies.length != CPU_TIME_PER_THREAD_FREQ_NUM_FREQUENCIES) {
            Slog.w(TAG, "Expected " + CPU_TIME_PER_THREAD_FREQ_NUM_FREQUENCIES
                    + " frequencies, but got " + cpuFrequencies.length);
            return;
        }
        for (int i = 0; i < processCpuUsages.size(); i++) {
            KernelCpuThreadReader.ProcessCpuUsage processCpuUsage = processCpuUsages.get(i);
            ArrayList<KernelCpuThreadReader.ThreadCpuUsage> threadCpuUsages =
@@ -1667,7 +1673,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                    continue;
                }

                for (int k = 0; k < threadCpuUsage.usageTimesMillis.length; k++) {
                StatsLogEventWrapper e =
                        new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
                e.writeInt(processCpuUsage.uid);
@@ -1675,10 +1680,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                e.writeInt(threadCpuUsage.threadId);
                e.writeString(processCpuUsage.processName);
                e.writeString(threadCpuUsage.threadName);
                for (int k = 0; k < CPU_TIME_PER_THREAD_FREQ_NUM_FREQUENCIES; k++) {
                    e.writeInt(cpuFrequencies[k]);
                    e.writeInt(threadCpuUsage.usageTimesMillis[k]);
                    pulledData.add(e);
                }
                pulledData.add(e);
            }
        }
    }