summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Qian2017-02-06 16:02:50 -0600
committerJin Qian2017-02-10 17:48:21 -0600
commit1275b1b6aaf417243ff3be17a400a21e26c42f39 (patch)
tree0a36a20c48e86c71a5a4393754cdea3493ea2a46 /storaged
parente5ea17c84024badac9498bd61d1c07f253d75cac (diff)
downloadplatform-system-core-1275b1b6aaf417243ff3be17a400a21e26c42f39.tar.gz
platform-system-core-1275b1b6aaf417243ff3be17a400a21e26c42f39.tar.xz
platform-system-core-1275b1b6aaf417243ff3be17a400a21e26c42f39.zip
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
Diffstat (limited to 'storaged')
-rw-r--r--storaged/include/storaged.h4
-rw-r--r--storaged/include/storaged_uid_monitor.h5
-rw-r--r--storaged/storaged_service.cpp7
-rw-r--r--storaged/storaged_uid_monitor.cpp6
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:
302 return mUidm.get_uid_io_stats(); 302 return mUidm.get_uid_io_stats();
303 } 303 }
304 std::map<uint64_t, std::vector<struct uid_record>> get_uid_records( 304 std::map<uint64_t, std::vector<struct uid_record>> get_uid_records(
305 int hours, uint64_t threshold) { 305 int hours, uint64_t threshold, bool force_report) {
306 return mUidm.dump(hours, threshold); 306 return mUidm.dump(hours, threshold, force_report);
307 } 307 }
308 void update_uid_io_interval(int interval) { 308 void update_uid_io_interval(int interval) {
309 if (interval >= DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO_LIMIT) { 309 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:
91 // called by storaged -u 91 // called by storaged -u
92 std::unordered_map<uint32_t, struct uid_info> get_uid_io_stats(); 92 std::unordered_map<uint32_t, struct uid_info> get_uid_io_stats();
93 // called by dumpsys 93 // called by dumpsys
94 std::map<uint64_t, std::vector<struct uid_record>> dump(int hours, uint64_t threshold); 94 std::map<uint64_t, std::vector<struct uid_record>> dump(
95 int hours, uint64_t threshold, bool force_report);
95 // called by battery properties listener 96 // called by battery properties listener
96 void set_charger_state(charger_stat_t stat); 97 void set_charger_state(charger_stat_t stat);
97 // called by storaged periodic_chore 98 // called by storaged periodic_chore or dump with force_report
98 void report(); 99 void report();
99}; 100};
100 101
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<String16>& args) {
91 int hours = 0; 91 int hours = 0;
92 int time_window = 0; 92 int time_window = 0;
93 uint64_t threshold = 0; 93 uint64_t threshold = 0;
94 bool force_report = false;
94 for (size_t i = 0; i < args.size(); i++) { 95 for (size_t i = 0; i < args.size(); i++) {
95 const auto& arg = args[i]; 96 const auto& arg = args[i];
96 if (arg == String16("--hours")) { 97 if (arg == String16("--hours")) {
@@ -111,10 +112,14 @@ status_t Storaged::dump(int fd, const Vector<String16>& args) {
111 threshold = stoll(String16::std_string(args[i])); 112 threshold = stoll(String16::std_string(args[i]));
112 continue; 113 continue;
113 } 114 }
115 if (arg == String16("--force")) {
116 force_report = true;
117 continue;
118 }
114 } 119 }
115 120
116 const std::map<uint64_t, std::vector<struct uid_record>>& records = 121 const std::map<uint64_t, std::vector<struct uid_record>>& records =
117 storaged.get_uid_records(hours, threshold); 122 storaged.get_uid_records(hours, threshold, force_report);
118 for (const auto& it : records) { 123 for (const auto& it : records) {
119 dprintf(fd, "%llu\n", (unsigned long long)it.first); 124 dprintf(fd, "%llu\n", (unsigned long long)it.first);
120 for (const auto& record : it.second) { 125 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)
150} 150}
151 151
152std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump( 152std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump(
153 int hours, uint64_t threshold) 153 int hours, uint64_t threshold, bool force_report)
154{ 154{
155 if (force_report) {
156 report();
157 }
158
155 std::unique_ptr<lock_t> lock(new lock_t(&um_lock)); 159 std::unique_ptr<lock_t> lock(new lock_t(&um_lock));
156 160
157 std::map<uint64_t, std::vector<struct uid_record>> dump_records; 161 std::map<uint64_t, std::vector<struct uid_record>> dump_records;