public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* backwards busy wait using "time_before()"??
@ 2009-12-31 16:40 Robert P. J. Day
  2009-12-31 19:23 ` Robert P. J. Day
  2010-01-01 15:17 ` Andi Kleen
  0 siblings, 2 replies; 3+ messages in thread
From: Robert P. J. Day @ 2009-12-31 16:40 UTC (permalink / raw)
  To: Linux Kernel Mailing List


  if this is an idiotic question, i'll blame it on the fact that
there's only decaf left in the house.

  from drivers/spi/spi_stmp.c:

   #define busy_wait(cond)                                              \
        ({                                                              \
        unsigned long end_jiffies = jiffies + STMP_SPI_TIMEOUT;         \
        bool succeeded = false;                                         \
        do {                                                            \
                if (cond) {                                             \
                        succeeded = true;                               \
                        break;                                          \
                }                                                       \
                cpu_relax();                                            \
        } while (time_before(end_jiffies, jiffies));                    \
        succeeded;                                                      \
        })


  is it just me, or do those arguments to time_before() look
backwards?

rday
--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: backwards busy wait using "time_before()"??
  2009-12-31 16:40 backwards busy wait using "time_before()"?? Robert P. J. Day
@ 2009-12-31 19:23 ` Robert P. J. Day
  2010-01-01 15:17 ` Andi Kleen
  1 sibling, 0 replies; 3+ messages in thread
From: Robert P. J. Day @ 2009-12-31 19:23 UTC (permalink / raw)
  To: Linux Kernel Mailing List

On Thu, 31 Dec 2009, Robert P. J. Day wrote:

>
>   if this is an idiotic question, i'll blame it on the fact that
> there's only decaf left in the house.
>
>   from drivers/spi/spi_stmp.c:
>
>    #define busy_wait(cond)                                              \
>         ({                                                              \
>         unsigned long end_jiffies = jiffies + STMP_SPI_TIMEOUT;         \
>         bool succeeded = false;                                         \
>         do {                                                            \
>                 if (cond) {                                             \
>                         succeeded = true;                               \
>                         break;                                          \
>                 }                                                       \
>                 cpu_relax();                                            \
>         } while (time_before(end_jiffies, jiffies));                    \
>         succeeded;                                                      \
>         })
>
>
>   is it just me, or do those arguments to time_before() look
> backwards?

  with a quick grep, i found one other example that looks reversed.
from drivers/char/hvsi.c:

static void hvsi_drain_input(struct hvsi_struct *hp)
{
        uint8_t buf[HVSI_MAX_READ] __ALIGNED__;
        unsigned long end_jiffies = jiffies + HVSI_TIMEOUT;

        while (time_before(end_jiffies, jiffies))
                if (0 == hvsi_read(hp, buf, HVSI_MAX_READ))
                        break;
}


  surely that's backwards as well, no?

rday
--


========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: backwards busy wait using "time_before()"??
  2009-12-31 16:40 backwards busy wait using "time_before()"?? Robert P. J. Day
  2009-12-31 19:23 ` Robert P. J. Day
@ 2010-01-01 15:17 ` Andi Kleen
  1 sibling, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2010-01-01 15:17 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Linux Kernel Mailing List

"Robert P. J. Day" <rpjday@crashcourse.ca> writes:

>                 cpu_relax();                                            \
>         } while (time_before(end_jiffies, jiffies));                    \
>         succeeded;                                                      \
>         })
>
>
>   is it just me, or do those arguments to time_before() look
> backwards?

Yes it looks backwards. The timeout path probably has been never
tested.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-01-01 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-31 16:40 backwards busy wait using "time_before()"?? Robert P. J. Day
2009-12-31 19:23 ` Robert P. J. Day
2010-01-01 15:17 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox