Skip to content
Commit c9e2fbd9 authored by Alexander Chumachenko's avatar Alexander Chumachenko Committed by H. Peter Anvin
Browse files

x86: Avoid 'constant_test_bit()' misoptimization due to cast to non-volatile



While debugging bit_spin_lock() hang, it was tracked down to gcc-4.4
misoptimization of non-inlined constant_test_bit() due to non-volatile
addr when 'const volatile unsigned long *addr' cast to 'unsigned long *'
with subsequent unconditional jump to pause (and not to the test) leading
to hang.

Compiling with gcc-4.3 or disabling CONFIG_OPTIMIZE_INLINING yields inlined
constant_test_bit() and correct jump, thus working around the kernel bug.

Other arches than asm-x86 may implement this slightly differently;
2.6.29 mitigates the misoptimization by changing the function prototype
(commit c4295fbb) but probably fixing the issue
itself is better.

Signed-off-by: default avatarAlexander Chumachenko <ledest@gmail.com>
Signed-off-by: default avatarMichael Shigorin <mike@osdn.org.ua>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent 7329cf02
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment