D.1.2.3 Update-Side Primitives

The synchronize_srcu() primitives may be used as shown below:



 1 list_del_rcu(p);
 2 synchronize_srcu(&ss);
 3 kfree(p);


As one might expect by analogy with Classic RCU, this primitive blocks until until after the completion of all SRCU read-side critical sections that started before the synchronize_srcu() started, as shown in Table [*]. Here, CPU 1 need only wait for the completion of CPU 0's SRCU read-side critical section. It need not wait for the completion of CPU 2's SRCU read-side critical section, because CPU 2 did not start this critical section until after CPU 1 began executing synchronize_srcu(). Finally, CPU 1's synchronize_srcu() need not wait for CPU 3's SRCU read-side critical section, because CPU 3 is using s2 rather than s1 as its struct srcu_struct. CPU 3's SRCU read-side critical section is thus related to a different set of grace periods than those of CPUs 0 and 2.


Table: SRCU Update and Read-Side Critical Sections
CPU 0 CPU 1 CPU 2 CPU 3
1 i0 = srcu_read_lock( s1)
2 synchronize_srcu( s1) enter
3 i2 = srcu_read_lock( s1)
4 srcu_read_unlock( s1, i0)
5 synchronize_srcu( s1) exit
6 srcu_read_unlock( s1, i2)


The srcu_batches_completed() primitive may be used to monitor the progress of a given struct srcu_struct's grace periods. This primitive is used in ``torture tests'' that validate SRCU's operation.

Paul E. McKenney 2011-12-16