diff options
| author | 2020-10-21 12:04:33 +0000 | |
|---|---|---|
| committer | 2020-10-21 12:04:33 +0000 | |
| commit | 0c88b54c2d3d5d20c74dd8db6fc031646ef5d4da (patch) | |
| tree | bd42cf68bd0e9249c32f07a0e89fb8e521ad9ce9 | |
| parent | 55f771a602ecc9be08d7a1b7632b882adadfecb0 (diff) | |
| parent | a5de575226f3f65c9e8cbdfe9e87e2a528da3d48 (diff) | |
Faster bugreports (6/n) am: a5de575226
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1441347
Change-Id: Id94870207bf6610a9731a458b67878515071583a
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 3773af7e82..331b10a499 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -1853,32 +1853,39 @@ Dumpstate::RunStatus Dumpstate::DumpstateDefaultAfterCritical() { return status; } +// Common states for telephony and wifi which are needed to be collected before +// dumpstate drop the root user. +static void DumpstateRadioAsRoot() { + DumpIpTablesAsRoot(); + ds.AddDir(LOGPERSIST_DATA_DIR, false); +} + // This method collects common dumpsys for telephony and wifi. Typically, wifi // reports are fine to include all information, but telephony reports on user // builds need to strip some content (see DumpstateTelephonyOnly). static void DumpstateRadioCommon(bool include_sensitive_info = true) { - DumpIpTablesAsRoot(); - - ds.AddDir(LOGPERSIST_DATA_DIR, false); - - if (!DropRootUser()) { - return; - } - // We need to be picky about some stuff for telephony reports on user builds. if (!include_sensitive_info) { // Only dump the radio log buffer (other buffers and dumps contain too much unrelated info). DoRadioLogcat(); } else { + // DumpHals takes long time, post it to the another thread in the pool, + // if pool is available. + if (ds.dump_pool_) { + ds.dump_pool_->enqueueTaskWithFd(DUMP_HALS_TASK, &DumpHals, _1); + } // Contains various system properties and process startup info. do_dmesg(); // Logs other than the radio buffer may contain package/component names and potential PII. DoLogcat(); // Too broad for connectivity problems. DoKmsg(); - // Contains unrelated hardware info (camera, NFC, biometrics, ...). - // TODO(b/136262402) Using thread pool for DumpHals - RUN_SLOW_FUNCTION_AND_LOG(DUMP_HALS_TASK, DumpHals); + // DumpHals contains unrelated hardware info (camera, NFC, biometrics, ...). + if (ds.dump_pool_) { + ds.dump_pool_->waitForTask(DUMP_HALS_TASK); + } else { + RUN_SLOW_FUNCTION_AND_LOG(DUMP_HALS_TASK, DumpHals); + } } DumpPacketStats(); @@ -1902,6 +1909,21 @@ static void DumpstateTelephonyOnly(const std::string& calling_package) { const bool include_sensitive_info = !PropertiesHelper::IsUserBuild(); + DumpstateRadioAsRoot(); + if (!DropRootUser()) { + return; + } + + // Starts thread pool after the root user is dropped, and two additional threads + // are created for DumpHals in the DumpstateRadioCommon and DumpstateBoard. + if (ds.dump_pool_) { + ds.dump_pool_->start(/*thread_counts =*/2); + + // DumpstateBoard takes long time, post it to the another thread in the pool, + // if pool is available. + ds.dump_pool_->enqueueTaskWithFd(DUMP_BOARD_TASK, &Dumpstate::DumpstateBoard, &ds, _1); + } + DumpstateRadioCommon(include_sensitive_info); if (include_sensitive_info) { @@ -1978,12 +2000,29 @@ static void DumpstateTelephonyOnly(const std::string& calling_package) { printf("========================================================\n"); printf("== dumpstate: done (id %d)\n", ds.id_); printf("========================================================\n"); + + if (ds.dump_pool_) { + ds.dump_pool_->waitForTask(DUMP_BOARD_TASK); + } else { + RUN_SLOW_FUNCTION_AND_LOG(DUMP_BOARD_TASK, ds.DumpstateBoard); + } } // This method collects dumpsys for wifi debugging only static void DumpstateWifiOnly() { DurationReporter duration_reporter("DUMPSTATE"); + DumpstateRadioAsRoot(); + if (!DropRootUser()) { + return; + } + + // Starts thread pool after the root user is dropped. Only one additional + // thread is needed for DumpHals in the DumpstateRadioCommon. + if (ds.dump_pool_) { + ds.dump_pool_->start(/*thread_counts =*/1); + } + DumpstateRadioCommon(); printf("========================================================\n"); @@ -2857,8 +2896,6 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package); MaybeCheckUserConsent(calling_uid, calling_package); DumpstateTelephonyOnly(calling_package); - // TODO(b/136262402) Using thread pool for DumpstateBoard - RUN_SLOW_FUNCTION_AND_LOG(DUMP_BOARD_TASK, DumpstateBoard); } else if (options_->wifi_only) { MaybeTakeEarlyScreenshot(); onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package); |