diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-01-26 01:56:32 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-01-26 01:56:32 +0000 |
| commit | a867efaed83fb3dab038e3fbe0cf608407678cb0 (patch) | |
| tree | 99180d963dcc9729ddadb8c608a45a510b34d949 /storaged/storaged.cpp | |
| parent | 314bb2faf2afb763b68b3c74577a40c2c70f8276 (diff) | |
| parent | 88ad33eff1fd70d276f9be70164afeb0dc639e58 (diff) | |
| download | system_core-a867efaed83fb3dab038e3fbe0cf608407678cb0.tar.gz system_core-a867efaed83fb3dab038e3fbe0cf608407678cb0.tar.bz2 system_core-a867efaed83fb3dab038e3fbe0cf608407678cb0.zip | |
Merge changes Id0599ee2,I01f64c84
* changes:
storaged: remove task io code
storaged: replace cmd arguments with properties
Diffstat (limited to 'storaged/storaged.cpp')
| -rw-r--r-- | storaged/storaged.cpp | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/storaged/storaged.cpp b/storaged/storaged.cpp index 0c53f4482..d3fa2b97d 100644 --- a/storaged/storaged.cpp +++ b/storaged/storaged.cpp @@ -21,6 +21,7 @@ #include <unistd.h> #include <android-base/logging.h> +#include <cutils/properties.h> #include <storaged.h> #include <storaged_utils.h> @@ -165,21 +166,23 @@ storaged_t::storaged_t(void) { mConfig.diskstats_available = true; } - mConfig.proc_taskio_readable = true; - const char* test_paths[] = {"/proc/1/io", "/proc/1/comm", "/proc/1/cmdline", "/proc/1/stat"}; - for (uint i = 0; i < sizeof(test_paths) / sizeof(const char*); ++i) { - if (access(test_paths[i], R_OK) < 0) { - mConfig.proc_taskio_readable = false; - break; - } - } - mConfig.proc_uid_io_available = (access(UID_IO_STATS_PATH, R_OK) == 0); - mConfig.periodic_chores_interval_unit = DEFAULT_PERIODIC_CHORES_INTERVAL_UNIT; - mConfig.periodic_chores_interval_disk_stats_publish = DEFAULT_PERIODIC_CHORES_INTERVAL_DISK_STATS_PUBLISH; - mConfig.periodic_chores_interval_emmc_info_publish = DEFAULT_PERIODIC_CHORES_INTERVAL_EMMC_INFO_PUBLISH; - mUidm.set_periodic_chores_interval(DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO_ALERT); + mConfig.periodic_chores_interval_unit = + property_get_int32("ro.storaged.event.interval", DEFAULT_PERIODIC_CHORES_INTERVAL_UNIT); + + mConfig.event_time_check_usec = + property_get_int32("ro.storaged.event.perf_check", 0); + + mConfig.periodic_chores_interval_disk_stats_publish = + property_get_int32("ro.storaged.disk_stats_pub", DEFAULT_PERIODIC_CHORES_INTERVAL_DISK_STATS_PUBLISH); + + mConfig.periodic_chores_interval_emmc_info_publish = + property_get_int32("ro.storaged.emmc_info_pub", DEFAULT_PERIODIC_CHORES_INTERVAL_EMMC_INFO_PUBLISH); + + mUidm.set_periodic_chores_params( + property_get_int32("ro.storaged.uid_io.interval", DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO), + property_get_int32("ro.storaged.uid_io.threshold", DEFAULT_PERIODIC_CHORES_UID_IO_THRESHOLD)); mStarttime = time(NULL); } @@ -193,12 +196,6 @@ void storaged_t::event(void) { } } -#ifdef DEBUG - if (mConfig.proc_taskio_readable) { - mTasks.update_running_tasks(); - } -#endif - if (mConfig.emmc_available && mTimer && (mTimer % mConfig.periodic_chores_interval_emmc_info_publish) == 0) { mEmmcInfo.update(); @@ -212,3 +209,30 @@ void storaged_t::event(void) { mTimer += mConfig.periodic_chores_interval_unit; } + +void storaged_t::event_checked(void) { + struct timespec start_ts, end_ts; + bool check_time = true; + + if (mConfig.event_time_check_usec && + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start_ts) < 0) { + check_time = false; + PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed"; + } + + event(); + + if (mConfig.event_time_check_usec) { + if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end_ts) < 0) { + PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed"; + return; + } + int64_t cost = (end_ts.tv_sec - start_ts.tv_sec) * SEC_TO_USEC + + (end_ts.tv_nsec - start_ts.tv_nsec) / USEC_TO_NSEC; + if (cost > mConfig.event_time_check_usec) { + LOG_TO(SYSTEM, ERROR) + << "event loop spent " << cost << " usec, threshold " + << mConfig.event_time_check_usec << " usec"; + } + } +} |
