• Viresh Kumar's avatar
    cpufreq: governor: Create and traverse list of policy_dbs to avoid deadlock · c54df071
    Viresh Kumar authored
    The dbs_data_mutex lock is currently used in two places.  First,
    cpufreq_governor_dbs() uses it to guarantee mutual exclusion between
    invocations of governor operations from the core.  Second, it is used by
    ondemand governor's update_sampling_rate() to ensure the stability of
    data structures walked by it.
    
    The second usage is quite problematic, because update_sampling_rate() is
    called from a governor sysfs attribute's ->store callback and that leads
    to a deadlock scenario involving cpufreq_governor_exit() which runs
    under dbs_data_mutex.  Thus it is better to rework the code so
    update_sampling_rate() doesn't need to acquire dbs_data_mutex.
    
    To that end, rework update_sampling_rate() to walk a list of policy_dbs
    objects supported by the dbs_data one it has been called for (instead of
    walking cpu_dbs_info object for all CPUs).  The list manipulation is
    protected with dbs_data->mutex which also is held around the execution
    of update_sampling_rate(), it is not necessary to hold dbs_data_mutex in
    that function any more.
    Reported-by: default avatarJuri Lelli <juri.lelli@arm.com>
    Reported-by: default avatarShilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
    Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
    [ rjw: Subject & changelog ]
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    c54df071
cpufreq_governor.c 16.5 KB