how are callouts handled in cpu_idle() ?
mav at FreeBSD.org
Sat Oct 1 10:31:02 UTC 2011
Adrian Chadd wrote:
> Right. Hm, what about for i386/amd64 cases we call intr_disable()
> before the critical_enter and idleclock, then re-enable either just
> before the wait/halt call (like it is now) or just after the
> sched_running check (just like it is now.)
> That way a filter handler which schedules a callout gets called correctly?
As I have described, that can fix only part of the problems (only
delayed shots, but not too early shots). It still won't allow to
reliably use callouts from the interrupt filter handlers.
Also I've just recalled one possible issue from that. cpu_idleclock()
calls binuptime() to get present system time to properly reprogram timer
hardware. In most cases binuptime() is quite undemanding call to be
called anywhere, but at least on some kinds of sparc64 hardware it uses
IPI to read time counter from another CPU, because of assumption that
CPUs may not be synchronized. I hate that, but that's fact. Attempt to
wait for IPI with interrupt disabled may cause dead lock between several
CPUs. Respecting that, in event timers subsystem I was trying to avoid
calling binuptime() with disabled interrupts. To be honest, sparc64
doesn't have cpu_idle() function now to all, but if we speaking about
general (perfect) case, we should either continue avoid this, or deny
things like what sparc64 does.
More information about the freebsd-hackers