summaryrefslogtreecommitdiffstats
path: root/storaged/include
diff options
context:
space:
mode:
authorJin Qian <jinqian@google.com>2017-01-31 17:33:20 -0800
committerJin Qian <jinqian@google.com>2017-02-01 16:48:21 -0800
commit9cdfdd3ff9481318a1631bd5584bfb527756d4d4 (patch)
tree5f69e16744acf3d8407a24db36e9b0648045fb71 /storaged/include
parent2bd3e9cefde5d49e6f9fec7f0bea600a5316ce58 (diff)
downloadsystem_core-9cdfdd3ff9481318a1631bd5584bfb527756d4d4.tar.gz
system_core-9cdfdd3ff9481318a1631bd5584bfb527756d4d4.tar.bz2
system_core-9cdfdd3ff9481318a1631bd5584bfb527756d4d4.zip
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
Diffstat (limited to 'storaged/include')
-rw-r--r--storaged/include/storaged.h8
-rw-r--r--storaged/include/storaged_uid_monitor.h9
2 files changed, 11 insertions, 6 deletions
diff --git a/storaged/include/storaged.h b/storaged/include/storaged.h
index 41bdf9744..ba78882e1 100644
--- a/storaged/include/storaged.h
+++ b/storaged/include/storaged.h
@@ -45,6 +45,8 @@ friend class test_case_name##_##test_name##_Test
#define MSEC_TO_USEC ( 1000 )
#define USEC_TO_NSEC ( 1000 )
#define SEC_TO_USEC ( 1000000 )
+#define HOUR_TO_SEC ( 3600 )
+#define DAY_TO_SEC ( 3600 * 24 )
// number of attributes diskstats has
#define DISK_STATS_SIZE ( 11 )
@@ -250,7 +252,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 ( 86400 )
+#define DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO ( 3600 )
// UID IO threshold in bytes
#define DEFAULT_PERIODIC_CHORES_UID_IO_THRESHOLD ( 1024 * 1024 * 1024ULL )
@@ -294,8 +296,8 @@ public:
std::unordered_map<uint32_t, struct uid_info> get_uids(void) {
return mUidm.get_uids();
}
- std::vector<struct uid_event> get_uid_events(void) {
- return mUidm.dump_events();
+ std::vector<struct uid_event> get_uid_events(int hours) {
+ return mUidm.dump_events(hours);
}
};
diff --git a/storaged/include/storaged_uid_monitor.h b/storaged/include/storaged_uid_monitor.h
index 9101767e5..ac6a8bd9f 100644
--- a/storaged/include/storaged_uid_monitor.h
+++ b/storaged/include/storaged_uid_monitor.h
@@ -48,7 +48,10 @@ struct uid_event {
uint64_t fg_write_bytes;
uint64_t bg_read_bytes;
uint64_t bg_write_bytes;
- uint64_t interval;
+ uint64_t ts;
+ bool operator< (const struct uid_event& e) const {
+ return ts < e.ts;
+ }
};
class uid_monitor {
@@ -67,8 +70,8 @@ public:
int get_periodic_chores_interval() { return interval; }
std::unordered_map<uint32_t, struct uid_info> get_uids();
void report();
- void add_event(const struct uid_event& event);
- std::vector<struct uid_event> dump_events();
+ void add_events(const std::vector<struct uid_event>& new_events, uint64_t curr_ts);
+ std::vector<struct uid_event> dump_events(int hours);
};
#endif /* _STORAGED_UID_MONITOR_H_ */