History log of /frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
234d1828ca4a706676ad6f3fa0629959c74297c7 14-Mar-2018 Mike Ma <yanmin@google.com> Resolve STATSD and batterystats race condition

Both STATSD and batterystats need to read uid cpu info. However, uid cpu
stats needs to be cleared from time to time to conserve memory. To
resolve this race condition, only batterystats will remove uid stats,
both from readers and from the kernel, also with a delay, so that STATSD
can access such info before it is removed.

Refactored readers to reuse some common code. Also removed string reader
from KernelUidCpuFreqTimeReader completely since binary reader has been
working fine for a while.

Change-Id: I209bdcec642e1a29a44b566ce98ebbfaaacb4e6a
Fixes: 72172569
Test: BatteryStatsCpuTimesTest
Test: KernelUidCpuActiveTimeReaderTest
Test: KernelUidCpuClusterTimeReaderTest
Test: KernelUidCpuFreqTimeReaderTest
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
ec67661bdfe1814039f625575176678219acc7b1 07-Mar-2018 Chenjie Yu <cjyu@google.com> Refactor cpu stats pullers

use same cpu stats readers with BatteryStats so that
1) both throttle to avoid too frequent pulls
2) cached value is served within throttle interval to avoid double
pulling by both statsd and BatteryStats

To run unit tests:
bit
FrameworksCoreTests:com.android.internal.os.KernelUidCpuFreqTimeReaderTest
bit
FrameworksCoreTests:com.android.internal.os.KernelUidCpuClusterTimeReaderTest
bit
FrameworksCoreTests:com.android.internal.os.KernelUidCpuActiveTimeReaderTest

make -j56 statsd_test && adb sync data && adb shell
/data/nativetest64/statsd_test/statsd_test

Test: cts test, unit test
Bug: 73745189
Bug: 73780619
Bug: 73360959

Merged-In: I10a9bc91ca67fa812f4cd71c4fbd73c1a5ba580e

Change-Id: I10a9bc91ca67fa812f4cd71c4fbd73c1a5ba580e
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
69d8b3e0508de7e181f70a3322be626b1527ee0e 23-Feb-2018 Mike Ma <yanmin@google.com> Refactor KernelUidCpuTimeReader

Refactor KernelUidCpu*TimeReader, all extends KernelUidCpuTimeReaderBase.
Refined logging of these classes, avoid spamming system log.

Change-Id: Id8e149ce5be2595292a31de7fe6e1a94cef28bc1
Fixes: 73825907
Test: KernelUidCpu*TimeReaderTest
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
2ab014426647bbc8960fdb4dadfe480b9806676e 13-Feb-2018 Mike Ma <yanmin@google.com> Binary Cpu Time Proc File Reader

Kernel now exposes cpu time proc files in binary format to save cpu
cycles. New proc files are:
Per uid freq time: /proc/uid_cpupower/time_in_state
Per uid active time: /proc/uid_cpupower/concurrent_active_time
Per uid cluster time: /proc/uid_cpupower/concurrent_policy_time
(See PowerProfile.java on how these data are used)
KernelUidCpuActiveTimeReader, KernelUidCpuClusterTimeReader and
KernelUidCpuFreqTimeReader are modified to use these new data.

Meanwhile, statsd needs these data too. So the actual reading
fuctionality is delegated to singletons in KernelCpuProcReader to
accomodate concurrent access of these proc files by more than one
party. When multiple read requests hit the singleton within the
throttle interval, the singleton will return stale data.

Optimization
KernelCpuProcReader reuses the same ByteBuffer to save results.
KernelUid***Reader all reuse the same long[] array to send results
back to BatteryStatsImpl. Estimated saving of ~200 KB GC effort
per read request.

Add a flag to control throttle interval:
kernel_uid_readers_throttle_time

Bug: 72763654
Bug: 71906435
Bug: 71905885
Bug: 70517018
Fixes: 73166477
Fixes: 72172569
Test: BatteryStatsCpuTimesTest
Test: KernelUidCpuActiveTimeReaderTest
Test: KernelUidCpuClusterTimeReaderTest
Test: KernelUidCpuFreqTimeReaderTest
Test: KernelCpuProcReaderTest
Change-Id: I1012667ce3b9eb35e37882a058bd4bceccabbbe9
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
a5bca091d8d6c5e4868835d9a641164084561b20 25-Jan-2018 Sudheer Shanka <sudheersai@google.com> check if per-uid cputimes proc file has correct no. of freqs.

Bug: 66953194
Test: atest core/tests/coretests/src/com/android/internal/os/KernelSingleUidTimeReaderTest.java
Change-Id: I0f5b00dcdb70ff0dcbed3455cf06f2ada21459ff
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
b2f83c16d6669456b237970327ebb9c92a4789f0 14-Nov-2017 Sudheer Shanka <sudheersai@google.com> Update BatteryStatsImpl to track per-procstate cpu times.

BatteryStatsImpl will track this data by reading from
/proc/uid/<uid>/time_in_state whenever process state changes
and will include this data as part of batterystats dump.

Bug: 66953194
Test: atest core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Test: atest hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
Test: atest core/tests/coretests/src/com/android/internal/os/BstatsCpuTimesValidationTest.java

Change-Id: Ibb3e07f518aaf7eea2a00bb95b95dc5f7e09552e
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
89182980450298763af9d5f46989f6239fa7a2da 02-Nov-2017 Jeff Sharkey <jsharkey@android.com> Narrower StrictMode defaults.

Until now, userdebug and eng builds have tracked StrictMode
violations on all system apps, including prebuilts that we have no
control over, which results in a lot of unactionable noise.

This CL narrows the set of enabled apps to only "bundled" system
apps, which gives us a much higher chance of burning these violations
down to 0 and keeping them there. We don't have a good proxy for an
app being "bundled", so we detect it based on being in the "android."
or "com.android." package namespace.

Clean up the entire flow of applying StrictMode defaults to make it
much more human-readable. This resulted in us fixing a bug where
StrictMode was never actually enabled for jank-sensitive threads in
system_server!

Relax I/O checks in a few places where we know we're interacting with
procfs or sysfs. Add internal "allow" methods that avoid object
allocation by returning raw mask.

Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.cts.StrictModeTest
Bug: 68662870
Change-Id: I536e8934fbcdec14915fcb10995fc9704ea98b29
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
4158f4b8fb7a2d01f1821da5c2357a446e27b0a8 29-Aug-2017 Sudheer Shanka <sudheersai@google.com> Merge "KernelUidCpuFreqTimeReader: Put logs under debug flag." into oc-mr1-dev am: 903dc2fdd2
am: 4411d84551

Change-Id: I4a1a8b21333f7a395a4a3aa571e1aca19b89fd09
6b1396e8feef1f923a01daa56aa58ea3fffdcb82 29-Aug-2017 Sudheer Shanka <sudheersai@google.com> KernelUidCpuFreqTimeReader: Put logs under debug flag.

Bug: 63041570
Test: N/A
Change-Id: Ifdeacb227bb936de82af9c9505621b327de3a9d2
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
523c42e85cb8fcf99d25570de184096a0ed02f11 24-Aug-2017 Sudheer Shanka <sudheersai@google.com> Merge "Merge "Change KernelUidCpuFreqTimeReader Slog.wtf to Slog.e" into oc-mr1-dev am: 29091ec55f" into oc-mr1-dev-plus-aosp
am: 383551da86

Change-Id: I9303dbda0f4d82c161d8cddacc8d3a56ebe1d52c
8cde930d71cc73a5712e48f144506a628bcbd366 23-Aug-2017 Sudheer Shanka <sudheersai@google.com> Change KernelUidCpuFreqTimeReader Slog.wtf to Slog.e

Bug: 63041570
Test: N/A
Change-Id: I2cb12f1b8f0333c4a000d601624dc95934cf9b90
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
b8ad594300b26c89a1b4b0ec4957b49600e58c08 08-Aug-2017 Sudheer Shanka <sudheersai@google.com> Use cpu freq times to calculate power consumed by an uid.

Initially we used to approximate times spent by an uid at a particular
freq using total time spent by the uid but since now the freq times
are directly available from the proc file, we can use these to
calculate power.

Bug: 62240247
Test: bit FrameworksCoreTests:com.android.internal.os.BatteryStatsTests
Test: cts-tradefed run singleCommand cts-dev -m CtsIncidentHostTestCases -t \
com.android.server.cts.BatteryStatsValidationTest
Test: Used some apps and verified that battery usage is attributed to
those apps in Battery settings.
Change-Id: Ia8e2eb07fd778b8a8c83a6acec711e7b97aefdc0
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
40c43f1b091445169e4d91b386f01ce8cc55d087 09-Aug-2017 Sudheer Shanka <sudheersai@google.com> Change logging format in KernelUidCpuFreqTimeReader.

TimeUtils.formatForLogging takes currentTimeMillis as
argument, not elapsedRealTime.

Bug: 63041570
Test: visual inspection of logs
Change-Id: I4b880f64a8ead9a6a4a37fa4b9691edfc38a12db
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
c189595b2e882d1ba0933fe8382c95abc4d1c591 19-Jul-2017 Sudheer Shanka <sudheersai@google.com> Merge "Log if there is malformed data in the proc file."
0085752bd02aaafea8084d71218e886d92e16956 07-Jul-2017 Sudheer Shanka <sudheersai@google.com> Log if there is malformed data in the proc file.

Bug: 63041570
Test: bit FrameworkCoreTests:com.android.internal.os.KernelUidCpuFreqTimeReaderTest
Change-Id: I0aa5b33a33770a1ec220d7772a57b2dae38725b0
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
b3f68233d9ae25b14b8ddc9455b89197e6fe6399 06-Jul-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Stop tracking user specific uid cpu time on user stop"
e6e723d588bf7ebd7ec28d97c31ee44b5b4e0b54 15-Jun-2017 Suprabh Shukla <suprabh@google.com> Stop tracking user specific uid cpu time on user stop

Telling kernel module uid_cputime to stop accounting time for uids
belonging to a stopped user. Upon user remove, removing uid states for
those uids.

Test: adb shell am instrument -e class \
com.android.internal.os.BatteryStatsUserLifecycleTests -w \
com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

adb shell am instrument -e class android.util.SparseLongArrayTest -w \
com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Bug: 62390461
Change-Id: Ibe07778465e3d2c13679e4d88d32f7b92fa959d9
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
97d15bfd4c285d1576c1075b4bd913155d80b0ac 20-Jun-2017 Sudheer Shanka <sudheersai@google.com> Don't callback if all the delta values are zero.

Bug: 25195548
Test: N/A
Change-Id: Ib597ec4c903acfaa78096b8f53dd6b8df7783a3a
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
6d8dcec87200e75ca62715c8feb87794d113e957 01-Jun-2017 Sudheer Shanka <sudheersai@google.com> Update KernelUidCpuFreqTimeReader to handle uid removals.

Bug: 34133340
Test: manual
Change-Id: Iaad2061671d83e1ff6d2797e166ae903f6faec13
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
acd7f2c78320051ddf85448b067e35a71ca3b400 02-Jun-2017 Sudheer Shanka <sudheersai@google.com> Avoid excessive logging when the necessary proc file is unavailable.

Bug: 34133340
Test: manual
Change-Id: Ic00e58a5b7bb7f92a0467df1cab8df5cab7dffda
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java
9b735c5c1a4575d9f0ea9f3229ad8bf9401caee0 10-May-2017 Sudheer Shanka <sudheersai@google.com> Add time spent by uid per cpu frequency to batterystats.

Currently we have total user and system cpu time spent by the uid
in the batterystats. This change will add times spent by the uid
at each different cpu frequency to the batterystats dump which will
help in better understanding the battery usage.

Bug: 34133340
Test: manual
Change-Id: I567dc75875eb58543c0e71572d0b440e87dbb4b9
/frameworks/base/core/java/com/android/internal/os/KernelUidCpuFreqTimeReader.java