Skip to contentSkip to conversation

Add full memory fence for test_and_*_bit operation

PATCH Chen, Kenneth W 2 participants 2 messages Mar 29, 2006

lore
Share & tools
lore
#0 lore raw

OK, semi-big-hammer to enforce full memory fence on ia64 for test_and_set_bit
test_and_clear_bit
test_and_change_bit

It's sad we don't have something like:

test_and_set_bit_used_like_a_lock
test_and_set_bit_used_like_an_unlock
test_and_set_bit_full_memory_fence
test_and_clear_bit_used_like_a_lock
test_and_clear_bit_used_like_an_unlock
test_and_clear_bit_full_memory_fence
test_and_change_bit_used_like_a_lock
test_and_change_bit_used_like_an_unlock
test_and_change_bit_full_memory_fence

- Ken

include/asm-ia64/bitops.h renamed from include/asm-ia64/bitops.h.orig +3 -3
@@ -166,7 +166,7 @@ test_and_set_bit (int nr, volatile void 
 		CMPXCHG_BUGCHECK(m);
 		old = *m;
 		new = old | bit;
-	} while (cmpxchg_acq(m, old, new) != old);
+	} while (cmpxchg_rel(m, old, new) != old);
 	return (old & bit) != 0;
 }
 
@@ -211,7 +211,7 @@ test_and_clear_bit (int nr, volatile voi
 		CMPXCHG_BUGCHECK(m);
 		old = *m;
 		new = old & mask;
-	} while (cmpxchg_acq(m, old, new) != old);
+	} while (cmpxchg_rel(m, old, new) != old);
 	return (old & ~mask) != 0;
 }
 
@@ -256,7 +256,7 @@ test_and_change_bit (int nr, volatile vo
 		CMPXCHG_BUGCHECK(m);
 		old = *m;
 		new = old ^ bit;
-	} while (cmpxchg_acq(m, old, new) != old);
+	} while (cmpxchg_rel(m, old, new) != old);
 	return (old & bit) != 0;
 }
 
#1 lore raw
Quoted 8 lines · Kenneth W

OK, semi-big-hammer to enforce full memory fence on ia64 for test_and_set_bit
test_and_clear_bit
test_and_change_bit

It's sad we don't have something like:

test_and_set_bit_used_like_a_lock

...

Normally the arch specific (e.g. __set_bit or __raw_readl) provide different semantics than the "portable" versions (e.g set_bit and readl). Can folks who know what they are doing can use arch specific versions at the expense of portability?

I expect the driver to compile and work correctly on all arches, it will just be a bit more of a PITA to maintain.

grant