Commit 79bbea09 authored by Peter McNeeley's avatar Peter McNeeley Committed by Chromium LUCI CQ

Minor error logging throttle

When the path for the accelerometer "/dev/cros-ec-accel/" is
inaccessible this error reporting will spam the log many times per
second. Here we simply add a backoff to throttle how often this logging
will occur.

The reason for the inaccessibility of this path is likely due to
incorrect group setting.

Some dev-only specific changes may be required to the file below in
order to apply these group settings in a dev/debug specific context.

https://source.corp.google.com/chromeos_public/src/third_party/
chromiumos-overlay/chromeos-base/chromeos-accelerometer-init/
files/udev/99-cros-ec-accel.rules?q=mems_setup&ss=
piper%2FGoogle%2Fchromeos_public:src%2F&start=31


Change-Id: I12ad7d27e5710c86292ca08dee0f5680a2ddb153
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2563700Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Peter McNeeley <petermcneeley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831936}
parent 0e85cb67
...@@ -551,9 +551,18 @@ void AccelerometerFileReader::ReadFileAndNotify() { ...@@ -551,9 +551,18 @@ void AccelerometerFileReader::ReadFileAndNotify() {
char reading[reading_size]; char reading[reading_size];
int bytes_read = base::ReadFile(reading_data.path, reading, reading_size); int bytes_read = base::ReadFile(reading_data.path, reading, reading_size);
if (bytes_read < reading_size) { if (bytes_read < reading_size) {
LOG(ERROR) << "Accelerometer Read " << bytes_read << " byte(s), expected " // Dynamically throttle error logging as this can be called many times
<< reading_size << " bytes from accelerometer " // every second if path is consistently inaccessible.
<< reading_data.path.MaybeAsASCII(); static uint64_t sLogCount = 1U;
static uint64_t sLogThrottle = 1U;
if ((sLogCount ^ sLogThrottle) == 0) {
LOG(ERROR) << "Accelerometer Read " << bytes_read
<< " byte(s), expected " << reading_size
<< " bytes from accelerometer "
<< reading_data.path.MaybeAsASCII();
sLogThrottle *= 2U;
}
sLogCount++;
return; return;
} }
for (AccelerometerSource source : reading_data.sources) { for (AccelerometerSource source : reading_data.sources) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment