diff options
author | phk <phk@FreeBSD.org> | 2003-11-13 10:03:58 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-11-13 10:03:58 +0000 |
commit | c92feb226d0a91bfda8388718857694c757f6c9a (patch) | |
tree | 64342133cf3fc0a69c799fcb311b280ead170848 /sys/kern/kern_tc.c | |
parent | 4c623367dfdcb425ddccf07630ea649fe6c14a4a (diff) | |
download | FreeBSD-src-c92feb226d0a91bfda8388718857694c757f6c9a.zip FreeBSD-src-c92feb226d0a91bfda8388718857694c757f6c9a.tar.gz |
Various minor details:
Give the HZ/overflow check a 10% margin.
Eliminate bogus newline.
If timecounters have equal quality, prefer higher frequency.
Some inspiration from: bde
Diffstat (limited to 'sys/kern/kern_tc.c')
-rw-r--r-- | sys/kern/kern_tc.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 1984d56..accd372 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -286,32 +286,41 @@ getmicrotime(struct timeval *tvp) void tc_init(struct timecounter *tc) { - unsigned u; + u_int u; u = tc->tc_frequency / tc->tc_counter_mask; + /* XXX: We need some margin here, 10% is a guess */ + u *= 11; + u /= 10; if (u > hz && tc->tc_quality >= 0) { tc->tc_quality = -2000; if (bootverbose) { printf("Timecounter \"%s\" frequency %ju Hz", - tc->tc_name, (intmax_t)tc->tc_frequency); + tc->tc_name, (uintmax_t)tc->tc_frequency); printf(" -- Insufficient hz, needs at least %u\n", u); } } else if (tc->tc_quality >= 0 || bootverbose) { - printf("Timecounter \"%s\" frequency %ju Hz quality %d", - tc->tc_name, (intmax_t)tc->tc_frequency, + printf("Timecounter \"%s\" frequency %ju Hz quality %d\n", + tc->tc_name, (uintmax_t)tc->tc_frequency, tc->tc_quality); } - printf("\n"); tc->tc_next = timecounters; timecounters = tc; - (void)tc->tc_get_timecount(tc); - (void)tc->tc_get_timecount(tc); - /* Never automatically use a timecounter with negative quality */ + /* + * Never automatically use a timecounter with negative quality. + * Even though we run on the dummy counter, switching here may be + * worse since this timecounter may not be monotonous. + */ if (tc->tc_quality < 0) return; if (tc->tc_quality < timecounter->tc_quality) return; + if (tc->tc_quality == timecounter->tc_quality && + tc->tc_frequency < timecounter->tc_frequency) + return; + (void)tc->tc_get_timecount(tc); + (void)tc->tc_get_timecount(tc); timecounter = tc; } |