Re: [PATCH] cpufreq, store_scaling_governor requires policy->rwsem to be held for duration of changing governors [v2]
From: Saravana Kannan
Date: Mon Aug 04 2014 - 16:16:45 EST
On 08/04/2014 06:38 AM, Viresh Kumar wrote:
On 4 August 2014 17:55, Prarit Bhargava <prarit@xxxxxxxxxx> wrote:
The issue is the collision between the setup & teardown of the policy's governor
sysfs files.
On creation the kernel does:
down_write(&policy->rwsem)
mutex_lock(kernfs_mutex) <- note this is similar to the "old" sysfs_mutex.
The opposite happens on a governor switch, specifically the existing governor's
exit, and then we get a lockdep warning.
Okay, probably a bit more clarity is what I was looking for. Suppose we try
to change governor, now tell me what will happen.
Viresh, I have a good understanding of what's going on. I was planning
to fix this after the rest of my patches are done. Didn't want to keep
too many outstanding unaccepted patches.
The problem is when between one thread trying to cat a governor's file
(say, sampling_rate) vs the governor getting a POLICY_EXIT.
In the read thread, the sysfs lock is grabbed first and then the policy
lock is grabbed next. When the governor gets the POLICY_EXIT, we call it
with the policy lock held and the governor tries to do sysfs remove
which tries to grab the sysfs lock. Classic deadlock.
Could you please look at my policy free/remove patches? If you can do
that, I can work on a fix for this. It might also be simpler to fix
after my patch series (not sure, might be).
Thanks,
Saravana
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/