Skip to contentSkip to conversation

cpufreq: minor cleanups

PATCH In review Dominik Brodowski 2 participants 3 messages Dec 21, 2002 – Dec 26, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: minor cleanups

Get rid of CPUFREQ_ALL_CPUS codepaths not used anymore.

Dominik

kernel/cpufreq.c +20 -34
diff -ruN linux-original/kernel/cpufreq.c linux/kernel/cpufreq.c
@@ -365,7 +365,7 @@
 {
 	struct cpufreq_policy policy;
 	down(&cpufreq_driver_sem);
-	if (!cpufreq_driver || !cpu_max_freq) {
+	if (!cpufreq_driver || !cpu_max_freq || (cpu > NR_CPUS)) {
 		up(&cpufreq_driver_sem);
 		return -EINVAL;
 	}
@@ -377,7 +377,20 @@
 	
 	up(&cpufreq_driver_sem);
 
-	return cpufreq_set_policy(&policy);
+	if (policy.cpu == CPUFREQ_ALL_CPUS)
+	{
+		unsigned int i;
+		unsigned int ret = 0;
+		for (i=0; i<NR_CPUS; i++) 
+		{
+			policy.cpu = i;
+			if (cpu_online(i))
+				ret |= cpufreq_set_policy(&policy);
+		}
+		return ret;
+	} 
+	else
+		return cpufreq_set_policy(&policy);
 }
 EXPORT_SYMBOL_GPL(cpufreq_set);
 
@@ -842,7 +855,6 @@
  */
 int cpufreq_set_policy(struct cpufreq_policy *policy)
 {
-	unsigned int i;
 	int ret;
 
 	down(&cpufreq_driver_sem);
@@ -889,24 +901,12 @@
 
 	up(&cpufreq_notifier_sem);
 
-	if (policy->cpu == CPUFREQ_ALL_CPUS) {
-		for (i=0;i<NR_CPUS;i++) {
-			cpufreq_driver->policy[i].min    = policy->min;
-			cpufreq_driver->policy[i].max    = policy->max;
-			cpufreq_driver->policy[i].policy = policy->policy;
-		} 
-	} else {
-		cpufreq_driver->policy[policy->cpu].min    = policy->min;
-		cpufreq_driver->policy[policy->cpu].max    = policy->max;
-		cpufreq_driver->policy[policy->cpu].policy = policy->policy;
-	}
+	cpufreq_driver->policy[policy->cpu].min    = policy->min;
+	cpufreq_driver->policy[policy->cpu].max    = policy->max;
+	cpufreq_driver->policy[policy->cpu].policy = policy->policy;
 
 #ifdef CONFIG_CPU_FREQ_24_API
-	if (policy->cpu == CPUFREQ_ALL_CPUS) {
-		for (i=0;i<NR_CPUS;i++)
-			cpu_cur_freq[i] = policy->max;
-	} else
-		cpu_cur_freq[policy->cpu] = policy->max;
+	cpu_cur_freq[policy->cpu] = policy->max;
 #endif
 
 	ret = cpufreq_driver->setpolicy(policy);
@@ -920,15 +920,6 @@
 
 
 /*********************************************************************
- *                    DYNAMIC CPUFREQ SWITCHING                      *
- *********************************************************************/
-#ifdef CONFIG_CPU_FREQ_DYNAMIC
-/* TBD */
-#endif /* CONFIG_CPU_FREQ_DYNAMIC */
-
-
-
-/*********************************************************************
  *            EXTERNALLY AFFECTING FREQUENCY CHANGES                 *
  *********************************************************************/
 
@@ -973,12 +964,7 @@
 		adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
 		notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs);
 #ifdef CONFIG_CPU_FREQ_24_API
-		if (freqs->cpu == CPUFREQ_ALL_CPUS) {
-			int i;
-			for (i=0;i<NR_CPUS;i++)
-				cpu_cur_freq[i] = freqs->new;
-		} else
-			cpu_cur_freq[freqs->cpu] = freqs->new;
+		cpu_cur_freq[freqs->cpu] = freqs->new;
 #endif
 		break;
 	}
#1 lore raw

Hi!

Quoted 1 line

Get rid of CPUFREQ_ALL_CPUS codepaths not used anymore.

Get rid of? Seems you are adding it.

Quoted 110 lines

Dominik

diff -ruN linux-original/kernel/cpufreq.c linux/kernel/cpufreq.c

kernel/cpufreq.c +20 -35
@@ -365,7 +365,7 @@
 {
 	struct cpufreq_policy policy;
 	down(&cpufreq_driver_sem);
-	if (!cpufreq_driver || !cpu_max_freq) {
+	if (!cpufreq_driver || !cpu_max_freq || (cpu > NR_CPUS)) {
 		up(&cpufreq_driver_sem);
 		return -EINVAL;
 	}
@@ -377,7 +377,20 @@
 
 	up(&cpufreq_driver_sem);
 
-	return cpufreq_set_policy(&policy);
+	if (policy.cpu == CPUFREQ_ALL_CPUS)
+	{
+		unsigned int i;
+		unsigned int ret = 0;
+		for (i=0; i<NR_CPUS; i++) 
+		{
+			policy.cpu = i;
+			if (cpu_online(i))
+				ret |= cpufreq_set_policy(&policy);
+		}
+		return ret;
+	} 
+	else
+		return cpufreq_set_policy(&policy);
 }
 EXPORT_SYMBOL_GPL(cpufreq_set);
 
@@ -842,7 +855,6 @@
  */
 int cpufreq_set_policy(struct cpufreq_policy *policy)
 {
-	unsigned int i;
 	int ret;
 
 	down(&cpufreq_driver_sem);
@@ -889,24 +901,12 @@
 
 	up(&cpufreq_notifier_sem);
 
-	if (policy->cpu == CPUFREQ_ALL_CPUS) {
-		for (i=0;i<NR_CPUS;i++) {
-			cpufreq_driver->policy[i].min    = policy->min;
-			cpufreq_driver->policy[i].max    = policy->max;
-			cpufreq_driver->policy[i].policy = policy->policy;
-		} 
-	} else {
-		cpufreq_driver->policy[policy->cpu].min    = policy->min;
-		cpufreq_driver->policy[policy->cpu].max    = policy->max;
-		cpufreq_driver->policy[policy->cpu].policy = policy->policy;
-	}
+	cpufreq_driver->policy[policy->cpu].min    = policy->min;
+	cpufreq_driver->policy[policy->cpu].max    = policy->max;
+	cpufreq_driver->policy[policy->cpu].policy = policy->policy;
 
 #ifdef CONFIG_CPU_FREQ_24_API
-	if (policy->cpu == CPUFREQ_ALL_CPUS) {
-		for (i=0;i<NR_CPUS;i++)
-			cpu_cur_freq[i] = policy->max;
-	} else
-		cpu_cur_freq[policy->cpu] = policy->max;
+	cpu_cur_freq[policy->cpu] = policy->max;
 #endif
 
 	ret = cpufreq_driver->setpolicy(policy);
@@ -920,15 +920,6 @@
 
 
 /*********************************************************************
- *                    DYNAMIC CPUFREQ SWITCHING                      *
- *********************************************************************/
-#ifdef CONFIG_CPU_FREQ_DYNAMIC
-/* TBD */
-#endif /* CONFIG_CPU_FREQ_DYNAMIC */
-
-
-
-/*********************************************************************
  *            EXTERNALLY AFFECTING FREQUENCY CHANGES                 *
  *********************************************************************/
 
@@ -973,12 +964,7 @@
 		adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
 		notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs);
 #ifdef CONFIG_CPU_FREQ_24_API
-		if (freqs->cpu == CPUFREQ_ALL_CPUS) {
-			int i;
-			for (i=0;i<NR_CPUS;i++)
-				cpu_cur_freq[i] = freqs->new;
-		} else
-			cpu_cur_freq[freqs->cpu] = freqs->new;
+		cpu_cur_freq[freqs->cpu] = freqs->new;
 #endif
 		break;
 	}
 
 
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?
#2 lore raw
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

Get rid of CPUFREQ_ALL_CPUS codepaths not used anymore.

Get rid of? Seems you are adding it.

Only in cpufreq_set(). If that is called with cpu==CPUFREQ_ALL_CPUS, this value can't be passed to cpufreq_set_policy any more. So the cpufreq_set_policy call needs to be iterated over all cpus. The reason for this is that on some architectures, not all CPUs support the same frequency ranges.
In all other instances, CPUFREQ_ALL_CPUS is removed by that patch you're commenting on; will re-send it soon for 2.5.53.

Dominik

Quoted 18 lines
Quoted 18 lines
kernel/cpufreq.c +14 -1
-	return cpufreq_set_policy(&policy);
+	if (policy.cpu == CPUFREQ_ALL_CPUS)
+	{
+		unsigned int i;
+		unsigned int ret = 0;
+		for (i=0; i<NR_CPUS; i++) 
+		{
+			policy.cpu = i;
+			if (cpu_online(i))
+				ret |= cpufreq_set_policy(&policy);
+		}
+		return ret;
+	} 
+	else
+		return cpufreq_set_policy(&policy);
 }
 EXPORT_SYMBOL_GPL(cpufreq_set);