[PATCH v5] introduce macro spin_event_timeout()

Scott Wood scottwood at freescale.com
Thu Mar 12 03:51:51 EST 2009


Timur Tabi wrote:
> On Wed, Mar 11, 2009 at 12:09 AM, Roland Dreier <rdreier at cisco.com> wrote:
> 
>> Are there really cases where spinning for 1 jiffy is too long of a
>> timeout?
> 
> If the result is a timeout, then I say no.  A timeout is an error
> condition, and the code will usually terminate.
[snip]
> Two jiffies can be a very long time.

One jiffy is fine, but two is just too long?

Given that it only happens in cases of malfunctioning hardware (or a 
buggy driver), it seems reasonable as long as preemption isn't disabled 
(I'm assuming anyone that cares about a rare latency of a couple jiffies 
is using a preemptible kernel).

> Besides, if this function is
> used when interrupts are disabled, I believe that on some platforms,
> jiffies never increments.  If so, we can't use the actual 'jiffies'
> variable.

Disallow that, enforced with a call to might_sleep().

Alternatively, do something with get_cycles(), and have some sort of 
#define by which arches can say if get_cycles actually works.  In the 
absence of a working get_cycles() or equivalent, timeouts with 
interrupts disabled aren't going to happen whether we abstract it with a 
macro or not.

-Scott



More information about the Linuxppc-dev mailing list