Skip to contentSkip to conversation

Cpufreq: Acquire read lock in the cpufreq_policy_restore() rather than write lock

PATCH Applied [email protected] 4 participants 4 messages Sep 11, 2013 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cpufreq: Acquire read lock in the cpufreq_policy_restore() rather than write lock

From: Lan Tianyu <[email protected]>

In the cpufreq_policy_restore(), policy before system suspend is read from from percpu's cpufreq_cpu_data_fallback. It's read operation rather than write operation. So convert write lock to read lock

---
 drivers/cpufreq/cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +2 -2
index 81ceea6..b762f9b 100644
@@ -912,11 +912,11 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu)
 	struct cpufreq_policy *policy;
 	unsigned long flags;
 
-	write_lock_irqsave(&cpufreq_driver_lock, flags);
+	read_lock_irqsave(&cpufreq_driver_lock, flags);
 
 	policy = per_cpu(cpufreq_cpu_data_fallback, cpu);
 
-	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+	read_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
 	return policy;
 }
Signature · 1 line
1.8.4.rc0.1.g8f6a3e5.dirty
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · On 09/11/2013 12:35 PM, [email protected] wrote:

From: Lan Tianyu <[email protected]>

In the cpufreq_policy_restore(), policy before system suspend is read from from percpu's cpufreq_cpu_data_fallback. It's read operation rather than write operation. So convert write lock to read lock

I noticed it too yesterday, while looking at something else. Thanks for fixing this!

Quoted 13 lines
---
 drivers/cpufreq/cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +0 -0
index 81ceea6..b762f9b 100644
@@ -912,11 +912,11 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu)
 	struct cpufreq_policy *policy;
 	unsigned long flags;
 

drivers/cpufreq/cpufreq.c static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu) · line 922

Quoted 10 lines
drivers/cpufreq/cpufreq.c +2 -2
-	write_lock_irqsave(&cpufreq_driver_lock, flags);
+	read_lock_irqsave(&cpufreq_driver_lock, flags);
 
 	policy = per_cpu(cpufreq_cpu_data_fallback, cpu);
 
-	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+	read_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
 	return policy;
 }

Regards,
Srivatsa S. Bhat

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 19 lines · On 11 September 2013 12:35, <[email protected]> wrote:

From: Lan Tianyu <[email protected]>

In the cpufreq_policy_restore(), policy before system suspend is read from from percpu's cpufreq_cpu_data_fallback. It's read operation rather than write operation. So convert write lock to read lock

---
 drivers/cpufreq/cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +0 -0
index 81ceea6..b762f9b 100644
@@ -912,11 +912,11 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu)
        struct cpufreq_policy *policy;
        unsigned long flags;
 

drivers/cpufreq/cpufreq.c static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu) · line 922

Quoted 10 lines
drivers/cpufreq/cpufreq.c +2 -2
-       write_lock_irqsave(&cpufreq_driver_lock, flags);
+       read_lock_irqsave(&cpufreq_driver_lock, flags);
 
        policy = per_cpu(cpufreq_cpu_data_fallback, cpu);
 
-       write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+       read_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
        return policy;
 }
#3 lore raw
In reply to [email protected]
Quoted 7 lines · On Wednesday, September 11, 2013 03:05:05 PM [email protected] wrote:

From: Lan Tianyu <[email protected]>

In the cpufreq_policy_restore(), policy before system suspend is read from from percpu's cpufreq_cpu_data_fallback. It's read operation rather than write operation. So convert write lock to read lock

Applied, thanks Tianyu!

Quoted 23 lines
---
 drivers/cpufreq/cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +2 -2
index 81ceea6..b762f9b 100644
@@ -912,11 +912,11 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu)
 	struct cpufreq_policy *policy;
 	unsigned long flags;
 
-	write_lock_irqsave(&cpufreq_driver_lock, flags);
+	read_lock_irqsave(&cpufreq_driver_lock, flags);
 
 	policy = per_cpu(cpufreq_cpu_data_fallback, cpu);
 
-	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+	read_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
 	return policy;
 }
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.