• Viresh Kumar's avatar
    cpufreq: Call __cpufreq_governor() with policy->rwsem held · 49f18560
    Viresh Kumar authored
    The cpufreq core code is not consistent with respect to invoking
    __cpufreq_governor() under policy->rwsem.
    
    Changing all code to always hold policy->rwsem around
    __cpufreq_governor() invocations will allow us to remove
    cpufreq_governor_lock that is used today because we can't
    guarantee that __cpufreq_governor() isn't executed twice in
    parallel for the same policy.
    
    We should also ensure that policy->rwsem is held across governor
    state changes.
    
    For example, while adding a CPU to the policy in the CPU online path,
    we need to stop the governor, change policy->cpus, start the governor
    and then refresh its limits. The complete sequence must be guaranteed
    to complete without interruptions by concurrent governor state
    updates.  That can be achieved by holding policy->rwsem around those
    sequences of operations.
    
    Also note that after this patch cpufreq_driver->stop_cpu() and
    ->exit() will get called under policy->rwsem which wasn't the case
    earlier. That shouldn't have any side effects, though.
    Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
    Tested-by: default avatarJuri Lelli <juri.lelli@arm.com>
    Tested-by: default avatarShilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
    [ rjw: Changelog ]
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    49f18560
cpufreq.c 65.7 KB