1 C cmpxchg-fail-ordered-1 1 C cmpxchg-fail-ordered-1 2 2 3 (* 3 (* 4 * Result: Never 4 * Result: Never 5 * 5 * 6 * Demonstrate that a failing cmpxchg() operat 6 * Demonstrate that a failing cmpxchg() operation will act as a full 7 * barrier when followed by smp_mb__after_atom 7 * barrier when followed by smp_mb__after_atomic(). 8 *) 8 *) 9 9 10 {} 10 {} 11 11 12 P0(int *x, int *y, int *z) 12 P0(int *x, int *y, int *z) 13 { 13 { 14 int r0; 14 int r0; 15 int r1; 15 int r1; 16 16 17 WRITE_ONCE(*x, 1); 17 WRITE_ONCE(*x, 1); 18 r1 = cmpxchg(z, 1, 0); 18 r1 = cmpxchg(z, 1, 0); 19 smp_mb__after_atomic(); 19 smp_mb__after_atomic(); 20 r0 = READ_ONCE(*y); 20 r0 = READ_ONCE(*y); 21 } 21 } 22 22 23 P1(int *x, int *y, int *z) 23 P1(int *x, int *y, int *z) 24 { 24 { 25 int r0; 25 int r0; 26 int r1; 26 int r1; 27 27 28 WRITE_ONCE(*y, 1); 28 WRITE_ONCE(*y, 1); 29 r1 = cmpxchg(z, 1, 0); 29 r1 = cmpxchg(z, 1, 0); 30 smp_mb__after_atomic(); 30 smp_mb__after_atomic(); 31 r0 = READ_ONCE(*x); 31 r0 = READ_ONCE(*x); 32 } 32 } 33 33 34 locations[0:r1;1:r1] 34 locations[0:r1;1:r1] 35 exists (0:r0=0 /\ 1:r0=0) 35 exists (0:r0=0 /\ 1:r0=0)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.