Documentation/litmus-tests/rcu/RCU+sync+free.litmus

Source file repositories/reference/linux-study-clean/Documentation/litmus-tests/rcu/RCU+sync+free.litmus

File Facts

System
Linux kernel
Corpus path
Documentation/litmus-tests/rcu/RCU+sync+free.litmus
Extension
.litmus
Size
892 bytes
Lines
43
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: Documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

C RCU+sync+free

(*
 * Result: Never
 *
 * This litmus test demonstrates that an RCU reader can never see a write that
 * follows a grace period, if it did not see writes that precede that grace
 * period.
 *
 * This is a typical pattern of RCU usage, where the write before the grace
 * period assigns a pointer, and the writes following the grace period destroy
 * the object that the pointer used to point to.
 *
 * This is one implication of the RCU grace-period guarantee, which says (among
 * other things) that an RCU read-side critical section cannot span a grace period.
 *)

{
int x = 1;
int *y = &x;
int z = 1;
}

P0(int *x, int *z, int **y)
{
	int *r0;
	int r1;

	rcu_read_lock();
	r0 = rcu_dereference(*y);
	r1 = READ_ONCE(*r0);
	rcu_read_unlock();
}

P1(int *x, int *z, int **y)
{
	rcu_assign_pointer(*y, z);
	synchronize_rcu();
	WRITE_ONCE(*x, 0);
}

exists (0:r0=x /\ 0:r1=0)

Annotation

Implementation Notes