Skip to contentSkip to conversation

cpufreq: conservative: fix requested_freq reduction issue

PATCH In review Xiaoguang Chen 2 participants 3 messages Nov 8, 2013 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cpufreq: conservative: fix requested_freq reduction issue

When decreasing frequency, requested_freq may be less than freq_target, So requested_freq minus freq_target may be negative, But reqested_freq's unit is unsigned int, then the negative result will be one larger integer which may be even higher than requested_freq.

This patch is to fix such issue. when result becomes negative, set requested_freq as the min value of policy.

---
 drivers/cpufreq/cpufreq_conservative.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq_conservative.c +6 -1
index f62d822..218460f 100644
@@ -80,13 +80,18 @@ static void cs_check_cpu(int cpu, unsigned int load)
 
 	/* Check for frequency decrease */
 	if (load < cs_tuners->down_threshold) {
+		unsigned int freq_target;
 		/*
 		 * if we cannot reduce the frequency anymore, break out early
 		 */
 		if (policy->cur == policy->min)
 			return;
 
-		dbs_info->requested_freq -= get_freq_target(cs_tuners, policy);
+		freq_target = get_freq_target(cs_tuners, policy);
+		if (dbs_info->requested_freq > freq_target)
+			dbs_info->requested_freq -= freq_target;
+		else
+			dbs_info->requested_freq = policy->min;
 
 		__cpufreq_driver_target(policy, dbs_info->requested_freq,
 				CPUFREQ_RELATION_L);
Signature · 1 line
1.8.0
#1 lore raw

PATCH 2/2 cpufreq: conservative: set requested_freq to policy max when it is over policy max

When requested_freq is over policy->max, set it to policy->max. This can help to speed up decreasing frequency.

---
 drivers/cpufreq/cpufreq_conservative.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/cpufreq/cpufreq_conservative.c +3 -0
index 218460f..25a70d0 100644
@@ -68,6 +68,9 @@ static void cs_check_cpu(int cpu, unsigned int load)
 
 		dbs_info->requested_freq += get_freq_target(cs_tuners, policy);
 
+		if (dbs_info->requested_freq > policy->max)
+			dbs_info->requested_freq = policy->max;
+
 		__cpufreq_driver_target(policy, dbs_info->requested_freq,
 			CPUFREQ_RELATION_H);
 		return;
Signature · 1 line
1.8.0
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] cpufreq: conservative: set requested_freq to policy max when it is over policy max

Quoted 13 lines · Xiaoguang Chen

When requested_freq is over policy->max, set it to policy->max. This can help to speed up decreasing frequency.

---
 drivers/cpufreq/cpufreq_conservative.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/cpufreq/cpufreq_conservative.c +0 -0
index 218460f..25a70d0 100644

drivers/cpufreq/cpufreq_conservative.c static void cs_check_cpu(int cpu, unsigned int load) · line 76

Quoted 9 lines
drivers/cpufreq/cpufreq_conservative.c +3 -0
@@ -68,6 +68,9 @@ static void cs_check_cpu(int cpu, unsigned int load)
 
                dbs_info->requested_freq += get_freq_target(cs_tuners, policy);
 
+               if (dbs_info->requested_freq > policy->max)
+                       dbs_info->requested_freq = policy->max;
+
                __cpufreq_driver_target(policy, dbs_info->requested_freq,
                        CPUFREQ_RELATION_H);
                return;