From 284bd76d3e8439ef16cf191ec4263257f814d502 Mon Sep 17 00:00:00 2001 From: Jin Qian Date: Mon, 30 Jan 2017 14:20:07 -0800 Subject: [PATCH] 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 --- storaged/EventLogTags.logtags | 4 +--- storaged/include/storaged.h | 2 +- storaged/include/storaged_uid_monitor.h | 6 ++++-- storaged/storaged_service.cpp | 8 +++++--- storaged/storaged_uid_monitor.cpp | 27 +++++++++++-------------- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/storaged/EventLogTags.logtags b/storaged/EventLogTags.logtags index 71fda25e5..2e25d4a29 100644 --- a/storaged/EventLogTags.logtags +++ b/storaged/EventLogTags.logtags @@ -36,6 +36,4 @@ 2732 storaged_disk_stats (type|3),(start_time|2|3),(end_time|2|3),(read_ios|2|1),(read_merges|2|1),(read_sectors|2|1),(read_ticks|2|3),(write_ios|2|1),(write_merges|2|1),(write_sectors|2|1),(write_ticks|2|3),(o_in_flight|2|1),(io_ticks|2|3),(io_in_queue|2|1) -2733 storaged_emmc_info (mmc_ver|3),(eol|1),(lifetime_a|1),(lifetime_b|1) - -2734 storaged_uid_io_alert (name|3),(read|2),(write|2),(interval|2) \ No newline at end of file +2733 storaged_emmc_info (mmc_ver|3),(eol|1),(lifetime_a|1),(lifetime_b|1) \ No newline at end of file diff --git a/storaged/include/storaged.h b/storaged/include/storaged.h index c6cdd81c7..41bdf9744 100644 --- a/storaged/include/storaged.h +++ b/storaged/include/storaged.h @@ -250,7 +250,7 @@ public: #define DEFAULT_PERIODIC_CHORES_INTERVAL_UNIT ( 60 ) #define DEFAULT_PERIODIC_CHORES_INTERVAL_DISK_STATS_PUBLISH ( 3600 ) #define DEFAULT_PERIODIC_CHORES_INTERVAL_EMMC_INFO_PUBLISH ( 86400 ) -#define DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO ( 3600 ) +#define DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO ( 86400 ) // UID IO threshold in bytes #define DEFAULT_PERIODIC_CHORES_UID_IO_THRESHOLD ( 1024 * 1024 * 1024ULL ) diff --git a/storaged/include/storaged_uid_monitor.h b/storaged/include/storaged_uid_monitor.h index fffed6f19..9101767e5 100644 --- a/storaged/include/storaged_uid_monitor.h +++ b/storaged/include/storaged_uid_monitor.h @@ -44,8 +44,10 @@ struct uid_info { struct uid_event { std::string name; - uint64_t read_bytes; - uint64_t write_bytes; + uint64_t fg_read_bytes; + uint64_t fg_write_bytes; + uint64_t bg_read_bytes; + uint64_t bg_write_bytes; uint64_t interval; }; diff --git a/storaged/storaged_service.cpp b/storaged/storaged_service.cpp index 2799c3933..86a2b219b 100644 --- a/storaged/storaged_service.cpp +++ b/storaged/storaged_service.cpp @@ -90,9 +90,11 @@ status_t Storaged::dump(int fd, const Vector& /* args */) { const std::vector& events = storaged.get_uid_events(); for (const auto& event : events) { - dprintf(fd, "%s %llu %llu %llu\n", event.name.c_str(), - (unsigned long long)event.read_bytes, - (unsigned long long)event.write_bytes, + dprintf(fd, "%s %llu %llu %llu %llu %llu\n", event.name.c_str(), + (unsigned long long)event.fg_read_bytes, + (unsigned long long)event.fg_write_bytes, + (unsigned long long)event.bg_read_bytes, + (unsigned long long)event.bg_write_bytes, (unsigned long long)event.interval); } return NO_ERROR; diff --git a/storaged/storaged_uid_monitor.cpp b/storaged/storaged_uid_monitor.cpp index fd30f5f5b..5f664e4e2 100644 --- a/storaged/storaged_uid_monitor.cpp +++ b/storaged/storaged_uid_monitor.cpp @@ -145,23 +145,20 @@ void uid_monitor::report() for (const auto& it : uids) { const struct uid_info& uid = it.second; - uint64_t bg_read_delta = uid.io[UID_BACKGROUND].read_bytes - - last_uids[uid.uid].io[UID_BACKGROUND].read_bytes; - uint64_t bg_write_delta = uid.io[UID_BACKGROUND].write_bytes - - last_uids[uid.uid].io[UID_BACKGROUND].write_bytes; + struct uid_event event; - if (bg_read_delta + bg_write_delta >= adjusted_threshold) { - struct uid_event event; - event.name = uid.name; - event.read_bytes = bg_read_delta; - event.write_bytes = bg_write_delta; - event.interval = uint64_t(ts_delta / NS_PER_SEC); - add_event(event); + event.name = uid.name; + event.fg_read_bytes = uid.io[UID_FOREGROUND].read_bytes - + last_uids[uid.uid].io[UID_FOREGROUND].read_bytes;; + event.fg_write_bytes = uid.io[UID_FOREGROUND].write_bytes - + last_uids[uid.uid].io[UID_FOREGROUND].write_bytes;; + event.bg_read_bytes = uid.io[UID_BACKGROUND].read_bytes - + last_uids[uid.uid].io[UID_BACKGROUND].read_bytes;; + event.bg_write_bytes = uid.io[UID_BACKGROUND].write_bytes - + last_uids[uid.uid].io[UID_BACKGROUND].write_bytes;; + event.interval = uint64_t(ts_delta / NS_PER_SEC); - android_log_event_list(EVENTLOGTAG_UID_IO_ALERT) - << uid.name << bg_read_delta << bg_write_delta - << uint64_t(ts_delta / NS_PER_SEC) << LOG_ID_EVENTS; - } + add_event(event); } set_last_uids(std::move(uids), curr_ts);