time(3): Align fast clock times to avoid firing multiple timers.
In non-periodic mode absolute timers fire at exactly the time given. When specifying a fast clock, align the firing time so that less timer interrupt events are needed. Reviewed by: rrs @ Differential Revision: https://reviews.freebsd.org/D36858 MFC after: 1 week Sponsored by: NVIDIA Networking
This commit is contained in:
parent
03d66186f6
commit
0def80f1a5
@ -706,6 +706,7 @@ umtx_abs_timeout_getsbt(struct umtx_abs_timeout *timo, sbintime_t *sbt,
|
||||
{
|
||||
struct bintime bt, bbt;
|
||||
struct timespec tts;
|
||||
sbintime_t rem;
|
||||
|
||||
switch (timo->clockid) {
|
||||
|
||||
@ -738,14 +739,24 @@ umtx_abs_timeout_getsbt(struct umtx_abs_timeout *timo, sbintime_t *sbt,
|
||||
return (0);
|
||||
}
|
||||
*sbt = bttosbt(bt);
|
||||
|
||||
/*
|
||||
* Check if the absolute time should be aligned to
|
||||
* avoid firing multiple timer events in non-periodic
|
||||
* timer mode.
|
||||
*/
|
||||
switch (timo->clockid) {
|
||||
case CLOCK_REALTIME_FAST:
|
||||
case CLOCK_MONOTONIC_FAST:
|
||||
case CLOCK_UPTIME_FAST:
|
||||
*sbt += tc_tick_sbt;
|
||||
rem = *sbt % tc_tick_sbt;
|
||||
if (__predict_true(rem != 0))
|
||||
*sbt += tc_tick_sbt - rem;
|
||||
break;
|
||||
case CLOCK_SECOND:
|
||||
*sbt += SBT_1S;
|
||||
rem = *sbt % SBT_1S;
|
||||
if (__predict_true(rem != 0))
|
||||
*sbt += SBT_1S - rem;
|
||||
break;
|
||||
}
|
||||
*flags = C_ABSOLUTE;
|
||||
|
Loading…
Reference in New Issue
Block a user