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

Commit 06d9729b authored by Glenn Kasten's avatar Glenn Kasten Committed by Android Git Automerger
Browse files

am c059bd42: Skip bad kHz values, and display them accurately

* commit 'c059bd42':
  Skip bad kHz values, and display them accurately
parents d361f189 c059bd42
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -508,7 +508,7 @@ bool FastMixer::threadLoop()
                // get the absolute value of CPU clock frequency in kHz
                int cpuNum = sched_getcpu();
                uint32_t kHz = tcu.getCpukHz(cpuNum);
                kHz = (kHz & ~0xF) | (cpuNum & 0xF);
                kHz = (kHz << 4) | (cpuNum & 0xF);
                // save values in FIFO queues for dumpsys
                // these stores #1, #2, #3 are not atomic with respect to each other,
                // or with respect to store #4 below
@@ -624,12 +624,15 @@ void FastMixerDumpState::dump(int fd)
        uint32_t sampleLoadNs = mLoadNs[i];
        uint32_t sampleCpukHz = mCpukHz[i];
        loadNs.sample(sampleLoadNs);
        kHz.sample(sampleCpukHz & ~0xF);
        // skip bad kHz samples
        if ((sampleCpukHz & ~0xF) != 0) {
            kHz.sample(sampleCpukHz >> 4);
            if (sampleCpukHz == previousCpukHz) {
            double megacycles = (double) sampleLoadNs * (double) sampleCpukHz * 1e-12;
                double megacycles = (double) sampleLoadNs * (double) (sampleCpukHz >> 4) * 1e-12;
                double adjMHz = megacycles / mixPeriodSec;  // _not_ wallNs * 1e9
                loadMHz.sample(adjMHz);
            }
        }
        previousCpukHz = sampleCpukHz;
    }
    fdprintf(fd, "Simple moving statistics over last %.1f seconds:\n", wall.n() * mixPeriodSec);