Re: [RFC/PATCH] doc: volatile considered evil

2007-05-09 Thread Satyam Sharma
On 5/9/07, Johannes Stezenbach <[EMAIL PROTECTED]> wrote: On Tue, May 08, 2007, Jonathan Corbet wrote: > > I just took a shot at turning this into something more like a normal > document: > > http://lwn.net/Articles/233479/ I think the "jiffies variable is special" part misses the "for

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-09 Thread Johannes Stezenbach
On Tue, May 08, 2007, Jonathan Corbet wrote: > > I just took a shot at turning this into something more like a normal > document: > > http://lwn.net/Articles/233479/ I think the "jiffies variable is special" part misses the "for stupid legacy reasons" explanation. According to the other

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-09 Thread Johannes Stezenbach
On Tue, May 08, 2007, Jonathan Corbet wrote: I just took a shot at turning this into something more like a normal document: http://lwn.net/Articles/233479/ I think the jiffies variable is special part misses the for stupid legacy reasons explanation. According to the other volatile

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-09 Thread Satyam Sharma
On 5/9/07, Johannes Stezenbach [EMAIL PROTECTED] wrote: On Tue, May 08, 2007, Jonathan Corbet wrote: I just took a shot at turning this into something more like a normal document: http://lwn.net/Articles/233479/ I think the jiffies variable is special part misses the for stupid

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jonathan Corbet
Randy Dunlap <[EMAIL PROTECTED]> wrote: > Here are some 'volatile' comments from Linus, extracted from > several emails in at least 2 threads. > > If this is close to useful, we can add it to Documentation/. I just took a shot at turning this into something more like a normal document:

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
David Rientjes wrote: On Tue, 8 May 2007, Randy Dunlap wrote: It's already there, isn't it? The only acceptable uses for "volatile" are: - in _code_, i.e., for things like the definition of "readb()" etc, where we use it to force a particular access. - with inline asms - on

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Randy Dunlap wrote: > It's already there, isn't it? > > The only acceptable uses for "volatile" are: > > - in _code_, i.e., for things like the definition of "readb()" etc, where we >use it to force a particular access. > - with inline asms > - on "jiffies", for

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
On Tue, 8 May 2007 13:20:31 -0700 (PDT) David Rientjes wrote: > On Tue, 8 May 2007, Krzysztof Halasa wrote: > > > > Since 'volatile' has two different semantics depending on the context in > > > which it is used, this warning should be appended to include the fact > > > that > > > it is

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
On Tue, 8 May 2007 14:27:33 -0700 (PDT) David Rientjes wrote: > On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: > > > It's probably worth noting that "asm volatile (...)" doesn't mean what > > many people think it means: specifically, it *does not* prevent the asm > > from being reordered with

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: > Sounds like it's referring to micro-architectural reordering, which is > distinct from compiler reordering. In other words, even if you > specified "-mvolatile-asm-stop" I would assume that the compiler could > still reorder the asm statements.

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
David Rientjes wrote: > It is analogous with a sequence point for ia64. But, as you mentioned, it > is ia64 specific so your comment about "asm volatile" constructs not being > reordered is always appropriate outside of ia64 specific code but may not > apply to ia64 if we ever compiled with

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: > > You're point about reordering "asm volatile" constructs differs depending > > on -mvolatile-asm-stop or -mno-volatile-asm-stop, however. > > > > Erm, that seems to be ia64 specific, and I have no idea what adding a > "stop bit" implies. Can

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
David Rientjes wrote: > Now if all such output operands are to specify that the input operands > were "modified", 'volatile' is required to ensure the side-effects are > preserved or, otherwise, gcc is free optimize the entire asm construct > away since it appears to be unused. > Yup. >>

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: > > In an asm construct, if all your input operands are modified and > > specified as output operands as well, volatile must be added so > > that the entire construct is not optimized away. Additionally, > > it must be added if

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
David Rientjes wrote: > Ok, so let's take your second paragraph and my email of an hour ago: > > In an asm construct, if all your input operands are modified and > specified as output operands as well, volatile must be added so > that the entire construct is not optimized away.

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: > It's probably worth noting that "asm volatile (...)" doesn't mean what > many people think it means: specifically, it *does not* prevent the asm > from being reordered with respect to the surrounding code. It may not > even prevent it from being

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
Jeremy Fitzhardinge wrote: David Rientjes wrote: Since 'volatile' has two different semantics depending on the context in which it is used, this warning should be appended to include the fact that it is legitimate to use for inline assembly. It's probably worth noting that "asm volatile

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeff Garzik
Randy Dunlap wrote: Jeff Garzik wrote: Jeremy Fitzhardinge wrote: No, David means that "asm volatile (...)" is meaningful and OK to use. I thought it was OK in readl(), writel(), etc... (and in asm), but that's it. (and jiffies) In a driver? Highly unlikey it is OK. In a filesystem?

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
Jeff Garzik wrote: Jeremy Fitzhardinge wrote: No, David means that "asm volatile (...)" is meaningful and OK to use. I thought it was OK in readl(), writel(), etc... (and in asm), but that's it. (and jiffies) In a driver? Highly unlikey it is OK. In a filesystem? Even more unlikely it

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
David Rientjes wrote: > Since 'volatile' has two different semantics depending on the context in > which it is used, this warning should be appended to include the fact that > it is legitimate to use for inline assembly. > It's probably worth noting that "asm volatile (...)" doesn't mean

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeff Garzik
Jeremy Fitzhardinge wrote: No, David means that "asm volatile (...)" is meaningful and OK to use. In a driver? Highly unlikey it is OK. In a filesystem? Even more unlikely it is OK to use. The set of circumstances where 'volatile' is acceptable is very limited. You will see it used

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Krzysztof Halasa
Jeremy Fitzhardinge <[EMAIL PROTECTED]> writes: > No, David means that "asm volatile (...)" is meaningful and OK to use. Ok, I mistook that. -- Krzysztof Halasa - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
Krzysztof Halasa wrote: > David Rientjes <[EMAIL PROTECTED]> writes: > > >> Since 'volatile' has two different semantics depending on the context in >> which it is used, this warning should be appended to include the fact that >> it is legitimate to use for inline assembly. >> > > I

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Krzysztof Halasa wrote: > > Since 'volatile' has two different semantics depending on the context in > > which it is used, this warning should be appended to include the fact that > > it is legitimate to use for inline assembly. > > I think it hasn't two semantics, it's

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Satyam Sharma
On 5/8/07, Randy Dunlap <[EMAIL PROTECTED]> wrote: On Mon, 30 Apr 2007 23:56:42 -0700 Andrew Morton wrote: > Oh my eyes. What are these doing? > > The volatiles are a worry - volatile is said to be basically-always-wrong > in-kernel, although we've never managed to document why, and i386 >

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Krzysztof Halasa
David Rientjes <[EMAIL PROTECTED]> writes: > Since 'volatile' has two different semantics depending on the context in > which it is used, this warning should be appended to include the fact that > it is legitimate to use for inline assembly. I think it hasn't two semantics, it's like arguing

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Randy Dunlap wrote: > [well, can be turned into a patch] > > Here are some 'volatile' comments from Linus, extracted from > several emails in at least 2 threads. > > If this is close to useful, we can add it to Documentation/. > >

[RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
On Mon, 30 Apr 2007 23:56:42 -0700 Andrew Morton wrote: > Oh my eyes. What are these doing? > > The volatiles are a worry - volatile is said to be basically-always-wrong > in-kernel, although we've never managed to document why, and i386 > cheerfully uses it in readb() and friends. > > Perhaps

[RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
On Mon, 30 Apr 2007 23:56:42 -0700 Andrew Morton wrote: Oh my eyes. What are these doing? The volatiles are a worry - volatile is said to be basically-always-wrong in-kernel, although we've never managed to document why, and i386 cheerfully uses it in readb() and friends. Perhaps if you

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Randy Dunlap wrote: [well, can be turned into a patch] Here are some 'volatile' comments from Linus, extracted from several emails in at least 2 threads. If this is close to useful, we can add it to Documentation/.

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Krzysztof Halasa
David Rientjes [EMAIL PROTECTED] writes: Since 'volatile' has two different semantics depending on the context in which it is used, this warning should be appended to include the fact that it is legitimate to use for inline assembly. I think it hasn't two semantics, it's like arguing that

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Satyam Sharma
On 5/8/07, Randy Dunlap [EMAIL PROTECTED] wrote: On Mon, 30 Apr 2007 23:56:42 -0700 Andrew Morton wrote: Oh my eyes. What are these doing? The volatiles are a worry - volatile is said to be basically-always-wrong in-kernel, although we've never managed to document why, and i386 cheerfully

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Krzysztof Halasa wrote: Since 'volatile' has two different semantics depending on the context in which it is used, this warning should be appended to include the fact that it is legitimate to use for inline assembly. I think it hasn't two semantics, it's like

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
Krzysztof Halasa wrote: David Rientjes [EMAIL PROTECTED] writes: Since 'volatile' has two different semantics depending on the context in which it is used, this warning should be appended to include the fact that it is legitimate to use for inline assembly. I think it hasn't two

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Krzysztof Halasa
Jeremy Fitzhardinge [EMAIL PROTECTED] writes: No, David means that asm volatile (...) is meaningful and OK to use. Ok, I mistook that. -- Krzysztof Halasa - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeff Garzik
Jeremy Fitzhardinge wrote: No, David means that asm volatile (...) is meaningful and OK to use. In a driver? Highly unlikey it is OK. In a filesystem? Even more unlikely it is OK to use. The set of circumstances where 'volatile' is acceptable is very limited. You will see it used

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
David Rientjes wrote: Since 'volatile' has two different semantics depending on the context in which it is used, this warning should be appended to include the fact that it is legitimate to use for inline assembly. It's probably worth noting that asm volatile (...) doesn't mean what

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
Jeff Garzik wrote: Jeremy Fitzhardinge wrote: No, David means that asm volatile (...) is meaningful and OK to use. I thought it was OK in readl(), writel(), etc... (and in asm), but that's it. (and jiffies) In a driver? Highly unlikey it is OK. In a filesystem? Even more unlikely it is

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
Jeremy Fitzhardinge wrote: David Rientjes wrote: Since 'volatile' has two different semantics depending on the context in which it is used, this warning should be appended to include the fact that it is legitimate to use for inline assembly. It's probably worth noting that asm volatile

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeff Garzik
Randy Dunlap wrote: Jeff Garzik wrote: Jeremy Fitzhardinge wrote: No, David means that asm volatile (...) is meaningful and OK to use. I thought it was OK in readl(), writel(), etc... (and in asm), but that's it. (and jiffies) In a driver? Highly unlikey it is OK. In a filesystem? Even

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: It's probably worth noting that asm volatile (...) doesn't mean what many people think it means: specifically, it *does not* prevent the asm from being reordered with respect to the surrounding code. It may not even prevent it from being

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
David Rientjes wrote: Ok, so let's take your second paragraph and my email of an hour ago: In an asm construct, if all your input operands are modified and specified as output operands as well, volatile must be added so that the entire construct is not optimized away.

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: In an asm construct, if all your input operands are modified and specified as output operands as well, volatile must be added so that the entire construct is not optimized away. Additionally, it must be added if your

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
David Rientjes wrote: Now if all such output operands are to specify that the input operands were modified, 'volatile' is required to ensure the side-effects are preserved or, otherwise, gcc is free optimize the entire asm construct away since it appears to be unused. Yup. Yeah,

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: You're point about reordering asm volatile constructs differs depending on -mvolatile-asm-stop or -mno-volatile-asm-stop, however. Erm, that seems to be ia64 specific, and I have no idea what adding a stop bit implies. Can you set even

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jeremy Fitzhardinge
David Rientjes wrote: It is analogous with a sequence point for ia64. But, as you mentioned, it is ia64 specific so your comment about asm volatile constructs not being reordered is always appropriate outside of ia64 specific code but may not apply to ia64 if we ever compiled with

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: Sounds like it's referring to micro-architectural reordering, which is distinct from compiler reordering. In other words, even if you specified -mvolatile-asm-stop I would assume that the compiler could still reorder the asm statements. Am I

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
On Tue, 8 May 2007 14:27:33 -0700 (PDT) David Rientjes wrote: On Tue, 8 May 2007, Jeremy Fitzhardinge wrote: It's probably worth noting that asm volatile (...) doesn't mean what many people think it means: specifically, it *does not* prevent the asm from being reordered with respect to

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
On Tue, 8 May 2007 13:20:31 -0700 (PDT) David Rientjes wrote: On Tue, 8 May 2007, Krzysztof Halasa wrote: Since 'volatile' has two different semantics depending on the context in which it is used, this warning should be appended to include the fact that it is legitimate to use

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread David Rientjes
On Tue, 8 May 2007, Randy Dunlap wrote: It's already there, isn't it? quote from original: The only acceptable uses for volatile are: - in _code_, i.e., for things like the definition of readb() etc, where we use it to force a particular access. - with inline asms - on jiffies,

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Randy Dunlap
David Rientjes wrote: On Tue, 8 May 2007, Randy Dunlap wrote: It's already there, isn't it? quote from original: The only acceptable uses for volatile are: - in _code_, i.e., for things like the definition of readb() etc, where we use it to force a particular access. - with inline asms

Re: [RFC/PATCH] doc: volatile considered evil

2007-05-08 Thread Jonathan Corbet
Randy Dunlap [EMAIL PROTECTED] wrote: Here are some 'volatile' comments from Linus, extracted from several emails in at least 2 threads. If this is close to useful, we can add it to Documentation/. I just took a shot at turning this into something more like a normal document: