diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2012-10-12 13:14:17 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2012-10-27 18:39:20 -0400 |
commit | cda4dc813071e6cb04944c5a140610bd06acd295 (patch) | |
tree | 5f4d9b821167872d986d31bc4d7c7de99793a15e /kernel | |
parent | 55c6659afaa6fd79a3b5a7c2b42bb87e0c11209d (diff) |
rcutorture: Use DEFINE_STATIC_SRCU()
Use DEFINE_STATIC_SRCU() to simplify the rcutorture.c SRCU test code.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/rcutorture.c | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c index aaa7b9f3532a..f4019720ceca 100644 --- a/kernel/rcutorture.c +++ b/kernel/rcutorture.c | |||
@@ -339,7 +339,6 @@ rcu_stutter_wait(char *title) | |||
339 | 339 | ||
340 | struct rcu_torture_ops { | 340 | struct rcu_torture_ops { |
341 | void (*init)(void); | 341 | void (*init)(void); |
342 | void (*cleanup)(void); | ||
343 | int (*readlock)(void); | 342 | int (*readlock)(void); |
344 | void (*read_delay)(struct rcu_random_state *rrsp); | 343 | void (*read_delay)(struct rcu_random_state *rrsp); |
345 | void (*readunlock)(int idx); | 344 | void (*readunlock)(int idx); |
@@ -431,7 +430,6 @@ static void rcu_torture_deferred_free(struct rcu_torture *p) | |||
431 | 430 | ||
432 | static struct rcu_torture_ops rcu_ops = { | 431 | static struct rcu_torture_ops rcu_ops = { |
433 | .init = NULL, | 432 | .init = NULL, |
434 | .cleanup = NULL, | ||
435 | .readlock = rcu_torture_read_lock, | 433 | .readlock = rcu_torture_read_lock, |
436 | .read_delay = rcu_read_delay, | 434 | .read_delay = rcu_read_delay, |
437 | .readunlock = rcu_torture_read_unlock, | 435 | .readunlock = rcu_torture_read_unlock, |
@@ -475,7 +473,6 @@ static void rcu_sync_torture_init(void) | |||
475 | 473 | ||
476 | static struct rcu_torture_ops rcu_sync_ops = { | 474 | static struct rcu_torture_ops rcu_sync_ops = { |
477 | .init = rcu_sync_torture_init, | 475 | .init = rcu_sync_torture_init, |
478 | .cleanup = NULL, | ||
479 | .readlock = rcu_torture_read_lock, | 476 | .readlock = rcu_torture_read_lock, |
480 | .read_delay = rcu_read_delay, | 477 | .read_delay = rcu_read_delay, |
481 | .readunlock = rcu_torture_read_unlock, | 478 | .readunlock = rcu_torture_read_unlock, |
@@ -493,7 +490,6 @@ static struct rcu_torture_ops rcu_sync_ops = { | |||
493 | 490 | ||
494 | static struct rcu_torture_ops rcu_expedited_ops = { | 491 | static struct rcu_torture_ops rcu_expedited_ops = { |
495 | .init = rcu_sync_torture_init, | 492 | .init = rcu_sync_torture_init, |
496 | .cleanup = NULL, | ||
497 | .readlock = rcu_torture_read_lock, | 493 | .readlock = rcu_torture_read_lock, |
498 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 494 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
499 | .readunlock = rcu_torture_read_unlock, | 495 | .readunlock = rcu_torture_read_unlock, |
@@ -536,7 +532,6 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture *p) | |||
536 | 532 | ||
537 | static struct rcu_torture_ops rcu_bh_ops = { | 533 | static struct rcu_torture_ops rcu_bh_ops = { |
538 | .init = NULL, | 534 | .init = NULL, |
539 | .cleanup = NULL, | ||
540 | .readlock = rcu_bh_torture_read_lock, | 535 | .readlock = rcu_bh_torture_read_lock, |
541 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 536 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
542 | .readunlock = rcu_bh_torture_read_unlock, | 537 | .readunlock = rcu_bh_torture_read_unlock, |
@@ -553,7 +548,6 @@ static struct rcu_torture_ops rcu_bh_ops = { | |||
553 | 548 | ||
554 | static struct rcu_torture_ops rcu_bh_sync_ops = { | 549 | static struct rcu_torture_ops rcu_bh_sync_ops = { |
555 | .init = rcu_sync_torture_init, | 550 | .init = rcu_sync_torture_init, |
556 | .cleanup = NULL, | ||
557 | .readlock = rcu_bh_torture_read_lock, | 551 | .readlock = rcu_bh_torture_read_lock, |
558 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 552 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
559 | .readunlock = rcu_bh_torture_read_unlock, | 553 | .readunlock = rcu_bh_torture_read_unlock, |
@@ -570,7 +564,6 @@ static struct rcu_torture_ops rcu_bh_sync_ops = { | |||
570 | 564 | ||
571 | static struct rcu_torture_ops rcu_bh_expedited_ops = { | 565 | static struct rcu_torture_ops rcu_bh_expedited_ops = { |
572 | .init = rcu_sync_torture_init, | 566 | .init = rcu_sync_torture_init, |
573 | .cleanup = NULL, | ||
574 | .readlock = rcu_bh_torture_read_lock, | 567 | .readlock = rcu_bh_torture_read_lock, |
575 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 568 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
576 | .readunlock = rcu_bh_torture_read_unlock, | 569 | .readunlock = rcu_bh_torture_read_unlock, |
@@ -589,19 +582,7 @@ static struct rcu_torture_ops rcu_bh_expedited_ops = { | |||
589 | * Definitions for srcu torture testing. | 582 | * Definitions for srcu torture testing. |
590 | */ | 583 | */ |
591 | 584 | ||
592 | static struct srcu_struct srcu_ctl; | 585 | DEFINE_STATIC_SRCU(srcu_ctl); |
593 | |||
594 | static void srcu_torture_init(void) | ||
595 | { | ||
596 | init_srcu_struct(&srcu_ctl); | ||
597 | rcu_sync_torture_init(); | ||
598 | } | ||
599 | |||
600 | static void srcu_torture_cleanup(void) | ||
601 | { | ||
602 | synchronize_srcu(&srcu_ctl); | ||
603 | cleanup_srcu_struct(&srcu_ctl); | ||
604 | } | ||
605 | 586 | ||
606 | static int srcu_torture_read_lock(void) __acquires(&srcu_ctl) | 587 | static int srcu_torture_read_lock(void) __acquires(&srcu_ctl) |
607 | { | 588 | { |
@@ -672,8 +653,7 @@ static int srcu_torture_stats(char *page) | |||
672 | } | 653 | } |
673 | 654 | ||
674 | static struct rcu_torture_ops srcu_ops = { | 655 | static struct rcu_torture_ops srcu_ops = { |
675 | .init = srcu_torture_init, | 656 | .init = rcu_sync_torture_init, |
676 | .cleanup = srcu_torture_cleanup, | ||
677 | .readlock = srcu_torture_read_lock, | 657 | .readlock = srcu_torture_read_lock, |
678 | .read_delay = srcu_read_delay, | 658 | .read_delay = srcu_read_delay, |
679 | .readunlock = srcu_torture_read_unlock, | 659 | .readunlock = srcu_torture_read_unlock, |
@@ -687,8 +667,7 @@ static struct rcu_torture_ops srcu_ops = { | |||
687 | }; | 667 | }; |
688 | 668 | ||
689 | static struct rcu_torture_ops srcu_sync_ops = { | 669 | static struct rcu_torture_ops srcu_sync_ops = { |
690 | .init = srcu_torture_init, | 670 | .init = rcu_sync_torture_init, |
691 | .cleanup = srcu_torture_cleanup, | ||
692 | .readlock = srcu_torture_read_lock, | 671 | .readlock = srcu_torture_read_lock, |
693 | .read_delay = srcu_read_delay, | 672 | .read_delay = srcu_read_delay, |
694 | .readunlock = srcu_torture_read_unlock, | 673 | .readunlock = srcu_torture_read_unlock, |
@@ -712,8 +691,7 @@ static void srcu_torture_read_unlock_raw(int idx) __releases(&srcu_ctl) | |||
712 | } | 691 | } |
713 | 692 | ||
714 | static struct rcu_torture_ops srcu_raw_ops = { | 693 | static struct rcu_torture_ops srcu_raw_ops = { |
715 | .init = srcu_torture_init, | 694 | .init = rcu_sync_torture_init, |
716 | .cleanup = srcu_torture_cleanup, | ||
717 | .readlock = srcu_torture_read_lock_raw, | 695 | .readlock = srcu_torture_read_lock_raw, |
718 | .read_delay = srcu_read_delay, | 696 | .read_delay = srcu_read_delay, |
719 | .readunlock = srcu_torture_read_unlock_raw, | 697 | .readunlock = srcu_torture_read_unlock_raw, |
@@ -727,8 +705,7 @@ static struct rcu_torture_ops srcu_raw_ops = { | |||
727 | }; | 705 | }; |
728 | 706 | ||
729 | static struct rcu_torture_ops srcu_raw_sync_ops = { | 707 | static struct rcu_torture_ops srcu_raw_sync_ops = { |
730 | .init = srcu_torture_init, | 708 | .init = rcu_sync_torture_init, |
731 | .cleanup = srcu_torture_cleanup, | ||
732 | .readlock = srcu_torture_read_lock_raw, | 709 | .readlock = srcu_torture_read_lock_raw, |
733 | .read_delay = srcu_read_delay, | 710 | .read_delay = srcu_read_delay, |
734 | .readunlock = srcu_torture_read_unlock_raw, | 711 | .readunlock = srcu_torture_read_unlock_raw, |
@@ -747,8 +724,7 @@ static void srcu_torture_synchronize_expedited(void) | |||
747 | } | 724 | } |
748 | 725 | ||
749 | static struct rcu_torture_ops srcu_expedited_ops = { | 726 | static struct rcu_torture_ops srcu_expedited_ops = { |
750 | .init = srcu_torture_init, | 727 | .init = rcu_sync_torture_init, |
751 | .cleanup = srcu_torture_cleanup, | ||
752 | .readlock = srcu_torture_read_lock, | 728 | .readlock = srcu_torture_read_lock, |
753 | .read_delay = srcu_read_delay, | 729 | .read_delay = srcu_read_delay, |
754 | .readunlock = srcu_torture_read_unlock, | 730 | .readunlock = srcu_torture_read_unlock, |
@@ -783,7 +759,6 @@ static void rcu_sched_torture_deferred_free(struct rcu_torture *p) | |||
783 | 759 | ||
784 | static struct rcu_torture_ops sched_ops = { | 760 | static struct rcu_torture_ops sched_ops = { |
785 | .init = rcu_sync_torture_init, | 761 | .init = rcu_sync_torture_init, |
786 | .cleanup = NULL, | ||
787 | .readlock = sched_torture_read_lock, | 762 | .readlock = sched_torture_read_lock, |
788 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 763 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
789 | .readunlock = sched_torture_read_unlock, | 764 | .readunlock = sched_torture_read_unlock, |
@@ -799,7 +774,6 @@ static struct rcu_torture_ops sched_ops = { | |||
799 | 774 | ||
800 | static struct rcu_torture_ops sched_sync_ops = { | 775 | static struct rcu_torture_ops sched_sync_ops = { |
801 | .init = rcu_sync_torture_init, | 776 | .init = rcu_sync_torture_init, |
802 | .cleanup = NULL, | ||
803 | .readlock = sched_torture_read_lock, | 777 | .readlock = sched_torture_read_lock, |
804 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 778 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
805 | .readunlock = sched_torture_read_unlock, | 779 | .readunlock = sched_torture_read_unlock, |
@@ -814,7 +788,6 @@ static struct rcu_torture_ops sched_sync_ops = { | |||
814 | 788 | ||
815 | static struct rcu_torture_ops sched_expedited_ops = { | 789 | static struct rcu_torture_ops sched_expedited_ops = { |
816 | .init = rcu_sync_torture_init, | 790 | .init = rcu_sync_torture_init, |
817 | .cleanup = NULL, | ||
818 | .readlock = sched_torture_read_lock, | 791 | .readlock = sched_torture_read_lock, |
819 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 792 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
820 | .readunlock = sched_torture_read_unlock, | 793 | .readunlock = sched_torture_read_unlock, |
@@ -1936,8 +1909,6 @@ rcu_torture_cleanup(void) | |||
1936 | 1909 | ||
1937 | rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ | 1910 | rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ |
1938 | 1911 | ||
1939 | if (cur_ops->cleanup) | ||
1940 | cur_ops->cleanup(); | ||
1941 | if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error) | 1912 | if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error) |
1942 | rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE"); | 1913 | rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE"); |
1943 | else if (n_online_successes != n_online_attempts || | 1914 | else if (n_online_successes != n_online_attempts || |