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
diff --git a/storaged/EventLogTags.logtags b/storaged/EventLogTags.logtags
index 71fda25..2e25d4a 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 c6cdd81..41bdf97 100644
--- a/storaged/include/storaged.h
+++ b/storaged/include/storaged.h
@@ -250,7 +250,7 @@
#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 fffed6f..9101767 100644
--- a/storaged/include/storaged_uid_monitor.h
+++ b/storaged/include/storaged_uid_monitor.h
@@ -44,8 +44,10 @@
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 2799c39..86a2b21 100644
--- a/storaged/storaged_service.cpp
+++ b/storaged/storaged_service.cpp
@@ -90,9 +90,11 @@
const std::vector<struct uid_event>& 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 fd30f5f..5f664e4 100644
--- a/storaged/storaged_uid_monitor.cpp
+++ b/storaged/storaged_uid_monitor.cpp
@@ -145,23 +145,20 @@
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);