Changeset View
Standalone View
sys/kern/kern_clocksource.c
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | if (fake) { | ||||
usermode = 0; | usermode = 0; | ||||
} else { | } else { | ||||
frame = curthread->td_intr_frame; | frame = curthread->td_intr_frame; | ||||
usermode = TRAPF_USERMODE(frame); | usermode = TRAPF_USERMODE(frame); | ||||
} | } | ||||
state = DPCPU_PTR(timerstate); | state = DPCPU_PTR(timerstate); | ||||
/* make sure the time is properly aligned */ | |||||
state->nexthard -= state->nexthard % tick_sbt; | |||||
runs = 0; | runs = 0; | ||||
while (now >= state->nexthard) { | while (now >= state->nexthard) { | ||||
state->nexthard += tick_sbt; | state->nexthard += tick_sbt; | ||||
runs++; | runs++; | ||||
} | } | ||||
if (runs) { | if (runs) { | ||||
hct = DPCPU_PTR(hardclocktime); | hct = DPCPU_PTR(hardclocktime); | ||||
*hct = state->nexthard - tick_sbt; | *hct = state->nexthard - tick_sbt; | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | #endif | ||||
if (busy) | if (busy) | ||||
return; | return; | ||||
/* Update present and next tick times. */ | /* Update present and next tick times. */ | ||||
state = DPCPU_PTR(timerstate); | state = DPCPU_PTR(timerstate); | ||||
if (et->et_flags & ET_FLAGS_PERCPU) { | if (et->et_flags & ET_FLAGS_PERCPU) { | ||||
next = &state->nexttick; | next = &state->nexttick; | ||||
} else | } else | ||||
next = &nexttick; | next = &nexttick; | ||||
now = sbinuptime(); | now = sbinuptime(); | ||||
hselasky: @mav : Unless we align the sbinuptime() value here, the *next value will start sliding. Do you… | |||||
Done Inline ActionsPeriodic timers may have arbitrary phase or even drift here or there relative to timecounter, we have no control over that. We can not align them in general case. Due to jitter it may theoretically happen that some interrupt period will cover two ticks, while the next -- none. Existing code But I don't care much about the periodic timers, since they are not widely used any more. Actually, I can't even find now where nexttick is used for periodic timers now, may be it could be scrapped, or used only for one-shot timers to keep its current programming to know when we need to reprogram it. mav: Periodic timers may have arbitrary phase or even drift here or there relative to timecounter… | |||||
Done Inline ActionsMy patch doesn't hurt if two ticks are skipped or more. It just ensure that the next tick is properly aligned as it should, and doesn't accumulate errors! hselasky: My patch doesn't hurt if two ticks are skipped or more. It just ensure that the next tick is… | |||||
Not Done Inline ActionsWho said that "it should"? As I have told, periodic counters didn't promise us anything. Some may be able to accept first event time, but not all. As I have told, I've tried to find what would your change hurt, but haven't found where that value is used at all for periodic timers, that is why I said may be we could scrap it all together, leaving only for one-shot timers. mav: Who said that "it should"? As I have told, periodic counters didn't promise us anything. Some… | |||||
Done Inline Actions
Nobody I guess. So why not make kern.hz a power of two, and skip all those expensive modulus and divisions in the callout subsystem? Would there be any consequences? I guess not? hselasky: > Who said that "it should" ?
Nobody I guess. So why not make kern.hz a power of two, and skip… | |||||
if (periodic) | if (periodic) | ||||
*next = now + timerperiod; | *next = now - (now % timerperiod) + timerperiod; | ||||
else | else | ||||
*next = -1; /* Next tick is not scheduled yet. */ | *next = -1; /* Next tick is not scheduled yet. */ | ||||
state->now = now; | state->now = now; | ||||
CTR2(KTR_SPARE2, "intr: now %d.%08x", | CTR2(KTR_SPARE2, "intr: now %d.%08x", | ||||
(int)(now >> 32), (u_int)(now & 0xffffffff)); | (int)(now >> 32), (u_int)(now & 0xffffffff)); | ||||
#ifdef SMP | #ifdef SMP | ||||
#ifdef EARLY_AP_STARTUP | #ifdef EARLY_AP_STARTUP | ||||
▲ Show 20 Lines • Show All 661 Lines • Show Last 20 Lines |
@mav : Unless we align the sbinuptime() value here, the *next value will start sliding. Do you agree?