From 959ea63b30d927103f00743308caf558a6ba9e63 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Thu, 10 Dec 2020 07:34:29 -0800 Subject: [PATCH] init: remove DumpShutdownDebugInformation() This hasn't helped investigating the issue, and the issue itself isn't a problem anymore, so we remove these logs. Bug: 155203339 Test: reboot Change-Id: I20e51d8fcad5572906a8d556bec8a8dee4522834 --- init/init.cpp | 4 +--- init/util.cpp | 47 ----------------------------------------------- init/util.h | 2 -- 3 files changed, 1 insertion(+), 52 deletions(-) diff --git a/init/init.cpp b/init/init.cpp index 1d0a9dca7..d1998a5c7 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -266,12 +266,10 @@ void DebugRebootLogging() { if (shutdown_state.do_shutdown()) { LOG(ERROR) << "sys.powerctl set while a previous shutdown command has not been handled"; UnwindMainThreadStack(); - DumpShutdownDebugInformation(); } if (IsShuttingDown()) { LOG(ERROR) << "sys.powerctl set while init is already shutting down"; UnwindMainThreadStack(); - DumpShutdownDebugInformation(); } } @@ -760,7 +758,7 @@ int SecondStageMain(int argc, char** argv) { trigger_shutdown = [](const std::string& command) { shutdown_state.TriggerShutdown(command); }; SetStdioToDevNull(argv); - InitSecondStageLogging(argv); + InitKernelLogging(argv); LOG(INFO) << "init second stage started!"; // Update $PATH in the case the second stage init is newer than first stage init, where it is diff --git a/init/util.cpp b/init/util.cpp index aec3173d3..255434a1b 100644 --- a/init/util.cpp +++ b/init/util.cpp @@ -30,9 +30,7 @@ #include #include -#include #include -#include #include #include @@ -724,50 +722,5 @@ bool IsRecoveryMode() { return access("/system/bin/recovery", F_OK) == 0; } -// TODO(b/155203339): remove this -// Devices in the lab seem to be stuck during shutdown, but the logs don't capture the last actions -// before shutdown started, so we record those lines, ignoring requests to shutdown, and replay them -// if we identify that the device is stuck. -constexpr size_t kRecordedLogsSize = 30; -std::string recorded_logs[kRecordedLogsSize]; -size_t recorded_log_position = 0; -std::mutex recorded_logs_lock; - -void InitSecondStageLogging(char** argv) { - SetFatalRebootTarget(); - auto second_stage_logger = [](android::base::LogId log_id, android::base::LogSeverity severity, - const char* tag, const char* file, unsigned int line, - const char* message) { - // We only store logs for init, not its children, and only if they're not related to - // sys.powerctl. - if (getpid() == 1 && strstr(message, "sys.powerctl") == nullptr) { - auto lock = std::lock_guard{recorded_logs_lock}; - recorded_logs[recorded_log_position++] = message; - if (recorded_log_position == kRecordedLogsSize) { - recorded_log_position = 0; - } - } - android::base::KernelLogger(log_id, severity, tag, file, line, message); - }; - android::base::InitLogging(argv, second_stage_logger, InitAborter); -} - -void DumpShutdownDebugInformation() { - auto lock = std::lock_guard{recorded_logs_lock}; - android::base::KernelLogger( - android::base::MAIN, android::base::ERROR, "init", nullptr, 0, - "===================== Dumping previous init lines ====================="); - for (size_t i = recorded_log_position; i < kRecordedLogsSize; ++i) { - android::base::KernelLogger(android::base::MAIN, android::base::ERROR, "init", nullptr, 0, - recorded_logs[i].c_str()); - } - for (size_t i = 0; i < recorded_log_position; ++i) { - android::base::KernelLogger(android::base::MAIN, android::base::ERROR, "init", nullptr, 0, - recorded_logs[i].c_str()); - } - android::base::KernelLogger(android::base::MAIN, android::base::ERROR, "init", nullptr, 0, - "===================== End of dump ====================="); -} - } // namespace init } // namespace android diff --git a/init/util.h b/init/util.h index 8a6aa6053..3cdc9f408 100644 --- a/init/util.h +++ b/init/util.h @@ -98,8 +98,6 @@ Result ParseUmountAll(const std::vector& args); void SetStdioToDevNull(char** argv); void InitKernelLogging(char** argv); -void InitSecondStageLogging(char** argv); -void DumpShutdownDebugInformation(); bool IsRecoveryMode(); } // namespace init } // namespace android