Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Unified Diff: ui/ozone/platform/drm/host/drm_device_handle.cc

Issue 2226163005: Suppress "Failed to authenticate /dev/dri/card0" log spam. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/drm/host/drm_device_handle.cc
diff --git a/ui/ozone/platform/drm/host/drm_device_handle.cc b/ui/ozone/platform/drm/host/drm_device_handle.cc
index 40f62f1bd45c0371f693565232683daf8d36bd9a..26db60995f29201e000de5eb61f06d684ca1b54d 100644
--- a/ui/ozone/platform/drm/host/drm_device_handle.cc
+++ b/ui/ozone/platform/drm/host/drm_device_handle.cc
@@ -12,11 +12,18 @@
#include "base/files/file_path.h"
#include "base/posix/eintr_wrapper.h"
#include "base/threading/thread_restrictions.h"
+#include "base/time/time.h"
namespace ui {
namespace {
+// Sleep this many milliseconds before retrying after authentication fails.
+const int kAuthFailSleepMs = 100;
+
+// Log a warning after failing to authenticate for this many milliseconds.
+const int kLogAuthFailDelayMs = 1000;
+
bool Authenticate(int fd) {
drm_magic_t magic;
memset(&magic, 0, sizeof(magic));
@@ -42,7 +49,10 @@ bool DrmDeviceHandle::Initialize(const base::FilePath& dev_path,
// used a label and is otherwise unvalidated.
CHECK(dev_path.DirName() == base::FilePath("/dev/dri"));
base::ThreadRestrictions::AssertIOAllowed();
- bool print_warning = true;
+
+ int num_auth_attempts = 0;
+ bool logged_warning = false;
+ const base::TimeTicks start_time = base::TimeTicks::Now();
while (true) {
file_.reset();
int fd = HANDLE_EINTR(open(dev_path.value().c_str(), O_RDWR | O_CLOEXEC));
@@ -54,16 +64,25 @@ bool DrmDeviceHandle::Initialize(const base::FilePath& dev_path,
file_.reset(fd);
sys_path_ = sys_path;
+ num_auth_attempts++;
if (Authenticate(file_.get()))
break;
- LOG_IF(WARNING, print_warning) << "Failed to authenticate "
- << dev_path.value();
- print_warning = false;
- usleep(100000);
+ // To avoid spamming the logs, hold off before logging a warning (some
+ // failures are expected at first) and only log a single message.
+ if (!logged_warning &&
+ (base::TimeTicks::Now() - start_time).InMilliseconds() >=
+ kLogAuthFailDelayMs) {
+ LOG(WARNING) << "Failed to authenticate " << dev_path.value()
+ << " within " << kLogAuthFailDelayMs << " ms";
+ logged_warning = true;
+ }
+ usleep(kAuthFailSleepMs * 1000);
}
- VLOG(1) << "Succeeded authenticating " << dev_path.value();
+ VLOG(1) << "Succeeded authenticating " << dev_path.value() << " in "
+ << (base::TimeTicks::Now() - start_time).InMilliseconds() << " ms "
+ << "with " << num_auth_attempts << " attempt(s)";
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698