summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorWei Wang <wvw@google.com>2018-06-08 00:34:44 -0700
committerWei Wang <wvw@google.com>2018-06-13 11:02:13 -0700
commitfdafb3d0ec67b40894ce0dd597d3142cc98ab943 (patch)
tree59c060a0a2f785b8997b494e5d32dc32c2870089 /init
parent7222199281b824fbe08f216860d2cd5153d33d11 (diff)
downloadsystem_core-fdafb3d0ec67b40894ce0dd597d3142cc98ab943.tar.gz
system_core-fdafb3d0ec67b40894ce0dd597d3142cc98ab943.tar.bz2
system_core-fdafb3d0ec67b40894ce0dd597d3142cc98ab943.zip
init: Add warning in init first stage mount
init need find required devices and it some times takes a long time due to rogue drivers. Add a warning if the timing is longer than 50ms. Bug: 80494921 Test: Reboot Change-Id: I8f937d7ca7127dc89ed76bb6e5f1781459d5c94a
Diffstat (limited to 'init')
-rw-r--r--init/uevent_listener.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/init/uevent_listener.cpp b/init/uevent_listener.cpp
index 24b14c44d..81486e108 100644
--- a/init/uevent_listener.cpp
+++ b/init/uevent_listener.cpp
@@ -23,7 +23,11 @@
#include <memory>
+#include <android-base/chrono_utils.h>
+#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/scopeguard.h>
+#include <android-base/stringprintf.h>
#include <cutils/uevent.h>
namespace android {
@@ -130,9 +134,19 @@ ListenerAction UeventListener::RegenerateUeventsForDir(DIR* d,
int fd = openat(dfd, "uevent", O_WRONLY);
if (fd >= 0) {
+ android::base::Timer t;
write(fd, "add\n", 4);
+ const std::string fd_path = android::base::StringPrintf("/proc/self/fd/%d", fd);
+ std::string uevent_file_path;
+ android::base::Readlink(fd_path, &uevent_file_path);
close(fd);
+ auto guard = android::base::make_scope_guard([&t, &uevent_file_path]() {
+ if (t.duration() > 50ms) {
+ LOG(WARNING) << "ReadUevent took " << t << " on '" << uevent_file_path << "'";
+ }
+ });
+
Uevent uevent;
while (ReadUevent(&uevent)) {
if (callback(uevent) == ListenerAction::kStop) return ListenerAction::kStop;