Re: user-mode port 0.44-2.4.7

Anton Altaparmakov (aia21@cam.ac.uk)
Tue, 24 Jul 2001 19:07:47 +0100


At 17:52 24/07/2001, Davide Libenzi wrote:
>On 24-Jul-2001 Alexander Viro wrote:
> > On Tue, 24 Jul 2001, Davide Libenzi wrote:
>You're simply telling the compiler the way it has to ( not ) optimize the
>code.
>This is IMHO a declaration time issue.
>Looking at this code :
>
>while (jiffies < ...) {
> ...
>}
>
>the "natural" behaviour that a reader expects is that the "content" of the
>memory pointed by jiffied is loaded and compared.

Well, that depends on your definition of "natural". In my definition, it
would be absolutely normal in this example for the compiler to cache
jiffies because it considers it as a non-changing variable if none of the
code inside the while loop refers to jiffies again. But that's just me...

>If you like this code more :
>
>for (;;) {
> barrier();
> if (jiffies >= ...)
> break;
> ...
>}

Er, what is wrong with:

while (barrier(), jiffies < ...) {
...
}

It is just as clean as the starting point but tells both the compiler at
compile time and _me_ when reading the code that jiffies is expected to
change under me.

That is _way_ better than declaring it volatile in some obsure header file
which, chances are, I have never looked at, or looked at and long forgotten
about...

Just my 2p.

Anton

-- 
   "Nothing succeeds like success." - Alexandre Dumas
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://linux-ntfs.sf.net/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/

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