[PATCH 1/1] Workaround to access sysfs cpufreq variables
From: Carsten Emde <hidden>
Date: 2015-02-16 15:53:11
Any attempt to write to one of the sysfs cpufreq variables results in a write error such as # echo performance >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor -bash: echo: write error: Invalid argument that is caused by lock contention. This patch is not a solution but a workaround to demonstrate the situation. Signed-off-by: Carsten Emde <redacted> --- drivers/cpufreq/cpufreq.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) Index: linux-3.18.7-rt1/drivers/cpufreq/cpufreq.c ===================================================================
--- linux-3.18.7-rt1.orig/drivers/cpufreq/cpufreq.c
+++ linux-3.18.7-rt1/drivers/cpufreq/cpufreq.c@@ -205,8 +205,16 @@ struct cpufreq_policy *cpufreq_cpu_get(u if (cpufreq_disabled() || (cpu >= nr_cpu_ids)) return NULL; - if (!down_read_trylock(&cpufreq_rwsem)) - return NULL; + if (!down_read_trylock(&cpufreq_rwsem)) { + struct rt_mutex *rtm = &cpufreq_rwsem.lock; + struct task_struct *owner = rtm->owner; + if (owner->pid != current->pid) { + printk(KERN_INFO + "%s: owner->pid %d (%s), current->pid %d\n", + __func__, owner->pid, owner->comm, current->pid); + return NULL; + } + } /* get the cpufreq driver */ read_lock_irqsave(&cpufreq_driver_lock, flags);