asm-i386/atomic.h: local_irq_save should be used instead of local_irq_disable
PATCH 1/1 asm-i386/atomic.h: local_irq_save should be used instead of local_irq_disable
Hi!
When I read the kernel codes, I think this perhaps be a little bug, What do you think about this?
See the following patch (against 2.6.16.3)
include/asm-i386/atomic.h +3 -2
@@ -189,6 +189,7 @@ static __inline__ int atomic_add_return( {int __i;#ifdef CONFIG_M386 +unsigned long flags;if (unlikely (boot_cpu_data.x86==3 )) goto no_xadd;#endif
@@ -202,10 +203,10 @@ static __inline__ int atomic_add_return(#ifdef CONFIG_M386 no_xadd:/* Legacy 386 processor */ -local_irq_disable (); +local_irq_save (flags); __i =atomic_read (v);atomic_set (v, i + __i); -local_irq_enable (); +local_irq_restore (flags);return i + __i;#endif }
Quoted 30 lines · lepton
Hi!
When I read the kernel codes, I think this perhaps be a little bug, What do you think about this?See the following patch (against 2.6.16.3)
Signed-off-by Lepton Wu <[email protected]>diff -pru
linux-2.6-curr.orig/include/asm-i386/atomic.hlinux-2.6-curr.lepton/include/asm-i386/atomic.hinclude/asm-i386/atomic.h +1
-0@@ -189,6 +189,7 @@ static __inline__ int atomic_add_return( {int __i;#ifdef CONFIG_M386 +unsigned long flags;if (unlikely (boot_cpu_data.x86==3 )) goto no_xadd;#endif @@ -202,10 +203,10 @@ static __inline__ int atomic_add_return(#ifdef CONFIG_M386
no_xadd: /* Legacy 386 processor */include/asm-i386/atomic.h +1
-1-local_irq_disable (); +local_irq_save (flags);__i = atomic_read(v); atomic_set(v, i + __i);include/asm-i386/atomic.h +1
-1-local_irq_enable (); +local_irq_restore (flags);return i + __i;
Quoted 2 lines
#endif
}
You need to disable interrupts on the local CPU! So, you would need to save the flags, disable the interrupts, then restore the flags after the atomic operations.
Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.42 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _
****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.
Thank you.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · lepton
I think irq is disbaled in
local_irq_save, am I right?/* For spinlocks etc */
#definelocal_irq_save(x)__asm____volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
Yes, with the CLI in the code. The macro-name was not correct and implied only a save of the flags..
Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.42 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _
****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.
Thank you.