xref: /kernel/linux/linux-6.6/tools/memory-model/litmus-tests/SB+fencembonceonces.litmus (revision 62306a36)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-6.6/tools/memory-model/litmus-tests/
162306a36Sopenharmony_ciC SB+fencembonceonces
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci(*
462306a36Sopenharmony_ci * Result: Never
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * This litmus test demonstrates that full memory barriers suffice to
762306a36Sopenharmony_ci * order the store-buffering pattern, where each process writes to the
862306a36Sopenharmony_ci * variable that the preceding process reads.  (Locking and RCU can also
962306a36Sopenharmony_ci * suffice, but not much else.)
1062306a36Sopenharmony_ci *)
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci{}
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciP0(int *x, int *y)
1562306a36Sopenharmony_ci{
1662306a36Sopenharmony_ci	int r0;
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci	WRITE_ONCE(*x, 1);
1962306a36Sopenharmony_ci	smp_mb();
2062306a36Sopenharmony_ci	r0 = READ_ONCE(*y);
2162306a36Sopenharmony_ci}
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciP1(int *x, int *y)
2462306a36Sopenharmony_ci{
2562306a36Sopenharmony_ci	int r0;
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci	WRITE_ONCE(*y, 1);
2862306a36Sopenharmony_ci	smp_mb();
2962306a36Sopenharmony_ci	r0 = READ_ONCE(*x);
3062306a36Sopenharmony_ci}
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ciexists (0:r0=0 /\ 1:r0=0)
33

Indexes created Thu Nov 07 10:32:03 CST 2024