Skip to content
Commit 5065db05 authored by Connor O'Brien's avatar Connor O'Brien
Browse files

Use bpf data when available for per-UID cpu stats



Update KernelCpuUidTimeReader and its subclasses to support reading
frequency, active & cluster times from BPF maps rather than proc files
on devices that support this approach. BPF-based accounting offers
improved accuracy as it can detect every context switch, whereas the
proc files attribute a full tick period to whatever happens to be
running when the tick occurs.
Add a KernelCpuUidBpfMapReader class modeled on
KernelCpuProcStringReader, with singletons for reading each distinct
set of data. These follow the locking approach used by
KernelCpuProcStringReader to ensure thread safety, but they collect
data by calling libtimeinstate functions via JNI rather than reading
text from proc files. They also provide a getDataDimensions() function
to retrieve information currently provided by the header rows of the
proc files, such as the list of available freqs or the number of cores
on each cluster.
Extend the KernelCpu*TimeReaderTest classes to exercise the BPF path
for each reader class, and add a KernelCpuUidBpfMapReaderTest modeled
on KernelProcStringReaderTest.

Bug: 138317993
Test: KernelCpu*TimeReaderTests and KernelCpuUidBpfMapReaderTest pass
Test: no regressions in BatteryStatsTests
Change-Id: Ie7c0b11a47289e16f72fd6868de4185e858c7e4f
Signed-off-by: default avatarConnor O'Brien <connoro@google.com>
parent 9a5d3ad5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment