Commit graph

48 commits

Author SHA1 Message Date
Pawan Wagh
f044f7f3dd Adding fuzzers for StoragedService and StoragedPrivateService
- StoragedService and StoragedPrivateService are defined in global
namespace. Moving them to android namespace
- Adding AIDL service fuzzers for both services

Bug: 232439428
Test: adb shell /data/nativetest64/storaged-unit-tests/storaged-unit-tests
Test: m storaged_service_fuzzer && adb sync data && adb shell /data/fuzz/x86_64/storaged_service_fuzzer/storaged_service_fuzzer
Test: m storaged_private_service_fuzzer && adb sync data && adb shell /data/fuzz/x86_64/storaged_private_service_fuzzer/storaged_private_service_fuzzer
Change-Id: Ieb6ff8117f548dd1ef376aab8e6d3dfec9fb06d3
2023-04-24 23:16:32 +00:00
Yifan Hong
5291a67ee3 storaged: use health HAL
Test: storaged_test
Test: manual
Bug: 208543110

Change-Id: I60d42fc4f2e411f375fe98d1c8e145ce79c52f88
2021-12-06 23:09:37 -08:00
Mark Salyzyn
79fc288f10 storaged: protect global proto_loaded
proto_loaded is not thread safe, so we must protect it with
a mutex proto_lock.

Signed-off-by: hanhongli@360.cn
Signed-off-by: gongguang@360.cn
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 170732441
Test: compile
Change-Id: I93416598b6047e890c66b922b360093aa42db8c5
(cherry picked from commit d179cbcdc2)
2020-12-15 21:46:28 +00:00
David Anderson
379003e77f storaged: Cap io_history when loading stats from disk.
Similar to add_record_locked, load_uid_io_proto should respect the
maximum number of records.

Bug: 111578975
Test: storaged_test.load_uid_io_proto
Change-Id: Ic3c5095cdd09d2184f436813b5ab50d3ee0007b2
2018-07-27 10:01:28 -07:00
David Anderson
21f20feec9 storaged: Don't duplicate uid_records from proto files.
It is possible for storaged to load the same saved proto file multiple
times, for example, if system_server crashes. In this case we do not
want to fill io_history with duplicate entries. This patch elides
records for which an app+userid record already exists for the same
timestamp.

Bug: 111578975
Test: gtest storaged_test.load_uid_io_proto
Change-Id: I87bc3e37d6464079cece03b5852285d79067b935
2018-07-27 09:48:55 -07:00
David Anderson
423046bbf6 storaged: Fix-up private variable names in uid_monitor.
Bug: N/A
Test: storaged builds
Change-Id: Ifd21e25baa7b1c6ce41c5e0ec5247f47ba716e6e
2018-07-27 09:48:49 -07:00
Yifan Hong
0b31908912 storaged: fix headers.
Add missing libbatteryservice_headers dependency.
It used to use global header include dirs, which is bad.

Add old transitive dependency from libbatteryservice_headers
as well.

Test: builds
Bug: 68724651

Change-Id: Idcc4452160dce70b4f8b48e2d809dcd5744b93b4
2018-05-04 14:25:09 -07:00
David Anderson
f2dd78bb2c storaged: fix divide-by-zero when updating history
Bug: 75984894
Test: storaged unit tests on x86/64 platforms
Change-Id: I869b3dc6e42aa71100a99a84344dbc30c319d280
2018-03-26 15:53:23 -07:00
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
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
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
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
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
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
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
5ec6b90c39 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
Change-Id: Ia785bb6f5ea259aa43cd1efab9505ebefaf3db12
2017-03-31 16:13:55 -07:00
Jin Qian
b90f1ae1e5 storaged: add support for ufs health info
Test: adb logcat -d -b events | grep storaged_emmc_info
Bug: 36228467
Change-Id: I519fe2b8a99c1c31f1fe720bd671904d1ab609bb
2017-03-28 15:08:37 -07:00
Jin Qian
726339c7e8 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
Change-Id: I2a181f52c9f19de1e679a3a905aaebafe4d08227
2017-03-28 15:08:31 -07: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
e83a6107c7 storaged: track fsync calls
Change-Id: Ibdb6a1703245a5de04cb4a2ee5b8ecfbed8b86fc
2017-03-02 16:16:54 -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
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
Jin Qian
1275b1b6aa storaged: add --force option to dumpsys
This option forces storaged to generate io usage report since last
report. This is for testing purpose so that we can run some app and
get the app's IO usage right away instead of waiting an hour for next
report.

Bug: 34198239
Bug: 34845096
Change-Id: I9cd217df37a9b6c8f383eb25d41602e8e8c8f9ba
2017-02-10 15:48:21 -08:00
Jin Qian
e5ea17c840 storaged: add dumpsys flags to limit data size
--threshold <bytes>
This skips io usage not greater than <bytes> for current report.

--time_window <secs>
This sets uid_io collection interval to <secs> for future reports.
The new interval will be ignore if it's less than 5 minutes.

Test: adb shell dumpsys --threshold 4096 --time_window 300
Bug: 33086174
Bug: 34198239
Change-Id: I723c0850fa504a113da0a14945c4fbc64ea47659
2017-02-10 15:28:34 -08:00
Jin Qian
5b962c6dbd storaged: account on/off charger per uid io usage
Register a listener to batteryproperties service for charger stats
change.

Aggregate IO usage based on charger stats in a collection window.

Bug: 33086174
Bug: 34198239
Change-Id: Ibe306c9c3ff8b8ada6be034aa8511268cb9a9b1c
2017-02-07 21:41:15 +00:00
Jin Qian
9cdfdd3ff9 storaged: add --hours flag for dumpsys
1. Add a flag to report IO usage for last N hours.
2. Change interval back to 1 hour so that we have finer usage data.
3. Don't clear events after dumpsys call. Use a max buffer limit.
4. Clear old events if they're more than 5 days old or when no room
for new events.
5. Skip uids with no IO usage to save space.
6. Replace interval with a timestamp in event entry.

Test: adb shell dumpsys storaged --hours 2
Bug: 34198239
Bug: 33086174
Change-Id: I66e8fb6ec155584115fab817c3ed2c78e637ac40
2017-02-01 16:48:21 -08:00
Jin Qian
284bd76d3e storaged: change uid_io reporting
Increase reporting interval to once per day.
Report foreground and background I/O usage.
Remove threshold to report all usages.

Test: adb shell dumpsys storaged
Bug: 34198239
Bug: 33086174
Change-Id: I3b4ea8200bdb8becb5b441051f52477bbd1f3ccf
2017-01-30 14:22:49 -08:00
Jin Qian
a2e5bd1347 storaged: add dumpsys interface
Write alerts to an internal buffer and flush to dumpsys
when dump is called.

Test: adb shell dumpsys storaged
Bug: 33086174
Bug: 34198239
Change-Id: I39e5dfd9c4e9a5f3ec3d74356b28e9ddf77f6624
2017-01-25 18:07:30 -08:00
Jin Qian
88ad33eff1 storaged: remove task io code
Bug: 34612499
Change-Id: Id0599ee2ae025a186259e95363c1ddd0feae8079
2017-01-24 14:45:50 -08:00
Jin Qian
3790f5bfaf storaged: replace cmd arguments with properties
Add properties to control event intervals.
Add a property to check time spent in event loop.

Bug: 34612341
Bug: 34198239
Change-Id: I01f64c84e17153377ece7ae530be106e3f55287e
2017-01-24 14:45:50 -08:00
Jin Qian
bcd6e3b9d9 storaged: monitor per-uid IO usage
Add uid_monitor class to query /proc/uid_io/stats periodically.
Add a log tag to record any UID that exceeds IO threshold.

Test: adb shell storaged -u
Bug: 34198239
Change-Id: I53568c30dbefe2f4bdb18054d3dedb30b4133d8b
2017-01-24 14:45:35 -08:00
Jin Qian
b00d5467d3 storaged: fix crash when cmdline is longer than 64 characters
Bug: 34331490
Change-Id: I40302f4d54b7d8fe4fc5ecbc76df42df68a35504
2017-01-17 15:45:05 -08:00
Jin Qian
27506fa41f storaged: remove redundant logging
Don't log disk_stats and emmc_info to system buffer since they
are already uploaded to events buffer.

Use DEBUG flag to control disk perf logging.

Bug: 34331490
Change-Id: I5f628a1a46e1f72588da064523da69737bd67dcb
2017-01-17 15:43:25 -08:00
Jin Qian
0c77270ffc storaged: increase periodic polling interval
set default polling internal to 1 minute
set default disk stats publish to 1 hour
set default emmc info publish to 1 day

Bug: 34331490
Change-Id: Ifd86ddf9d826fb252de9dc8d6881e80ccb193e3b
2017-01-17 15:37:37 -08:00
Jin Qian
535ddbe2c9 storaged: replace kmsg with LOG macros
Also convert android_log_event to C++ style calls.

Change-Id: I7d62c81789fe7925fe9cae3e2a798b6af8c8be9d
2017-01-13 19:02:23 +00:00
ynwang
62cb372279 storaged: add storaged native daemon
Storaged periodically checks the devices' disk stats and eMMC lifetime.
This information is logged to both the kernel and event log. By event
logging, the data can be aggregated by the checkin service and then
sent to Sawmill.

It also periodically traverses /proc/[pid], maintaining the I/O usage of
all tasks (all sampled tasks). The task I/O data can be reported using
the --dump option.

Storaged is booted when the device boots up and requires the permission
for reading /proc/diskstats, /proc/[pid]/io and debugfs(eMMC ext_csd).
For detailed description, please refer to go/storaged.

Bug: 28826771
Change-Id: I774b1a44cc30092bac1bfcbc08bf487295e7cfed
2016-12-15 15:56:33 -08:00