• Rafael J. Wysocki's avatar
    cpufreq: stats: Add memory barrier to store_reset() · efad4240
    Rafael J. Wysocki authored
    There is nothing to prevent the CPU or the compiler from reordering
    the writes to stats->reset_time and stats->reset_pending in
    store_reset(), in which case the readers of stats->reset_time may see
    a stale value.  Moreover, on 32-bit arches the write to reset_time
    cannot be completed in one go, so the readers of it may see a
    partially updated value in that case.
    
    To prevent that from happening, add a write memory barrier between
    the writes to stats->reset_time and stats->reset_pending in
    store_reset() and corresponding read memory barrier in the
    readers of stats->reset_time.
    
    Fixes: 40c3bd4c ("cpufreq: stats: Defer stats update to cpufreq_stats_record_transition()")
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
    efad4240
cpufreq_stats.c 7.11 KB