@@ -58,8 +58,9 @@ static void tick_do_update_jiffies64(ktime_t now)
58
58
59
59
/*
60
60
* Do a quick check without holding jiffies_lock:
61
+ * The READ_ONCE() pairs with two updates done later in this function.
61
62
*/
62
- delta = ktime_sub (now , last_jiffies_update );
63
+ delta = ktime_sub (now , READ_ONCE ( last_jiffies_update ) );
63
64
if (delta < tick_period )
64
65
return ;
65
66
@@ -70,17 +71,20 @@ static void tick_do_update_jiffies64(ktime_t now)
70
71
if (delta >= tick_period ) {
71
72
72
73
delta = ktime_sub (delta , tick_period );
73
- last_jiffies_update = ktime_add (last_jiffies_update ,
74
- tick_period );
74
+ /* Pairs with the lockless read in this function. */
75
+ WRITE_ONCE (last_jiffies_update ,
76
+ ktime_add (last_jiffies_update , tick_period ));
75
77
76
78
/* Slow path for long timeouts */
77
79
if (unlikely (delta >= tick_period )) {
78
80
s64 incr = ktime_to_ns (tick_period );
79
81
80
82
ticks = ktime_divns (delta , incr );
81
83
82
- last_jiffies_update = ktime_add_ns (last_jiffies_update ,
83
- incr * ticks );
84
+ /* Pairs with the lockless read in this function. */
85
+ WRITE_ONCE (last_jiffies_update ,
86
+ ktime_add_ns (last_jiffies_update ,
87
+ incr * ticks ));
84
88
}
85
89
do_timer (++ ticks );
86
90
0 commit comments