lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 09 Mar 2009 13:16:48 -0500
From:	Timur Tabi <timur@...escale.com>
To:	Peter Zijlstra <peterz@...radead.org>
CC:	linux-kernel@...r.kernel.org, rdreier@...co.com,
	jirislaby@...il.com
Subject: Re: [PATCH v2] add function spin_event_timeout()

Peter Zijlstra wrote:

> This changelog utterly fails to justify this interface. And to me it
> seems a rather bad one. 

I'll update the commit to include a justification, but in the meantime,
let me answer your question.

The primary purpose of this macro is to provide a way for drivers to
poll a status register waiting for a bit to change.  In most cases, this
 bit should change very quickly, even within a few cycles.  The timeout
is used as a way to easily deal with situations where the hardware is
misprogrammed such that the bit never changes.

Too often, developers do something like this:

	while (!(in_be32(&ssi->sisr) & CCSR_SSI_SISR_RFF0));

If something goes wrong and RFF0 never gets set, then this loop will
never exit.  So to encourage developers to do it the right way, and to
make it simpler to identify code which does this sort of thing, I'm
introducing spin_event_timeout().

> Why would we ever be wanting to spin in order of
> jiffies?

I picked jiffies because it seems straightforward, but I think I see
your point.  It has two drawbacks:

1) It's too coarse of a time measurement.  Most people will probably use
a value of 1 or 2.

2) It can't be used if interrupts are disabled, because then jiffies
won't be updated.

So I can switch that to using ndelay().

-- 
Timur Tabi
Linux kernel developer at Freescale
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ