[PATCH v6] introduce macro spin_event_timeout()
Timur Tabi
timur at freescale.com
Sat May 2 07:44:19 EST 2009
Sean MacLennan wrote:
> Would cpu_relax be a good thing to put here?
>
> Something like:
>
> while (!(rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \
> if (delay) \
> udelay(delay); \
> else \
> cpu_relax(); \
>
I had that at one point, but then I looked at the code for udelay(), and
it appears that if I do udelay(0), it does something similar to cpu_relax:
start = get_tbl();
while (get_tbl() - start < loops)
HMT_low();
HMT_medium();
cpu_relax does this:
do { HMT_low(); HMT_medium(); barrier(); } while (0)
Well, now that I look at it, cpu_relax() changes the thread priority to
low and then back to medium, whereas udelay() never sets it to low if
'loops' is 0.
I'm okay with changing my code, but I wonder if udelay() should look
like this:
start = get_tbl();
HMT_low();
while (get_tbl() - start < loops)
HMT_low();
HMT_medium();
--
Timur Tabi
Linux kernel developer at Freescale
More information about the Linuxppc-dev
mailing list