Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread H. Peter Anvin
pradeep singh wrote: > > Sorry, for my misunderstanding but i hope Jonathan actually means > volatile harmful only in C and not while using extended asm with gcc? Or > does you all consider volatile while using extended asm as harmful too? > Incidentally i came to know that using volatile in such

Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread H. Peter Anvin
Jan Engelhardt wrote: >>> >>> turns up no less than 1106+2 hits. >> You forgot to exclude instances with "asm" in them. > > You can do that. > I can. 54.2% of those hits were "asm", and therefore require the "register" keyword. -hpa - To unsubscribe from this list: send the line "unsub

Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread Jan Engelhardt
On May 10 2007 14:45, H. Peter Anvin wrote: >Jan Engelhardt wrote: >> On May 10 2007 14:20, Jonathan Corbet wrote: >>> Who knew a documentation patch would get so many reviews? I like it... >> >> And the next thing is register-considered-harmful.txt. Running >> >> grep -Pr '\bregister\s+(u

Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread Satyam Sharma
On 5/11/07, Johannes Stezenbach <[EMAIL PROTECTED]> wrote: On Fri, May 11, 2007 at 02:08:54AM +0530, jimmy bahuleyan wrote: > Jonathan Corbet wrote: > [snip..] > > + > > + - The jiffies variable is special in that it can have a different value > > +every time it is referenced, but it can be

Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread jimmy bahuleyan
Johannes Stezenbach wrote: > On Fri, May 11, 2007 at 02:08:54AM +0530, jimmy bahuleyan wrote: >> Jonathan Corbet wrote: >> [snip..] >>> + >>> + - The jiffies variable is special in that it can have a different value >>> +every time it is referenced, but it can be read without any special >>> +

Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread Johannes Stezenbach
On Fri, May 11, 2007 at 02:08:54AM +0530, jimmy bahuleyan wrote: > Jonathan Corbet wrote: > [snip..] > > + > > + - The jiffies variable is special in that it can have a different value > > +every time it is referenced, but it can be read without any special > > +locking. So jiffies can be

Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread Stefan Richter
Jonathan Corbet wrote: > +The key point to understand with regard to volatile is that its purpose is > +to suppress optimization, which is almost never what one really wants to > +do. In the kernel, one must protect shared data structures against > +unwanted concurrent access, which is very much a

Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread Bernd Eckenfels
In article <[EMAIL PROTECTED]> you wrote: > +Consider a typical block of kernel code: > + > +spin_lock(&the_lock); > +do_something_on(&shared_data); > +do_something_else_with(&shared_data); > +spin_unlock(&the_lock); > + > +If all the code follows the locking rules, the value of sha

Re: [PATCH] "volatile considered harmful", take 2

2007-05-11 Thread Philipp Matthias Hahn
Hello! On Thu, May 10, 2007 at 02:20:19PM -0600, Jonathan Corbet wrote: ... > +++ b/Documentation/volatile-considered-harmful.txt ... > +Consider a typical block of kernel code: > + > +spin_lock(&the_lock); > +do_something_on(&shared_data); ^^^ > +do_som

Re: [PATCH] "volatile considered harmful", take 2

2007-05-10 Thread H. Peter Anvin
Jan Engelhardt wrote: > On May 10 2007 14:20, Jonathan Corbet wrote: >> Who knew a documentation patch would get so many reviews? I like it... > > And the next thing is register-considered-harmful.txt. Running > > grep -Pr '\bregister\s+(unsigned|char|short|int|long|float| > double|s

Re: [PATCH] "volatile considered harmful", take 2

2007-05-10 Thread Satyam Sharma
On 5/11/07, jimmy bahuleyan <[EMAIL PROTECTED]> wrote: Jonathan Corbet wrote: [snip..] > + > + - The jiffies variable is special in that it can have a different value > +every time it is referenced, but it can be read without any special > +locking. So jiffies can be volatile, but the a

Re: [PATCH] "volatile considered harmful", take 2

2007-05-10 Thread Jan Engelhardt
On May 10 2007 14:20, Jonathan Corbet wrote: > >Who knew a documentation patch would get so many reviews? I like it... And the next thing is register-considered-harmful.txt. Running grep -Pr '\bregister\s+(unsigned|char|short|int|long|float| double|struct|union|uint|u\d+|s\d+)\b

Re: [PATCH] "volatile considered harmful", take 2

2007-05-10 Thread jimmy bahuleyan
Jonathan Corbet wrote: [snip..] > + > + - The jiffies variable is special in that it can have a different value > +every time it is referenced, but it can be read without any special > +locking. So jiffies can be volatile, but the addition of other > +variables of this type is strongl

[PATCH] "volatile considered harmful", take 2

2007-05-10 Thread Jonathan Corbet
Who knew a documentation patch would get so many reviews? I like it... Anyway, here's a new version in which I attempt to respond to all the comments that came in. Thanks to everybody for looking it over. jon Steer developers away from the volatile type. Signed-off-by: Jonathan Corbet <[EMAIL