Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Scott Wood
Timur Tabi wrote: Benjamin Herrenschmidt wrote: Well, there's a non-empty set of HW where polling as fast as you can will effectively prevent it to make fwd progress... Alan Cox mentioned this. He gave PCI and 10us as an example. I suggested adding a third parameter that would be a udelay(

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Timur Tabi
Benjamin Herrenschmidt wrote: Well, there's a non-empty set of HW where polling as fast as you can will effectively prevent it to make fwd progress... Alan Cox mentioned this. He gave PCI and 10us as an example. I suggested adding a third parameter that would be a udelay() inserted into the

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Benjamin Herrenschmidt
> No, not udelay. Or any delay for that matter. If spinning on a > condition, then there is no advantage to burning cycles with a > udelay(). Those cycles may as well be used to keep testing the > condition so the loop can be exited faster. a udelay() would only > serve to always make the busy

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Scott Wood
Timur Tabi wrote: Scott Wood wrote: > Or you can say that atomic context is outside the scope of this macro. No, I don't want to say that. We have wait_event_timeout() for larger-scale operations. I'm just looking for something that can replace "while (!condition);" wait_event_timeout()

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Timur Tabi
Scott Wood wrote: > Or you can say that atomic context is outside the scope of this macro. No, I don't want to say that. We have wait_event_timeout() for larger-scale operations. I'm just looking for something that can replace "while (!condition);" -- Timur Tabi Linux Kernel Developer @ Fre

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Scott Wood
Timur Tabi wrote: On Wed, Mar 11, 2009 at 2:22 PM, Scott Wood wrote: I was under the impression that we were only talking about timeouts, and that the common case was significantly shorter than that. I think one of the concerns that Alan Cox raised is that the existence of this macro would e

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Timur Tabi
On Wed, Mar 11, 2009 at 2:22 PM, Scott Wood wrote: > I was under the impression that we were only talking about timeouts, and > that the common case was significantly shorter than that. I think one of the concerns that Alan Cox raised is that the existence of this macro would encourage people to

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Scott Wood
Timur Tabi wrote: On Wed, Mar 11, 2009 at 11:51 AM, Scott Wood wrote: One jiffy is fine, but two is just too long? Any number of jiffies is *not* too long if a timeout occurs. However, I think even one jiffy is too long if that's the normal condition. I was under the impression that we we

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Timur Tabi
On Wed, Mar 11, 2009 at 11:51 AM, Scott Wood wrote: > One jiffy is fine, but two is just too long? Any number of jiffies is *not* too long if a timeout occurs. However, I think even one jiffy is too long if that's the normal condition. Unfortunately, the driver may not have any choice in some c

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Grant Likely
On Tue, Mar 10, 2009 at 6:24 PM, Benjamin Herrenschmidt wrote: > On Tue, 2009-03-10 at 19:22 -0500, Timur Tabi wrote: >> >> Alan did have one valid point though.  Determining how long to loop >> for is architecture-specific.  Using jiffies is bad, because even one >> jiffy is too long.  Adding a u

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Scott Wood
Timur Tabi wrote: On Wed, Mar 11, 2009 at 12:09 AM, Roland Dreier 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

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-11 Thread Timur Tabi
On Wed, Mar 11, 2009 at 12:09 AM, Roland Dreier 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. > It might make sense for the parameter passed

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Roland Dreier
> Alan did have one valid point though. Determining how long to loop > for is architecture-specific. Using jiffies is bad, because even one > jiffy is too long. Adding a udelay() inside the loop means that it > only checks he condition every microsecond. So the real solution is > to use ke

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Josh Boyer
On Wed, Mar 11, 2009 at 10:59:11AM +1100, Benjamin Herrenschmidt wrote: >On Tue, 2009-03-10 at 18:37 -0400, Josh Boyer wrote: >> On Tue, Mar 10, 2009 at 05:33:08PM -0500, Scott Wood wrote: >> > Timur Tabi wrote: >> >> The macro spin_event_timeout() takes a condition and timeout value >> >> (in micr

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Josh Boyer
On Tue, Mar 10, 2009 at 05:58:58PM -0500, Scott Wood wrote: > Josh Boyer wrote: >> On Tue, Mar 10, 2009 at 05:33:08PM -0500, Scott Wood wrote: >>> Timur Tabi wrote: The macro spin_event_timeout() takes a condition and timeout value (in microseconds) as parameters. It spins until either t

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Timur Tabi
On Tue, Mar 10, 2009 at 6:59 PM, Benjamin Herrenschmidt wrote: > And ? We can disagree with Alan... If you guys want to argue with Alan on lkml, please go ahead. I could use the support. Alan did have one valid point though. Determining how long to loop for is architecture-specific. Using ji

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Benjamin Herrenschmidt
On Tue, 2009-03-10 at 19:22 -0500, Timur Tabi wrote: > > Alan did have one valid point though. Determining how long to loop > for is architecture-specific. Using jiffies is bad, because even one > jiffy is too long. Adding a udelay() inside the loop means that it > only checks he condition ever

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Benjamin Herrenschmidt
On Tue, 2009-03-10 at 18:37 -0400, Josh Boyer wrote: > On Tue, Mar 10, 2009 at 05:33:08PM -0500, Scott Wood wrote: > > Timur Tabi wrote: > >> The macro spin_event_timeout() takes a condition and timeout value > >> (in microseconds) as parameters. It spins until either the condition is > >> true >

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Benjamin Herrenschmidt
On Tue, 2009-03-10 at 17:11 -0500, Timur Tabi wrote: > The macro spin_event_timeout() takes a condition and timeout value > (in microseconds) as parameters. It spins until either the condition is true > or the timeout expires. It returns zero if the timeout expires first, > non-zero > otherwise.

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Scott Wood
Josh Boyer wrote: On Tue, Mar 10, 2009 at 05:33:08PM -0500, Scott Wood wrote: Timur Tabi wrote: The macro spin_event_timeout() takes a condition and timeout value (in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns zero if the timeou

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Josh Boyer
On Tue, Mar 10, 2009 at 05:33:08PM -0500, Scott Wood wrote: > Timur Tabi wrote: >> The macro spin_event_timeout() takes a condition and timeout value >> (in microseconds) as parameters. It spins until either the condition is true >> or the timeout expires. It returns zero if the timeout expires f

Re: [PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Scott Wood
Timur Tabi wrote: The macro spin_event_timeout() takes a condition and timeout value (in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns zero if the timeout expires first, non-zero otherwise. This primary purpose of this macro is to p

[PATCH v5] introduce macro spin_event_timeout()

2009-03-10 Thread Timur Tabi
The macro spin_event_timeout() takes a condition and timeout value (in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns zero if the timeout expires first, non-zero otherwise. This primary purpose of this macro is to poll on a hardware re