Commit Graph

70 Commits

Author SHA1 Message Date
Hridya Valsaraju 79d38ebcaf health: Modify IHealthInfo Callback interface to return V2.0 HealthInfo
Bug: 71860528
Test: vts-tradefed run vts -m VtsHalHealthV2_0
Change-Id: I7de39ffa4c21772d8878c9a3f054bc6dbbde2fb9
2018-01-18 14:51:26 -08:00
TreeHugger Robot 7b94ae273b Merge "Provide Recent Disk Perf via IStoraged" 2018-01-18 02:50:48 +00:00
Yifan Hong 845e35bdc3 storaged: use health HAL to read StorageInfo.
Test: storaged unit tests
Bug: 68388678

Change-Id: Iec395a33bac72f49366e8c30ea7e709c8acdcfa2
2018-01-16 19:25:01 -08:00
Yifan Hong c4b46e0ad9 storaged: use health HAL to read DiskStats.
Test: storaged unit tests
Bug: 68388678
Change-Id: I03ce3aa71fb54ae40489c7b35973cd4b83b13bfb
2018-01-16 19:24:54 -08:00
Yifan Hong 4a43bdc5f5 storaged: storaged_t replace initHealthService with init.
storaged_t has more fields that depend on the health service;
they should be initialized in the new init() function.

Test: storaged unit tests

Change-Id: I70d41e5d0a0ef20c39c41c7539a284937bd21ad5
2018-01-16 19:19:37 -08:00
Yifan Hong 70c44e7a6a storaged: use get_health_service
Test: storaged unit tests
Bug: 68388678
Change-Id: I67100a9a0ad27f9e5b8fc077ff83c442e2bebe71
2018-01-16 18:05:19 -08:00
Michael Wachenschwanz 37b912b805 Provide Recent Disk Perf via IStoraged
Expose recent disk write performance to Java side services.

Bug: 62393328
Test: manual
Change-Id: I6002681b17e7f5b9538b4dc9e312843cf838e467
2018-01-08 19:06:22 -08:00
Jin Qian 4c23c4576b storaged: align buffer address and size for direct_io
O_DIRECT requires buffer address and size to be aligned

Bug: 63629306

Change-Id: I268abb1c0ba32af4fd2e92210192c47a1f173238
2017-12-13 15:54:55 -08:00
Elliott Hughes 3e2b34136a Merge "Add OWNERS." am: 3289b9c928 am: 515c8fe572
am: aede8375fe

Change-Id: I28f7a8f3fa9c9837f4043768e70c0d985ed95abd
2017-12-08 01:29:20 +00:00
Elliott Hughes 3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes 693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
Colin Cross c2a3a20c2c Export AIDL files as a filegroup for framework.jar
Put AIDL files into a filegroup so they can be imported as sources
for framework.jar.

Test: m checkbuild
Change-Id: I1a5335384e9291af1f26e7418f15fcfa082ee356
2017-11-30 10:22:40 -08:00
Jin Qian 94b64ef332 storaged: remove protos from storaged class
protobuf is only needed when serializing/deserializing data. Instead of
maintaining a permanent buffer in storaged object, move the container to
stack so that the buffer is released when we don't need it. In addition,
we don't need to clear the buffer before updating it.

Also added a function to clear user io history when the user is removed.

Bug: 63740245
Change-Id: Ia5d19b9a0c3f92a93b061a56be89bb0b958a2a29
2017-11-09 17:24:58 -08:00
Jin Qian 0700f3b863 Merge "storaged: fix regression found in unit-test" 2017-11-07 07:54:16 +00:00
Yifan Hong e3526facb5 Merge changes from topic "health2-health1"
* changes:
  storaged: update for using 1.0::HealthInfo.
  Health@2.0: uses @1.0::HealthInfo
2017-11-07 06:42:13 +00:00
Yifan Hong 348bc20bf8 storaged: update for using 1.0::HealthInfo.
Test: boots
Bug: 63702641

Change-Id: I97e322af97347c603f10b5b5b82cd3ae52c58b8f
2017-11-06 13:14:18 -08:00
Jin Qian 65d8c03d35 storaged: fix regression found in unit-test
Should use reference instead of copy to clear storaged proto

Bug: 63740245
Change-Id: Ibb933a0bac12508467fc104b37e7cc490dfbe948
2017-11-06 19:07:09 +00:00
Yifan Hong 3cf55ef056 do not getTransport before getting IHealth service.
getService already has getTransport logic.

Test: storaged unit tests

Bug: 63702641
Change-Id: I29be15e5713ac276fbbeda88224d8aef514319c6
2017-11-03 13:20:10 -07:00
Jin Qian 6df3bc6301 storaged: split proto file into multiple CE areas
Use user_id (from app uid) to determine file location.
/data/misc_ce/<user_id>/storaged/storaged.proto

Vold notifies storaged when a user's CE area becomes available.
Then storaged restores data from the proto in that area and
combines them into IO history.

Vold also notifies storaged when the CE area is being deleted.
Storaged clears internal history about this user and deletes the
proto file.

IO perf is stored in user_0 area since it's not user related.

Test: dumpsys storaged before/after multiple users' unlock
Bug: 63740245
Change-Id: I39f923f6b09e9f2a29e9286ce02b3b3bcbfb9f94
2017-10-31 14:31:13 -07:00
Yifan Hong bf2dcb2e1b storaged: talk to healthd in hwbinder.
Test: storaged-unit-tests
Change-Id: I6ebfea3470b4b37b2516ffb2b14385f65bb4b80e
2017-10-19 14:55:53 -07:00
Jin Qian a8533325d5 storaged: move proto file to /data/misc_ce/0/storaged
Use proto_stat to indicate status of CE area. Before user_0 unlocks,
storaged detects CE NOT_AVAILABLE when attempting to read the proto
file. It then skips reading/writting the proto.

When user_0 logs in, vold calls onUserStart in storaged, which sets
proto_stat to AVAILABLE. At next event, storaged tries to read the
proto. If it's a success, proto_stat is changed to LOADED. After that,
storaged reads and writes proto normally.

Test: adb shell storaged -u -p
Bug: 63740245
Change-Id: I1fdd42c430e91682f6cc07497fcad5be52489b4e
2017-10-18 13:50:03 -07:00
Jin Qian b049d18b0a storaged: use AIDL to generate storaged binder calls.
Split binder calls into two separate services.

"storaged" service will be used by external clients, e.g. vold.
- Added stub onUserStarted/onUserStopped to prepare for moving
storaged.proto into ce area.

"storaged_pri" private service will be used by storaged cmdline,
e.g. adb shell storaged -u
- Added parcelable UidInfo for private service.
- Change format of perf history to one vector with first 3 elements
showing size of recent/daily/weekly perf history.

Test: adb shell storaged -u -p
Bug: 63740245
Change-Id: Ib0367282a95b6cb0a38f064f0456e849ecccc210
2017-10-18 13:50:03 -07:00
Jin Qian d691d6e941 storaged: record IO perf history from proto updates
Record the bandwidth when writing storaged.proto to monitor system
storage performance.

The history is maintained in 3 catergories.
1. samples of last 24 hours.
2. daily average of last 7 days.
3. weekly average of last 52 weeks.

Sampling frequency of the first catergory is set to once every hour.
Storaged also flushes proto at same frequency.

The proto file is padded to reach a minimal size of 128KB. Storaged
writes 16KB at a time. Bandwidth calculation ignores time spent in
the first write and writes smaller than 16KB.

bandwidth = total size of 16KB writes / time spent in 16KB writes

Restructured the code so that storaged.cpp handles proto load/flush.
It calls individual module to sync proto with internal data
structures.

Added a cmdline argument to dump perf history.

adb shell storaged -p
I/O perf history (KB/s) :  most_recent  <---------  least_recent
last 24 hours : 5315 3775 3659 2042 3890 5652 3649 3696 6023
last 7 days   : 4648 3532 3828 3567 3841 3359 4676
last 52 weeks : 3817 4275 3836 3766 4280 0 0 0 0 0 ...

Test: adb shell storaged -p
      atp:asit/perf/jank_systemui_test
      atp:asit/perf/appstartup_hermetic_cyclic_dropcache_test
      atp:asit/perf/appstartup_non_hermetic_cyclic_dropcache_test

Bug: 63629306
Change-Id: Ie7051e7a8df883d4a6818ea9a54a10f4dccb4843
2017-10-10 00:56:03 +00:00
Jin Qian 65dea71248 storaged: clean up disk stats code
Merged disk_stats_publisher into disk_stats_monitor class.

Moved proc file check to disk_stats class instead of doing so in
storaged, same for uid_io.

Added is_zero function to check zero disk_stats.

Added operators to compute disk_stats.

Change-Id: I277ae51f6fe18464f92e45c03471343784e67093
2017-10-02 15:45:14 -07:00
Jin Qian 0e02687d3f storaged: fix task io stats parsing
comm field in task io stats string can have comma since this field
includes task arguments. As a result, splitting the string by comma
doesn't always give 13 fields. Parse the string in following way to
fix that.

last 11 fields -> pid and io stats
Second field to 12th from last -> comm

Bug: 63739275
Change-Id: I6a2418260444c71d6492fc6cbd639d3cc54ceaed
2017-09-28 11:29:51 -07:00
Jin Qian ebf031be98 storaged: store io_history as protobuf file on userdata
Convert storaged internal io_history to protobuf format and serialize
it to userdata partition. Also load this file during storaged startup
to reconstruct io history.

Bug: 63740245
Change-Id: I0697525df1c31fdec20f5ed4e3e9363e2dde244f
2017-08-15 17:00:19 -07:00
Jin Qian e4f1ec315d storaged: convert Android.mk to Android.bp
Change-Id: Ia59f6cc94f0eaea531a8e516b0492e0dfecc6ce0
2017-08-15 16:56:28 -07:00
Yang Jin c61cdfe5c3 storaged: add parser for dumpsys storaged output
Rank uids by io stats and display their tasks. Can either rank by combining
io stats for same uids or io stats for the last appearing uid.
See python ranker.py -h for details.

Test: python ranker.py -i io.txt -o output.txt -u 20 -cnt

Bug: 63739275
Change-Id: Ieee1d7a9bf190266fc6a055c0922434fcd9099c6
2017-08-09 15:25:19 -07:00
Jin Qian 9c54268dce storaged: call getNamesForUids to get uid names
Calls getNamesForUids when one of the two conditions are true.
1. entries for new uids are reported from io stats
2. previous getNamesForUids failed

Bug: 62805090
Merged-In: I120b81e1857b2aa0a90d0fb85c8d749e985df78e
Change-Id: I120b81e1857b2aa0a90d0fb85c8d749e985df78e
2017-08-08 20:59:03 +00:00
Jin Qian 2d7bcceefc storaged: call getNamesForUids to get uid names
Calls getNamesForUids when one of the two conditions are true.
1. entries for new uids are reported from io stats
2. previous getNamesForUids failed

Bug: 62805090
Change-Id: I120b81e1857b2aa0a90d0fb85c8d749e985df78e
2017-08-08 10:51:17 -07:00
Jin Qian ccae2b5779 storaged: fix excessive accounting when io usage has negative delta
When current io bytes are smaller than previous bytes, add 0 to delta
instead of adding current io bytes.

Bug: 64317562
Merged-In: If0c9814892ad61b790baa6395649af10b11d5b7c
Change-Id: I1ffd7ac33649ab3b8405c83b1328fa9bf49702c0
2017-08-03 17:28:52 +00:00
Jin Qian 6abe26cdf4 Merge "storaged: add task io to dump service" 2017-07-26 22:47:42 +00:00
Yang Jin 3906c89206 storaged: add task io to dump service
Display task io in dump service when both kernel logs task io to
proc/uid_io/stats and when debug flag is enabled.

Also add -t flag to display both uid and task io for storaged.

Tests:
adb shell
dumpsys storaged --debug
storaged -t

Bug: 63739275

Change-Id: If0c9814892ad61b790baa6395649af10b11d5b7c
2017-07-26 12:46:08 -07:00
Jin Qian 8847c62579 storaged: record userdata space utilization
Update disk space utilization together with diskstats since we will
use free space size to co-relate disk performance.

Bug: 63629306
Change-Id: I4e5694aaff3b71aa56db451f1bc92ccfb07e5086
2017-07-17 15:51:30 -07:00
Jin Qian 26b2be0d30 storaged: stop binder threads before exiting
Test: kill healthd when storaged is running
Bug: 36652060
Change-Id: Ie55fb6cb7c8c6df6ce6bc4820c476b90cc0f4165
2017-04-04 19:44:01 +00:00
Jin Qian 566e63da53 storaged: exit if batteryproperties service is dead.
storaged relies on batteryproperties service (healthd) to provide
charger stats. If healthd is killed, kill storaged as well. Both
will be restarted by init process anyway to restore a correct state.

Test: kill healthd when storaged is running
Bug: 36652060
Merged-In: Ia785bb6f5ea259aa43cd1efab9505ebefaf3db12
Change-Id: Ia785bb6f5ea259aa43cd1efab9505ebefaf3db12
2017-04-04 17:45:41 +00:00
Jin Qian 4882eaba25 storaged: use sp<> to keep refcount for storaged_t object
BatteryListener takes sp<> as parameter. Passing raw storaged_t ptr
to BatteryListener will cause the ptr to be freed when BatteryListener
releases the sp<>. Keep a refcount in storaged to prevent this from
happening.

Test: kill healthd while storaged is running
Bug: 36652060
Change-Id: I96bc45a3bedb39eb7158b8f6c86334b5b31c9346
2017-04-03 23:13:26 -07:00
Jin Qian ba27df4d0f storaged: skip batteryproperties listener if uid_io not available
uid_monitor is the only user of batteryproperties, no need to register
a callback if uid_io not enabled.

Test: run storaged without uid_io, plug/unplug usb cable
Merged-In: If890a93fec155b67c450341c54b44bb18d3aae3d
Change-Id: If890a93fec155b67c450341c54b44bb18d3aae3d
2017-04-03 16:48:44 +00:00
Jin Qian 808f703609 storaged: add support for ufs health info
Test: adb logcat -d -b events | grep storaged_emmc_info
Bug: 36228467
Merged-In: I519fe2b8a99c1c31f1fe720bd671904d1ab609bb
Change-Id: I519fe2b8a99c1c31f1fe720bd671904d1ab609bb
2017-04-03 16:48:30 +00:00
Jin Qian 8197093497 storaged: read emmc health data from sysfs
Sysfs data is straightforward so we don't need parsing anymore.

Also removed periodical check since data is set only once during
driver initialization. Checking at every device boot or storaged
restart should be sufficient to monitor long term status change.

Test: adb logcat -d -b events | grep storaged_emmc_info
Bug: 36228467
Merged-In: I2a181f52c9f19de1e679a3a905aaebafe4d08227
Change-Id: Ic05e353f0af9363f3bcbe793ba0c351082e446ca
2017-04-03 16:48:14 +00:00
Jin Qian 4fc338e60b storaged: rewrite emmc info class
Test: adb logcat -d -b events | grep storaged_emmc_info
Bug: 36228467
Change-Id: Ib799e60ed65661a9fb99be8ad4c930f547339975
2017-03-16 16:12:55 -07:00
Jin Qian 4bcc8b6526 storaged: clean up output format
make it easy to use scripts parsing output

Test: adb shell storaged -u
Change-Id: I459078c4ddf6e18fe1eb05d25d564e6e6d03e87e
2017-03-14 12:43:40 -07:00
Jin Qian 9b1aeae730 storaged: replace string functions that can throw exception
android coding style doesn't allow exception handling which leads
to crash when any function throws exception. Replace such functions
in storaged to gracefully handle invalid inputs.

Test: adb shell dumpsys storaged --hours N --time_window 300
Bug: 36131658
Change-Id: I36be1b49c4d9977a01d1bd4c9ca57d49322d95f4
2017-03-14 11:20:02 -07:00
Steven Moreland 629843670a storaged: remove usage of String16::std_string
<string> is being removed from String16

Test: adb shell dumpsys storaged <all options>
Change-Id: I234ecd64d9c481cb2eeee883a715f2fbfaecc511
2017-03-10 21:35:31 +00:00
Jin Qian e83a6107c7 storaged: track fsync calls
Change-Id: Ibdb6a1703245a5de04cb4a2ee5b8ecfbed8b86fc
2017-03-02 16:16:54 -08:00
Jin Qian f97e6e7dd4 storaged: reduce storaged privilege
Remove storaged from system group.
Let init set priority based on rc file.

Test: adb shell dumpsys storaged --force
Bug: 35323867
Change-Id: I9d893ec69d9cc34a9e24f47166384efd7ef4d9d2
2017-02-27 12:52:04 -08:00
Jin Qian 8157775d79 storaged: include start time in IO usage dumpsys
New format:
starttime1,endtime1
records
[starttime2],endtime2
records

Note starttime2 is skipped if it equals with endtime1.

Bug: 34198239
Change-Id: I8a88a3bf1d50e065510d3ab123422d564fb6159f
2017-02-21 15:33:22 -08:00
Jin Qian baff640d5d storaged: handle negative delta in io usage
When UID is uninstalled and reinstalled, IO usage of the UID is
reset. This caused problem in accounting since it assumes IO usage
is always increasing for the same UID. In such case, use the current
usage instead of negative delta for accounting.

Bug: 34198239
Change-Id: I74661feccc05d19ba8a0feff8a2e38d72c7d1465
2017-02-16 18:46:41 -08:00
Jin Qian 821eb0d007 storaged: fix selinux dac_override denial
Bug: 35250057
Bug: 34198239
Change-Id: I18592d298765dc46ab05f25ae2ced0a5eddacc8b
2017-02-10 18:33:13 -08:00
Jin Qian dd41d6b171 storaged: allow dump window to be less than an hour
This is useful for CTS where we just need dump from last few minutes.

Bug: 34198239
Bug: 34845096
Change-Id: Ic543e7184606f419f8989bf0cb992cd46e48845c
2017-02-10 17:25:34 -08:00