Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 57714d5b1778f2f610bcc5c74d85b29ba1cc1995
- Author: Viresh Kumar <viresh.kumar@linaro.org>
- Date: Wed Jan 21 11:31:39 2015 +0530
- cpufreq: Access governor's sysfs attributes without 'policy->rwsem'
- Commit 955ef4833574 ("cpufreq: Drop rwsem lock around CPUFREQ_GOV_POLICY_EXIT")
- dropped policy->rwsem because of some ABBA deadlocks.
- We weren't clear about the reasoning behind the deadlocks earlier and so dropped
- the locks before calling CPUFREQ_GOV_POLICY_EXIT.
- The actual problem was:
- If we hold any locks, that the attribute operations grab, when removing the
- attribute, then it can result in a ABBA deadlock.
- show()/store() holds the policy->rwsem lock while accessing any sysfs attributes
- under cpu/cpuX/cpufreq/ directory.
- Consider this scenario for drivers with CPUFREQ_HAVE_GOVERNOR_PER_POLICY flag:
- - Access any governor sysfs attribute. This will increment the active-count of
- sysfs attribute and show/store() of cpufreq core will get called. We will try
- to take policy->rwsem lock there, but following happens before that.
- - Another thread tries to change the governor by writing to
- cpuX/cpufreq/scaling_governor. We took policy->rwsem lock from store() and
- called CPUFREQ_GOV_POLICY_EXIT for governor.
- We call sysfs_remove_group() for the governor attributes, but that will wait
- for active-count to become zero.
- Now the first thread is waiting for the policy->rwsem lock and the next one for
- zero active-count.
- Perfect ABBA deadlock.
- Proposed solution: Accessing govenors attributes doesn't require policy->rwsem
- lock and so avoid it.
- - There are two code paths while accessing governor sysfs attributes.
- - Gov-per-policy: show/store() routines are called.
- - Common-gov: governor show/store routines called directly. In this case the
- governor might be getting used for multiple policies and so we couldn't take
- policy->rwsem lock there.
- So we need to avoid the locks only for the first case.
- This patch adds another field 'skip_lock' to 'struct freq_attr' and is set only
- for the governors. When this is set, we don't take policy->rwsem lock in
- show/store() routines.
- Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Add Comment
Please, Sign In to add comment