linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Timur Tabi <timur@freescale.com>
To: Roland Dreier <rdreier@cisco.com>
Cc: Scott Wood <scottwood@freescale.com>, linuxppc-dev@ozlabs.org
Subject: Re: [PATCH v5] introduce macro spin_event_timeout()
Date: Wed, 11 Mar 2009 11:31:50 -0500	[thread overview]
Message-ID: <ed82fe3e0903110931y62e23a02yf2a9719e5a69bd2@mail.gmail.com> (raw)
In-Reply-To: <adaiqmgbq6w.fsf@cisco.com>

On Wed, Mar 11, 2009 at 12:09 AM, Roland Dreier <rdreier@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.

> It might make sense for the parameter passed in to be in terms
> of microseconds but I have a hard time coming up with a case where
> having the real timeout be 40 msecs or whatever 1 jiffy ends up being is
> a real problem -- after all, this helper is intended for the case where
> we expect the condition to become true much sooner than the worst case.

Well, that's the point.  What if the condition takes a long time to
come true.  One argument against this code is that it encourages
developers to use busy-waits for long periods of time.  The only way
to prevent this is to make the timeout really short.  But if we're
using jiffies, then the minimum amount of time needs to be two.  It
can't be one, because what if jiffies increments immediately after
starting the loop?  So you need to use a value of two as a minimum.

Two jiffies can be a very long time.  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.

-- 
Timur Tabi
Linux kernel developer at Freescale

  reply	other threads:[~2009-03-11 16:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-10 22:11 [PATCH v5] introduce macro spin_event_timeout() Timur Tabi
2009-03-10 22:33 ` Scott Wood
2009-03-10 22:37   ` Josh Boyer
2009-03-10 22:58     ` Scott Wood
2009-03-11  0:32       ` Josh Boyer
2009-03-10 23:59     ` Benjamin Herrenschmidt
2009-03-11  0:22       ` Timur Tabi
2009-03-11  0:24         ` Benjamin Herrenschmidt
2009-03-11 17:10           ` Grant Likely
2009-03-11 21:49             ` Benjamin Herrenschmidt
2009-03-11 21:54               ` Timur Tabi
2009-03-11 22:49                 ` Scott Wood
2009-03-11  5:09         ` Roland Dreier
2009-03-11 16:31           ` Timur Tabi [this message]
2009-03-11 16:51             ` Scott Wood
2009-03-11 19:14               ` Timur Tabi
2009-03-11 19:22                 ` Scott Wood
2009-03-11 20:45                   ` Timur Tabi
2009-03-11 21:00                     ` Scott Wood
2009-03-11 21:02                       ` Timur Tabi
2009-03-11 21:03                         ` Scott Wood
2009-03-11  0:44       ` Josh Boyer
2009-03-10 23:58 ` Benjamin Herrenschmidt

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=ed82fe3e0903110931y62e23a02yf2a9719e5a69bd2@mail.gmail.com \
    --to=timur@freescale.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=rdreier@cisco.com \
    --cc=scottwood@freescale.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;
as well as URLs for NNTP newsgroup(s).