> @@ -168,8 +168,13 @@ int __read_mostly timekeeping_suspended;
> static struct timespec xtime_cache __attribute__ ((aligned (16)));
> void update_xtime_cache(u64 nsec)
> {
> - xtime_cache = xtime;
> - timespec_add_ns(&xtime_cache, nsec);
> + /*
> + * Use temporary variable so get_seconds() cannot catch
> + * an intermediate xtime_cache.tv_sec value.
> + */
> + struct timespec ts = xtime;
> + timespec_add_ns(&ts, nsec);
There's nothing to stop the compiler's optimizer to use memory accesses
directly again. Something similar to ACCESS_ONCE (that is essentially a
volatile cast) may be required to be fully future proof.
-Andi
_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable