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

Commit 948b9b07 authored by Jonathan Backer's avatar Jonathan Backer
Browse files

Fix kernel wakeup durations

Before this change, atom KERNEL_WAKEUP_REPORTED recorded the uptime from
kernel wake to first partial wakelock started.

With this change, atom KERNEL_WAKEUP_REPORTED records the complete uptime
associated with the kernel wake.

There is significant CPU scheduling delay on WearOS devices due to
CPU starvation (go/wear-metric-problem). This means that a thread hop
can take take a large amount of wall time.

As per b/309610775#comment9, the calls to aggreateWakeupReasonLocked by
noteWakeupReasonLocked and noteStartWakeLocked are racing and potential
scheduling delays can really skew the order.

Test: ./out/host/linux-x86/bin/statsd_testdrive -e 36

Bug: 309610775
Change-Id: I8ec939e00d1535da4bdcd3a1aa0e028424ef97e4
parent 0e75605d
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -4885,7 +4885,6 @@ public class BatteryStatsImpl extends BatteryStats {
        if (type == WAKE_TYPE_PARTIAL) {
            // Only care about partial wake locks, since full wake locks
            // will be canceled when the user puts the screen to sleep.
            aggregateLastWakeupUptimeLocked(elapsedRealtimeMs, uptimeMs);
            if (historyName == null) {
                historyName = name;
            }
@@ -5205,20 +5204,14 @@ public class BatteryStatsImpl extends BatteryStats {
    }
    @GuardedBy("this")
    void aggregateLastWakeupUptimeLocked(long elapsedRealtimeMs, long uptimeMs) {
    public void noteWakeupReasonLocked(String reason, long elapsedRealtimeMs, long uptimeMs) {
        if (mLastWakeupReason != null) {
            long deltaUptimeMs = uptimeMs - mLastWakeupUptimeMs;
            SamplingTimer timer = getWakeupReasonTimerLocked(mLastWakeupReason);
            timer.add(deltaUptimeMs * 1000, 1, elapsedRealtimeMs); // time in in microseconds
            mFrameworkStatsLogger.kernelWakeupReported(deltaUptimeMs * 1000, mLastWakeupReason,
                    mLastWakeupElapsedTimeMs);
            mLastWakeupReason = null;
        }
        }
    @GuardedBy("this")
    public void noteWakeupReasonLocked(String reason, long elapsedRealtimeMs, long uptimeMs) {
        aggregateLastWakeupUptimeLocked(elapsedRealtimeMs, uptimeMs);
        mHistory.recordWakeupEvent(elapsedRealtimeMs, uptimeMs, reason);
        mLastWakeupReason = reason;
        mLastWakeupUptimeMs = uptimeMs;