summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Qian2017-02-16 20:34:31 -0600
committerJin Qian2017-02-16 20:46:41 -0600
commitbaff640d5d0a1abd95458f08017fe0e8babb8103 (patch)
tree469866b12bb91b6fdc1cb4994cefc67b532a3045 /storaged
parentcee1918b088d1df7e6875e495c985c2704c0ef2d (diff)
downloadplatform-system-core-baff640d5d0a1abd95458f08017fe0e8babb8103.tar.gz
platform-system-core-baff640d5d0a1abd95458f08017fe0e8babb8103.tar.xz
platform-system-core-baff640d5d0a1abd95458f08017fe0e8babb8103.zip
storaged: handle negative delta in io usage
When UID is uninstalled and reinstalled, IO usage of the UID is reset. This caused problem in accounting since it assumes IO usage is always increasing for the same UID. In such case, use the current usage instead of negative delta for accounting. Bug: 34198239 Change-Id: I74661feccc05d19ba8a0feff8a2e38d72c7d1465
Diffstat (limited to 'storaged')
-rw-r--r--storaged/storaged_uid_monitor.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/storaged/storaged_uid_monitor.cpp b/storaged/storaged_uid_monitor.cpp
index 3b893b506..49d0d4861 100644
--- a/storaged/storaged_uid_monitor.cpp
+++ b/storaged/storaged_uid_monitor.cpp
@@ -204,18 +204,23 @@ void uid_monitor::update_curr_io_stats_locked()
204 } 204 }
205 205
206 struct uid_io_usage& usage = curr_io_stats[uid.name]; 206 struct uid_io_usage& usage = curr_io_stats[uid.name];
207 usage.bytes[READ][FOREGROUND][charger_stat] += 207 int64_t fg_rd_delta = uid.io[FOREGROUND].read_bytes -
208 uid.io[FOREGROUND].read_bytes -
209 last_uid_io_stats[uid.uid].io[FOREGROUND].read_bytes; 208 last_uid_io_stats[uid.uid].io[FOREGROUND].read_bytes;
210 usage.bytes[READ][BACKGROUND][charger_stat] += 209 int64_t bg_rd_delta = uid.io[BACKGROUND].read_bytes -
211 uid.io[BACKGROUND].read_bytes -
212 last_uid_io_stats[uid.uid].io[BACKGROUND].read_bytes; 210 last_uid_io_stats[uid.uid].io[BACKGROUND].read_bytes;
213 usage.bytes[WRITE][FOREGROUND][charger_stat] += 211 int64_t fg_wr_delta = uid.io[FOREGROUND].write_bytes -
214 uid.io[FOREGROUND].write_bytes -
215 last_uid_io_stats[uid.uid].io[FOREGROUND].write_bytes; 212 last_uid_io_stats[uid.uid].io[FOREGROUND].write_bytes;
213 int64_t bg_wr_delta = uid.io[BACKGROUND].write_bytes -
214 last_uid_io_stats[uid.uid].io[BACKGROUND].write_bytes;
215
216 usage.bytes[READ][FOREGROUND][charger_stat] +=
217 (fg_rd_delta < 0) ? uid.io[FOREGROUND].read_bytes : fg_rd_delta;
218 usage.bytes[READ][BACKGROUND][charger_stat] +=
219 (bg_rd_delta < 0) ? uid.io[BACKGROUND].read_bytes : bg_rd_delta;
220 usage.bytes[WRITE][FOREGROUND][charger_stat] +=
221 (fg_wr_delta < 0) ? uid.io[FOREGROUND].write_bytes : fg_wr_delta;
216 usage.bytes[WRITE][BACKGROUND][charger_stat] += 222 usage.bytes[WRITE][BACKGROUND][charger_stat] +=
217 uid.io[BACKGROUND].write_bytes - 223 (bg_wr_delta < 0) ? uid.io[BACKGROUND].write_bytes : bg_wr_delta;
218 last_uid_io_stats[uid.uid].io[BACKGROUND].write_bytes;;
219 } 224 }
220 225
221 last_uid_io_stats = uid_io_stats; 226 last_uid_io_stats = uid_io_stats;