Skip to content

Commit bdf2a43

Browse files
committed
rcu: Catch rcutorture up to new RCU API additions
Now that the RCU API contains synchronize_rcu_bh(), synchronize_sched(), call_rcu_sched(), and rcu_bh_expedited()... Make rcutorture test synchronize_rcu_bh(), getting rid of the old rcu_bh_torture_synchronize() workaround. Similarly, make rcutorture test synchronize_sched(), getting rid of the old sched_torture_synchronize() workaround. Make rcutorture test call_rcu_sched() instead of wrappering synchronize_sched(). Also add testing of rcu_bh_expedited(). Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
1 parent 2c42818 commit bdf2a43

2 files changed

Lines changed: 24 additions & 34 deletions

File tree

‎Documentation/RCU/torture.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ torture_type The type of RCU to test, with string values as follows:
122122
"rcu_bh_sync": rcu_read_lock_bh(), rcu_read_unlock_bh(),
123123
and synchronize_rcu_bh().
124124

125+
"rcu_bh_expedited": rcu_read_lock_bh(), rcu_read_unlock_bh(),
126+
and synchronize_rcu_bh_expedited().
127+
125128
"srcu": srcu_read_lock(), srcu_read_unlock() and
126129
synchronize_srcu().
127130

‎kernel/rcutorture.c‎

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -480,30 +480,6 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
480480
call_rcu_bh(&p->rtort_rcu, rcu_torture_cb);
481481
}
482482

483-
struct rcu_bh_torture_synchronize {
484-
struct rcu_head head;
485-
struct completion completion;
486-
};
487-
488-
static void rcu_bh_torture_wakeme_after_cb(struct rcu_head *head)
489-
{
490-
struct rcu_bh_torture_synchronize *rcu;
491-
492-
rcu = container_of(head, struct rcu_bh_torture_synchronize, head);
493-
complete(&rcu->completion);
494-
}
495-
496-
static void rcu_bh_torture_synchronize(void)
497-
{
498-
struct rcu_bh_torture_synchronize rcu;
499-
500-
init_rcu_head_on_stack(&rcu.head);
501-
init_completion(&rcu.completion);
502-
call_rcu_bh(&rcu.head, rcu_bh_torture_wakeme_after_cb);
503-
wait_for_completion(&rcu.completion);
504-
destroy_rcu_head_on_stack(&rcu.head);
505-
}
506-
507483
static struct rcu_torture_ops rcu_bh_ops = {
508484
.init = NULL,
509485
.cleanup = NULL,
@@ -512,7 +488,7 @@ static struct rcu_torture_ops rcu_bh_ops = {
512488
.readunlock = rcu_bh_torture_read_unlock,
513489
.completed = rcu_bh_torture_completed,
514490
.deferred_free = rcu_bh_torture_deferred_free,
515-
.sync = rcu_bh_torture_synchronize,
491+
.sync = synchronize_rcu_bh,
516492
.cb_barrier = rcu_barrier_bh,
517493
.fqs = rcu_bh_force_quiescent_state,
518494
.stats = NULL,
@@ -528,14 +504,30 @@ static struct rcu_torture_ops rcu_bh_sync_ops = {
528504
.readunlock = rcu_bh_torture_read_unlock,
529505
.completed = rcu_bh_torture_completed,
530506
.deferred_free = rcu_sync_torture_deferred_free,
531-
.sync = rcu_bh_torture_synchronize,
507+
.sync = synchronize_rcu_bh,
532508
.cb_barrier = NULL,
533509
.fqs = rcu_bh_force_quiescent_state,
534510
.stats = NULL,
535511
.irq_capable = 1,
536512
.name = "rcu_bh_sync"
537513
};
538514

515+
static struct rcu_torture_ops rcu_bh_expedited_ops = {
516+
.init = rcu_sync_torture_init,
517+
.cleanup = NULL,
518+
.readlock = rcu_bh_torture_read_lock,
519+
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
520+
.readunlock = rcu_bh_torture_read_unlock,
521+
.completed = rcu_bh_torture_completed,
522+
.deferred_free = rcu_sync_torture_deferred_free,
523+
.sync = synchronize_rcu_bh_expedited,
524+
.cb_barrier = NULL,
525+
.fqs = rcu_bh_force_quiescent_state,
526+
.stats = NULL,
527+
.irq_capable = 1,
528+
.name = "rcu_bh_expedited"
529+
};
530+
539531
/*
540532
* Definitions for srcu torture testing.
541533
*/
@@ -659,11 +651,6 @@ static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
659651
call_rcu_sched(&p->rtort_rcu, rcu_torture_cb);
660652
}
661653

662-
static void sched_torture_synchronize(void)
663-
{
664-
synchronize_sched();
665-
}
666-
667654
static struct rcu_torture_ops sched_ops = {
668655
.init = rcu_sync_torture_init,
669656
.cleanup = NULL,
@@ -672,7 +659,7 @@ static struct rcu_torture_ops sched_ops = {
672659
.readunlock = sched_torture_read_unlock,
673660
.completed = rcu_no_completed,
674661
.deferred_free = rcu_sched_torture_deferred_free,
675-
.sync = sched_torture_synchronize,
662+
.sync = synchronize_sched,
676663
.cb_barrier = rcu_barrier_sched,
677664
.fqs = rcu_sched_force_quiescent_state,
678665
.stats = NULL,
@@ -688,7 +675,7 @@ static struct rcu_torture_ops sched_sync_ops = {
688675
.readunlock = sched_torture_read_unlock,
689676
.completed = rcu_no_completed,
690677
.deferred_free = rcu_sync_torture_deferred_free,
691-
.sync = sched_torture_synchronize,
678+
.sync = synchronize_sched,
692679
.cb_barrier = NULL,
693680
.fqs = rcu_sched_force_quiescent_state,
694681
.stats = NULL,
@@ -1425,7 +1412,7 @@ rcu_torture_init(void)
14251412
int firsterr = 0;
14261413
static struct rcu_torture_ops *torture_ops[] =
14271414
{ &rcu_ops, &rcu_sync_ops, &rcu_expedited_ops,
1428-
&rcu_bh_ops, &rcu_bh_sync_ops,
1415+
&rcu_bh_ops, &rcu_bh_sync_ops, &rcu_bh_expedited_ops,
14291416
&srcu_ops, &srcu_expedited_ops,
14301417
&sched_ops, &sched_sync_ops, &sched_expedited_ops, };
14311418

0 commit comments

Comments
 (0)