• Viresh Kumar's avatar
    cpufreq: stats: Defer stats update to cpufreq_stats_record_transition() · 40c3bd4c
    Viresh Kumar authored
    In order to prepare for lock-less stats update, add support to defer any
    updates to it until cpufreq_stats_record_transition() is called.
    
    The stats were updated from two places earlier:
    
    - show_time_in_state(): This can be easily deferred, all we need is to
      calculate the delta duration again in this routine to show the current
      state's time-in-state.
    
    - store_reset(): This is a bit tricky as we need to clear the stats
      here and avoid races with simultaneous call to
      cpufreq_stats_record_transition().
    
    Fix that by deferring the reset of the stats (within the code) to the
    next call to cpufreq_stats_record_transition(), but since we need to
    keep showing the right stats until that time, we capture the reset
    time and account for the time since last time reset was called until
    the time cpufreq_stats_record_transition() update the stats.
    
    User space will continue seeing the stats correctly, everything will
    be 0 after the stats are reset, apart from the time-in-state of the
    current state, until the time a frequency switch happens.
    Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
    [ rjw: Minor changelog edits ]
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    40c3bd4c
cpufreq_stats.c 6.92 KB