Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 01 Oct 2011 13:30:45 +0300
From:      Alexander Motin <mav@FreeBSD.org>
To:        Adrian Chadd <adrian@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: how are callouts handled in cpu_idle() ?
Message-ID:  <4E86EBD5.9070705@FreeBSD.org>
In-Reply-To: <CAJ-VmomqBRqeoS3iJiGULmj7xLAO9WeTiqtnYvDSGkZ9nECN2A@mail.gmail.com>
References:  <CAJ-Vmoksy68YmTXAQ1S87-%2BFMUHjZ-K0TOV0OUm3hQpYGZhXHw@mail.gmail.com>	<4E86DC86.3040204@FreeBSD.org>	<CAJ-Vmon1xMpourX1u6%2Bx=Y%2Bpi3G3VNCCJRoO1wHH6kCMKFYKog@mail.gmail.com>	<4E86E20B.7000703@FreeBSD.org> <CAJ-VmomqBRqeoS3iJiGULmj7xLAO9WeTiqtnYvDSGkZ9nECN2A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

-- 
Alexander Motin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E86EBD5.9070705>