Skip to content

Commit 1bcfeaf

Browse files
committed
DO NOT MERGE: common_time: Turn the logging up to 11
Actually, despite the CL title, no addition log messages are being sent to logcat. Generally speaking, the common_time service tends to be rather quiet from a log perspective. Events related to master election and arbitration as well as state changes tend to be infrequent in steady state operation. Unfortunately, if there is a problem with the system, it frequently gets pushed out of logcat by other messages and is missing from the logs when a bugreport is finally taken. This change adds a utility class which can be used to store the last N log message in a ring buffer to be dumped later during a dumpsys operation. Three internal log buffers were added to the system. One to record messages having to do with state transitions. Another was added to record traffic relating to master election, and one final buffer to record basic data on packets which were received but discarded for any reason. During a bugreport, these common_time.clock service will be able to dump these messages regardless of the amt of other logcat activity, which should assist in debugging long running issues. Change-Id: Ic3bbf7480c8978f9bf82bafaba04cf4586db60cf Signed-off-by: John Grossman <johngro@google.com>
1 parent c43a685 commit 1bcfeaf

File tree

7 files changed

+318
-46
lines changed

7 files changed

+318
-46
lines changed

services/common_time/clock_recovery.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ bool ClockRecoveryLoop::pushDisciplineEvent(int64_t local_time,
225225
if (current_point == min_rtt || rtt < control_thresh_) {
226226
delta_f = delta = nominal_common_time - observed_common;
227227

228+
last_error_est_valid_ = true;
229+
last_error_est_usec_ = delta;
230+
228231
// Compute the error then clamp to the panic threshold. If we ever
229232
// exceed this amt of error, its time to panic and reset the system.
230233
// Given that the error in the measurement of the error could be as
@@ -258,7 +261,6 @@ bool ClockRecoveryLoop::pushDisciplineEvent(int64_t local_time,
258261

259262
// Save error terms for later.
260263
last_delta_f_ = delta_f;
261-
last_delta_ = delta;
262264

263265
// Clamp CO to +/- 100ppm.
264266
if (CO < COmin)
@@ -295,8 +297,8 @@ bool ClockRecoveryLoop::pushDisciplineEvent(int64_t local_time,
295297
int32_t ClockRecoveryLoop::getLastErrorEstimate() {
296298
Mutex::Autolock lock(&lock_);
297299

298-
if (last_delta_valid_)
299-
return last_delta_;
300+
if (last_error_est_valid_)
301+
return last_error_est_usec_;
300302
else
301303
return ICommonClock::kErrorEstimateUnknown;
302304
}
@@ -310,8 +312,8 @@ void ClockRecoveryLoop::reset_l(bool position, bool frequency) {
310312
}
311313

312314
if (frequency) {
313-
last_delta_valid_ = false;
314-
last_delta_ = 0;
315+
last_error_est_valid_ = false;
316+
last_error_est_usec_ = 0;
315317
last_delta_f_ = 0.0;
316318
CO = 0.0f;
317319
lastCObias = CObias = 0.0f;

services/common_time/clock_recovery.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ class ClockRecoveryLoop {
108108

109109
// parameters maintained while running and reset during a reset
110110
// of the frequency correction.
111-
bool last_delta_valid_;
112-
int32_t last_delta_;
111+
bool last_error_est_valid_;
112+
int32_t last_error_est_usec_;
113113
float last_delta_f_;
114114
int32_t integrated_error_;
115115
int32_t tgt_correction_;

0 commit comments

Comments
 (0)