[Bug 264867] kevent EVFILT_TIMER, timer expiration with twice the period

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 02 Jul 2022 17:21:07 UTC

Mark Johnston <markj@FreeBSD.org> changed:

           What    |Removed                     |Added
           Assignee|bugs@FreeBSD.org            |markj@FreeBSD.org

--- Comment #16 from Mark Johnston <markj@FreeBSD.org> ---
Ok, I'm still able to reproduce the problem with my patch.  But, the frequency
of the late wakeups is much much lower, and I'm fairly sure that the patch
solves a legitimate problem on its own.

Specifically, getnextcpuevent() contains the following bit of code:

/* Handle callout events. */
if (event > state->nextcall)
    event = state->nextcall;

It gets called when a CPU goes idle, and the idle thread is scheduling the next
timer interrupt.  "nextcall" is not volatile, and interrupts are enabled, so
state->nextcall can be modified between the check and the load, and the CPU
will end up using a stale value.

It might be that there is another, similar race in handleevents(), since a
different CPU might be updating state->nextcall concurrently.  But I think the
race is harmless since callout_process() should be able to find the next

You are receiving this mail because:
You are the assignee for the bug.