Messages in this thread | | | From | (Davide Libenzi) | Subject | Re: (*(unsigned long *)&jiffies)++; | Date | Thu, 6 Jan 2000 20:23:30 +0100 |
| |
On Thu, 06 Jan 2000, Richard B. Johnson wrote: > 1 movl foo,%eax ! Get it > 2 leal 1(%eax),%edx ! bump it by one > 3 movl %edx,foo ! write it back > 4 movl foo,%eax ! Then do something dumb > 5 movl foo,%edx ! Then do something dumb again > 6 pushl %edx > 7 pushl $.LC0 > 8 call printf > 9 addl $8,%esp
This is the correct behaviour the code must follow. Even if it has just stored the value in foo ( 3 ) and even it can think that the value is %edx is the last one, the volatile keyword force a reload in 5. The step 4 is not clear for me ! IMVHO doing a jiffies++ or (*(unsigned long *)&jiffies)++ is exactly the same thing in this case. I mean that :
incl jiffies
or
movl jiffies, %eax incl %eax movl %eax, jiffies
does not introduce worse issues in SMP. Sure the volatile keyword avoid the compiler to optimize :
movl jiffies, %eax incl %eax
...
movl %eax, jiffies
As a general rule I suggest to introduce any tricks that can solve speed or code optimization issues where there's the need, avoiding them in caseless situations.
Cheers, Davide.
-- "Debian, the freedom in freedom."
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |