From 1275b1b6aaf417243ff3be17a400a21e26c42f39 Mon Sep 17 00:00:00 2001 From: Jin Qian Date: Mon, 6 Feb 2017 14:02:50 -0800 Subject: [PATCH] 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 --- storaged/include/storaged.h | 4 ++-- storaged/include/storaged_uid_monitor.h | 5 +++-- storaged/storaged_service.cpp | 7 ++++++- storaged/storaged_uid_monitor.cpp | 6 +++++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/storaged/include/storaged.h b/storaged/include/storaged.h index a16be27db..0bdff7483 100644 --- a/storaged/include/storaged.h +++ b/storaged/include/storaged.h @@ -302,8 +302,8 @@ public: return mUidm.get_uid_io_stats(); } std::map> get_uid_records( - int hours, uint64_t threshold) { - return mUidm.dump(hours, threshold); + int hours, uint64_t threshold, bool force_report) { + return mUidm.dump(hours, threshold, force_report); } void update_uid_io_interval(int interval) { if (interval >= DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO_LIMIT) { diff --git a/storaged/include/storaged_uid_monitor.h b/storaged/include/storaged_uid_monitor.h index ae850167d..f6250ae7b 100644 --- a/storaged/include/storaged_uid_monitor.h +++ b/storaged/include/storaged_uid_monitor.h @@ -91,10 +91,11 @@ public: // called by storaged -u std::unordered_map get_uid_io_stats(); // called by dumpsys - std::map> dump(int hours, uint64_t threshold); + std::map> dump( + int hours, uint64_t threshold, bool force_report); // called by battery properties listener void set_charger_state(charger_stat_t stat); - // called by storaged periodic_chore + // called by storaged periodic_chore or dump with force_report void report(); }; diff --git a/storaged/storaged_service.cpp b/storaged/storaged_service.cpp index 007b75c41..8624b3b6b 100644 --- a/storaged/storaged_service.cpp +++ b/storaged/storaged_service.cpp @@ -91,6 +91,7 @@ status_t Storaged::dump(int fd, const Vector& args) { int hours = 0; int time_window = 0; uint64_t threshold = 0; + bool force_report = false; for (size_t i = 0; i < args.size(); i++) { const auto& arg = args[i]; if (arg == String16("--hours")) { @@ -111,10 +112,14 @@ status_t Storaged::dump(int fd, const Vector& args) { threshold = stoll(String16::std_string(args[i])); continue; } + if (arg == String16("--force")) { + force_report = true; + continue; + } } const std::map>& records = - storaged.get_uid_records(hours, threshold); + storaged.get_uid_records(hours, threshold, force_report); for (const auto& it : records) { dprintf(fd, "%llu\n", (unsigned long long)it.first); for (const auto& record : it.second) { diff --git a/storaged/storaged_uid_monitor.cpp b/storaged/storaged_uid_monitor.cpp index a186b7346..2c20dba1d 100644 --- a/storaged/storaged_uid_monitor.cpp +++ b/storaged/storaged_uid_monitor.cpp @@ -150,8 +150,12 @@ void uid_monitor::add_records_locked(uint64_t curr_ts) } std::map> uid_monitor::dump( - int hours, uint64_t threshold) + int hours, uint64_t threshold, bool force_report) { + if (force_report) { + report(); + } + std::unique_ptr lock(new lock_t(&um_lock)); std::map> dump_records;