Skip to content

Commit

Permalink
rcu: Mark accesses to boost_starttime
Browse files Browse the repository at this point in the history
The boost_starttime shared variable has conflicting unmarked C-language
accesses, which are dangerous at best.  This commit therefore adds
appropriate marking.  This was found by KCSAN.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
  • Loading branch information
Paul E. McKenney committed Feb 2, 2022
1 parent da12301 commit a47f9f1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kernel/rcu/rcutorture.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ static int rcu_torture_boost(void *arg)
goto checkwait;

/* Wait for the next test interval. */
oldstarttime = boost_starttime;
oldstarttime = READ_ONCE(boost_starttime);
while (time_before(jiffies, oldstarttime)) {
schedule_timeout_interruptible(oldstarttime - jiffies);
if (stutter_wait("rcu_torture_boost"))
Expand Down Expand Up @@ -1041,10 +1041,11 @@ static int rcu_torture_boost(void *arg)
* interval. Besides, we are running at RT priority,
* so delays should be relatively rare.
*/
while (oldstarttime == boost_starttime && !kthread_should_stop()) {
while (oldstarttime == READ_ONCE(boost_starttime) && !kthread_should_stop()) {
if (mutex_trylock(&boost_mutex)) {
if (oldstarttime == boost_starttime) {
boost_starttime = jiffies + test_boost_interval * HZ;
WRITE_ONCE(boost_starttime,
jiffies + test_boost_interval * HZ);
n_rcu_torture_boosts++;
}
mutex_unlock(&boost_mutex);
Expand Down

0 comments on commit a47f9f1

Please sign in to comment.