From: Peter Zijlstra <peterz@infradead.org>
To: Timur Tabi <timur@freescale.com>
Cc: Grant Likely <grant.likely@secretlab.ca>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
linux-kernel@vger.kernel.org, rdreier@cisco.com,
jirislaby@gmail.com, will.newton@gmail.com, hancockrwd@gmail.com,
jeremy@goop.org
Subject: Re: [PATCH v4] introduce macro spin_event_timeout()
Date: Thu, 12 Mar 2009 17:50:09 +0100 [thread overview]
Message-ID: <1236876609.5090.934.camel@laptop> (raw)
In-Reply-To: <49B9362D.3090805@freescale.com>
On Thu, 2009-03-12 at 11:19 -0500, Timur Tabi wrote:
> Grant Likely wrote:
>
> > #define spin_until_timeout(condition, timeout, rc) \
> > for (unsigned long __timeout = jiffies + (timeout); \
> > (!(rc = (condition)) && time_after(jiffies, __timeout)); )
>
> Ooo, that's good.
>
> I'm still not crazy about using jiffies, since it doesn't get
> incremented when interrupts are disabled, and I'd like this function to
> work in those cases. How about get_cycles()? I know it's not supported
> on all platforms, but I'm willing to live with that.
>
> The other problem with get_cycles() is that there doesn't appear to be a
> num_cycles_per_usec() function, so there's no way for me to scale the
> count to a fixed time period.
sched_clock() does that, but:
- it falls back to jiffies on poor platforms
- it requires to be called with IRQs disabled
- it can basically jump any random way on funky hardware
then there is cpu_clock(int cpu):
- still falls back to jiffies on poor platforms
- is monotonic when used on the same cpu
- can drift up to a few jiffies when used between cpus
But something that seems to always work, is simply count loops and rely
on whatever delay is in the specified loop.
#define spin_until_timeout(condition, timeout, rc) \
for (unsigned long __timeout = 0; \
!(rc = (condition)) && __timeout < (timeout); \
__timeout++)
next prev parent reply other threads:[~2009-03-12 16:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-10 15:30 [PATCH v4] introduce macro spin_event_timeout() Timur Tabi
2009-03-10 15:35 ` Alan Cox
2009-03-10 15:50 ` Timur Tabi
2009-03-10 16:05 ` Will Newton
2009-03-10 16:11 ` Timur Tabi
2009-03-11 0:01 ` Benjamin Herrenschmidt
2009-03-11 0:37 ` Alan Cox
2009-03-11 16:48 ` Timur Tabi
2009-03-11 16:58 ` Alan Cox
2009-03-11 18:18 ` Timur Tabi
2009-03-11 21:58 ` Benjamin Herrenschmidt
2009-03-12 2:45 ` Grant Likely
2009-03-12 15:54 ` Timur Tabi
2009-03-12 16:01 ` Grant Likely
2009-03-12 16:19 ` Timur Tabi
2009-03-12 16:50 ` Peter Zijlstra [this message]
2009-03-12 19:05 ` Timur Tabi
2009-03-13 3:03 ` Benjamin Herrenschmidt
2009-03-13 4:51 ` Grant Likely
2009-03-10 18:41 ` Grant Likely
2009-03-10 19:04 ` Timur Tabi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1236876609.5090.934.camel@laptop \
--to=peterz@infradead.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=benh@kernel.crashing.org \
--cc=grant.likely@secretlab.ca \
--cc=hancockrwd@gmail.com \
--cc=jeremy@goop.org \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rdreier@cisco.com \
--cc=timur@freescale.com \
--cc=will.newton@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox