Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167021454
D42942.id131102.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D42942.id131102.diff
View Options
diff --git a/sys/kern/kern_ffclock.c b/sys/kern/kern_ffclock.c
--- a/sys/kern/kern_ffclock.c
+++ b/sys/kern/kern_ffclock.c
@@ -51,7 +51,6 @@
FEATURE(ffclock, "Feedforward clock support");
extern struct ffclock_estimate ffclock_estimate;
-extern struct bintime ffclock_boottime;
extern int8_t ffclock_updated;
extern struct mtx ffclock_mtx;
@@ -62,7 +61,7 @@
* into account). If valid pointers are provided, the ffcounter value and an
* upper bound on clock error associated with the bintime are provided.
* The DIFF and MONO flags determining FFclock type are processed within
- * ffclock_last_tick and ffclock_read_counter.
+ * ffclock_last_tick and ffclock_read_counter, as is the UPTIME flag.
* Note that here ffclock_convert_abs() is used to read the FFclock `now', but
* the resulting timestamp corresponds to the event timestamped by the raw
* ffcounter read made earlier - this is a feature!
@@ -101,11 +100,6 @@
bt->sec -= cest.leapsec_next;
}
- /* Uptime clock case, obtain from UTC via boottime UTC timestamp. */
- if ((flags & FFCLOCK_UPTIME) == FFCLOCK_UPTIME) {
- bintime_sub(bt, &ffclock_boottime);
- }
-
/* Compute error bound if a valid pointer has been passed. */
if (error_bound) {
ffdelta_error = ffc - cest.update_ffcount;
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -519,16 +519,16 @@
/* Feedforward clock estimates kept updated by the synchronization daemon. */
struct ffclock_estimate ffclock_estimate;
-struct bintime ffclock_boottime; /* feedforward boot time estimate. */
uint32_t ffclock_status; /* feedforward clock status. */
int8_t ffclock_updated; /* New estimates are available. */
struct mtx ffclock_mtx; /* Mutex on ffclock_estimate. */
struct fftimehands {
- struct ffclock_estimate cest; /* natFFC data */
- struct bintime tick_time; /* natFFC */
- struct bintime tick_time_mono; /* monoFFC */
- struct bintime tick_time_diff; /* diffFFC */
+ struct ffclock_estimate cest; /* natFFC daemon data */
+ struct bintime tick_time; /* natFFC */
+ struct bintime tick_time_mono; /* monoFFC */
+ struct bintime tick_time_diff; /* diffFFC */
+ struct bintime ffclock_boottime; /* UTC timestamp of boot */
struct bintime tick_error;
ffcounter tick_ffcount;
uint64_t period_mono;
@@ -556,7 +556,6 @@
ffclock_updated = 0;
ffclock_status = FFCLOCK_STA_UNSYNC;
- ffclock_boottime.sec = ffclock_boottime.frac = 0;
mtx_init(&ffclock_mtx, "ffclock lock", NULL, MTX_SPIN);
}
@@ -643,7 +642,7 @@
* = FF : ensure cont'y in FF and hence sysclock Uptime
*/
if (sysclock_active == SYSCLOCK_FB)
- ffclock_boottime = *reset_FBbootime;
+ ffth->ffclock_boottime = *reset_FBbootime;
else {
/* First calculate what monoFFC would have been. */
ffth->tick_time_mono = fftimehands->tick_time_mono;
@@ -655,11 +654,11 @@
if (bintime_cmp(reset_UTC, &ffth->tick_time_mono, >)) {
gap = *reset_UTC;
bintime_sub(&gap, &ffth->tick_time_mono);
- bintime_add(&ffclock_boottime, &gap);
+ bintime_add(&ffth->ffclock_boottime, &gap);
} else {
gap = ffth->tick_time_mono;
bintime_sub(&gap, reset_UTC);
- bintime_sub(&ffclock_boottime, &gap);
+ bintime_sub(&ffth->ffclock_boottime, &gap);
}
}
@@ -694,17 +693,18 @@
ffth->period_mono = cest->period;
upt = ffth->tick_time_mono;
- bintime_sub(&upt, &ffclock_boottime);
+ bintime_sub(&upt, &ffth->ffclock_boottime);
printf("FFclock processing RTC reset: UTC: %lld.%03u"
" boottime: %llu.%03u, uptime: %llu.%03u\n",
(long long)ffth->tick_time_mono.sec,
(unsigned int)(ffth->tick_time_mono.frac / MS_AS_BINFRAC),
- (unsigned long long)ffclock_boottime.sec,
- (unsigned int)(ffclock_boottime.frac / MS_AS_BINFRAC),
+ (unsigned long long)ffth->ffclock_boottime.sec,
+ (unsigned int)(ffth->ffclock_boottime.frac / MS_AS_BINFRAC),
(unsigned long long)upt.sec,
(unsigned int)(upt.frac / MS_AS_BINFRAC) );
- }
+ } else
+ ffth->ffclock_boottime = fftimehands->ffclock_boottime;
/*
* Signal to ignore a stale daemon update following a RTC reset.
@@ -816,17 +816,17 @@
&& ((cest->status & FFCLOCK_STA_UNSYNC) == 0) ) {
if (forward_jump) {
printf("ffwindup: forward");
- bintime_add(&ffclock_boottime, &gap);
+ bintime_add(&ffth->ffclock_boottime, &gap);
} else {
printf("ffwindup: backward");
- bintime_sub(&ffclock_boottime, &gap);
+ bintime_sub(&ffth->ffclock_boottime, &gap);
}
printf(" jump for monoFFclock of %llu.%03u",
(unsigned long long)gap.sec,
(unsigned int)(gap.frac / MS_AS_BINFRAC) );
upt = ffth->tick_time_mono;
- bintime_sub(&upt, &ffclock_boottime);
+ bintime_sub(&upt, &ffth->ffclock_boottime);
printf(" (uptime preserved at: %llu.%03u)\n",
(unsigned long long)upt.sec,
(unsigned int)(upt.frac / MS_AS_BINFRAC) );
@@ -988,6 +988,11 @@
else
*bt = ffth->tick_time;
*ffcount = ffth->tick_ffcount;
+
+ /* Uptime clock case, obtain from UTC via boottime timestamp. */
+ if ((flags & FFCLOCK_UPTIME) == FFCLOCK_UPTIME)
+ bintime_sub(bt, &ffth->ffclock_boottime);
+
} while (gen == 0 || gen != ffth->gen);
}
@@ -1029,6 +1034,11 @@
bintime_add(bt, &bt2);
else
bintime_sub(bt, &bt2);
+
+ /* Uptime clock case, obtain from UTC via boottime timestamp. */
+ if ((flags & FFCLOCK_UPTIME) == FFCLOCK_UPTIME)
+ bintime_sub(bt, &ffth->ffclock_boottime);
+
} while (gen == 0 || gen != ffth->gen);
}
@@ -1249,6 +1259,7 @@
ffi->tick_time = ffth->tick_time;
ffi->tick_time_diff = ffth->tick_time_diff;
ffi->tick_time_mono = ffth->tick_time_mono;
+ ffi->ffclock_boottime = ffth->ffclock_boottime;
ffi->period = ffth->cest.period;
ffi->period_mono = ffth->period_mono;
clock_snap->ffcount = ffth->tick_ffcount;
@@ -1346,7 +1357,7 @@
/* Add appropriate const for Uptime, UTC, or diffFFC clock. */
if (flags & FFCLOCK_UPTIME)
- bintime_sub(bt, &ffclock_boottime);
+ bintime_sub(bt, &cs->ff_info.ffclock_boottime);
else // UTC
if (!(flags & FFCLOCK_DIFF) || flags & FFCLOCK_MONO)
bt->sec -= cs->ff_info.leapsec_adjustment;
diff --git a/sys/sys/timeffc.h b/sys/sys/timeffc.h
--- a/sys/sys/timeffc.h
+++ b/sys/sys/timeffc.h
@@ -143,6 +143,7 @@
struct bintime tick_time;
struct bintime tick_time_mono;
struct bintime tick_time_diff;
+ struct bintime ffclock_boottime;
uint64_t period;
uint64_t period_mono;
int leapsec_adjustment;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 3:27 PM (11 h, 27 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36941770
Default Alt Text
D42942.id131102.diff (6 KB)
Attached To
Mode
D42942: FFclock: Making the FFclock's boottime parameter tick-safe
Attached
Detach File
Event Timeline
Log In to Comment