diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-01-31 15:58:39 -0500 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-02-23 12:03:16 -0500 |
commit | 57a2fe90fcdaa812ac1aa6c91ba0e591c30f461a (patch) | |
tree | d8ccc4801bb561a55c0c31ab480f754c6ca4b3da /kernel/torture.c | |
parent | 628edaa5062282b6e3d76c886fd2cbccae5cb87b (diff) |
rcutorture: Apply ACCESS_ONCE() to racy fullstop accesses
Because the fullstop variable can be accessed while it is being updated,
this commit avoids any resulting compiler mischief through use of
ACCESS_ONCE() for non-initialization accesses to this shared variable.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel/torture.c')
-rw-r--r-- | kernel/torture.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kernel/torture.c b/kernel/torture.c index b30c2ee78580..1bafd02d1eed 100644 --- a/kernel/torture.c +++ b/kernel/torture.c | |||
@@ -439,9 +439,9 @@ static int torture_shutdown_notify(struct notifier_block *unused1, | |||
439 | unsigned long unused2, void *unused3) | 439 | unsigned long unused2, void *unused3) |
440 | { | 440 | { |
441 | mutex_lock(&fullstop_mutex); | 441 | mutex_lock(&fullstop_mutex); |
442 | if (fullstop == FULLSTOP_DONTSTOP) { | 442 | if (ACCESS_ONCE(fullstop) == FULLSTOP_DONTSTOP) { |
443 | VERBOSE_TOROUT_STRING("Unscheduled system shutdown detected"); | 443 | VERBOSE_TOROUT_STRING("Unscheduled system shutdown detected"); |
444 | fullstop = FULLSTOP_SHUTDOWN; | 444 | ACCESS_ONCE(fullstop) = FULLSTOP_SHUTDOWN; |
445 | } else { | 445 | } else { |
446 | pr_warn("Concurrent rmmod and shutdown illegal!\n"); | 446 | pr_warn("Concurrent rmmod and shutdown illegal!\n"); |
447 | } | 447 | } |
@@ -575,13 +575,13 @@ EXPORT_SYMBOL_GPL(torture_init_end); | |||
575 | bool torture_cleanup(void) | 575 | bool torture_cleanup(void) |
576 | { | 576 | { |
577 | mutex_lock(&fullstop_mutex); | 577 | mutex_lock(&fullstop_mutex); |
578 | if (fullstop == FULLSTOP_SHUTDOWN) { | 578 | if (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) { |
579 | pr_warn("Concurrent rmmod and shutdown illegal!\n"); | 579 | pr_warn("Concurrent rmmod and shutdown illegal!\n"); |
580 | mutex_unlock(&fullstop_mutex); | 580 | mutex_unlock(&fullstop_mutex); |
581 | schedule_timeout_uninterruptible(10); | 581 | schedule_timeout_uninterruptible(10); |
582 | return true; | 582 | return true; |
583 | } | 583 | } |
584 | fullstop = FULLSTOP_RMMOD; | 584 | ACCESS_ONCE(fullstop) = FULLSTOP_RMMOD; |
585 | mutex_unlock(&fullstop_mutex); | 585 | mutex_unlock(&fullstop_mutex); |
586 | unregister_reboot_notifier(&torture_shutdown_nb); | 586 | unregister_reboot_notifier(&torture_shutdown_nb); |
587 | torture_shuffle_cleanup(); | 587 | torture_shuffle_cleanup(); |
@@ -605,6 +605,6 @@ EXPORT_SYMBOL_GPL(torture_must_stop); | |||
605 | */ | 605 | */ |
606 | bool torture_must_stop_irq(void) | 606 | bool torture_must_stop_irq(void) |
607 | { | 607 | { |
608 | return fullstop != FULLSTOP_DONTSTOP; | 608 | return ACCESS_ONCE(fullstop) != FULLSTOP_DONTSTOP; |
609 | } | 609 | } |
610 | EXPORT_SYMBOL_GPL(torture_must_stop_irq); | 610 | EXPORT_SYMBOL_GPL(torture_must_stop_irq); |