Hi!
The atomic_add() assembler for x86 is missing hint for gcc that value of
v->counter is being modified by xaddl instruction and as this variable
is changed only from this asm runtime, some combination of gcc
optimalizations allows for this value to be placed in binary .rodata
section resulting in realtime tests segfaulting when trying to do
atomic_add(). It's reproducible on SLES11 (gcc 4.3.2) with -O2.

Patch attached.

Signed-off-by: Cyril Hrubis [email protected]

-- 
Cyril Hrubis
[email protected]
diff --git a/testcases/realtime/include/librttest.h b/testcases/realtime/include/librttest.h
index e526ab4..cddc399 100644
--- a/testcases/realtime/include/librttest.h
+++ b/testcases/realtime/include/librttest.h
@@ -119,7 +119,7 @@ static inline int atomic_add(int i, atomic_t *v)
 	__i = i;
 	asm volatile(
 			"lock; xaddl %0, %1;"
-			:"=r"(i)
+			:"=r"(i), "+m" (v->counter)
 			:"m"(v->counter), "0"(i));
 	return i + __i;
 #elif defined(__powerpc__)
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to