Commit graph

27 commits

Author SHA1 Message Date
Tom Cherry
3f3b1708d9 storaged: ignore SIGPIPE
It is possible for storaged to terminate due to SIGPIPE if its clients
have terminated.  This is not a fatal condition from storaged's
perspective, so we ignore SIGPIPE instead.

Bug: 151581751
Test: build
Change-Id: I633780ed20908be02e5e1dea9504e140932afc8c
2020-03-17 09:31:01 -07:00
shaozhongqi
cda9b2a500 storaged:Thread out of sync will cause null pointer crash
if other process binder calls dumpPerfHistory when storaged is started, there will be a problem with the storage_sp null pointer

Test: Manual

Bug: 149251684

Change-Id: I9bf61ceb7c34326e95f2355129714d28153a994c
Signed-off-by: shaozhongqi <shaozhongqi@xiaomi.com>
2020-02-11 16:03:41 +08:00
Tom Cherry
b8c1147c4a storaged: replace LOG_TO() macros with LOG()
Storaged always writes to the SYSTEM log, so instead of using
LOG_TO(), it can use the normal LOG() macros as long as it calls
InitLogging() with a default to the SYSTEM log.

Test: storaged writes to the SYSTEM log still
Change-Id: I47e63bc92d55f9b1262a67e3508601ddbd9edc87
2020-01-10 17:10:58 -08:00
David Anderson
bba38cda0f Merge "storaged: remove unused includes" am: 0289f35b83
am: 6cebd27db8

Change-Id: Ia6f60132c3026621252015028cb7ebe2559a47bd
2018-04-06 13:30:11 -07:00
David Anderson
6d65f7c61a storaged: remove unused includes
Bug: 35323867
Test: N/A
Change-Id: I21c0b62765dbd27a462288c5e7577905240720f0
2018-04-05 18:55:08 -07: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
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
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
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
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
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
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
821eb0d007 storaged: fix selinux dac_override denial
Bug: 35250057
Bug: 34198239
Change-Id: I18592d298765dc46ab05f25ae2ced0a5eddacc8b
2017-02-10 18:33:13 -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
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
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
af49d9756f Storaged cleanup
Compliance with Android Coding standards

Test: compile
Bug: 28826771
Change-Id: I10bc4a793bb1da75e8600b81a5d7ff913e310da1
2016-12-21 11:08:24 -08: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