[PATCH 1/1] Workaround to access sysfs cpufreq variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <C.Emde@xxxxxxxxx>

---
 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);

--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux