Re: [PATCH 1/4] cpufreq: change cpu freq tables to per_cpu variables

2008-02-11 Thread Dave Jones
On Mon, Feb 11, 2008 at 09:32:19AM -0800, Mike Travis wrote:
 > Dave Jones wrote:
 > > On Fri, Feb 08, 2008 at 03:37:39PM -0800, Mike Travis wrote:
 > >  > Change cpu frequency tables from arrays to per_cpu variables.
 > >  > 
 > >  > Based on linux-2.6.git + x86.git
 > > 
 > > Looks ok to me.   Would you like me to push this though cpufreq.git,
 > > or do you want the series to go through all in one?
 > 
 > Thanks Dave.  The patches are pretty much independent but it is
 > easier to keep track of them if they go in together.

No problem.  Feel free to add my
Signed-off-by: Dave Jones <[EMAIL PROTECTED]>

 >  Btw, I have
 > another set coming shortly that I'm testing now.  It should remove
 > most of the remaining references to NR_CPUS.

Cool! As a distro kernel maintainer, this is appreciated.
Keeping everyone happy isn't easy, and work like this definitly
goes a long way towards that goal.

Dave

-- 
http://www.codemonkey.org.uk
--
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/


Re: [PATCH 1/4] cpufreq: change cpu freq tables to per_cpu variables

2008-02-11 Thread Mike Travis
Dave Jones wrote:
> On Fri, Feb 08, 2008 at 03:37:39PM -0800, Mike Travis wrote:
>  > Change cpu frequency tables from arrays to per_cpu variables.
>  > 
>  > Based on linux-2.6.git + x86.git
> 
> Looks ok to me.   Would you like me to push this though cpufreq.git,
> or do you want the series to go through all in one?
> 
>   Dave
> 

Thanks Dave.  The patches are pretty much independent but it is
easier to keep track of them if they go in together.  Btw, I have
another set coming shortly that I'm testing now.  It should remove
most of the remaining references to NR_CPUS.

Thanks again,
Mike
--
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/


Re: [PATCH 1/4] cpufreq: change cpu freq tables to per_cpu variables

2008-02-10 Thread Dave Jones
On Fri, Feb 08, 2008 at 03:37:39PM -0800, Mike Travis wrote:
 > Change cpu frequency tables from arrays to per_cpu variables.
 > 
 > Based on linux-2.6.git + x86.git

Looks ok to me.   Would you like me to push this though cpufreq.git,
or do you want the series to go through all in one?

Dave

-- 
http://www.codemonkey.org.uk
--
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/


[PATCH 1/4] cpufreq: change cpu freq tables to per_cpu variables

2008-02-08 Thread Mike Travis
Change cpu frequency tables from arrays to per_cpu variables.

Based on linux-2.6.git + x86.git

Cc: Dave Jones <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 drivers/cpufreq/cpufreq_userspace.c |   71 +++-
 1 file changed, 39 insertions(+), 32 deletions(-)

--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -30,11 +30,11 @@
 /**
  * A few values needed by the userspace governor
  */
-static unsigned intcpu_max_freq[NR_CPUS];
-static unsigned intcpu_min_freq[NR_CPUS];
-static unsigned intcpu_cur_freq[NR_CPUS]; /* current CPU freq */
-static unsigned intcpu_set_freq[NR_CPUS]; /* CPU freq desired by userspace 
*/
-static unsigned intcpu_is_managed[NR_CPUS];
+DEFINE_PER_CPU(int, cpu_max_freq);
+DEFINE_PER_CPU(int, cpu_min_freq);
+DEFINE_PER_CPU(int, cpu_cur_freq); /* current CPU freq */
+DEFINE_PER_CPU(int, cpu_set_freq); /* CPU freq desired by userspace */
+DEFINE_PER_CPU(int, cpu_is_managed);
 
 static DEFINE_MUTEX(userspace_mutex);
 static int cpus_using_userspace_governor;
@@ -48,12 +48,12 @@ userspace_cpufreq_notifier(struct notifi
 {
 struct cpufreq_freqs *freq = data;
 
-   if (!cpu_is_managed[freq->cpu])
+   if (!per_cpu(cpu_is_managed, freq->cpu))
return 0;
 
dprintk("saving cpu_cur_freq of cpu %u to be %u kHz\n",
freq->cpu, freq->new);
-   cpu_cur_freq[freq->cpu] = freq->new;
+   per_cpu(cpu_cur_freq, freq->cpu) = freq->new;
 
 return 0;
 }
@@ -77,15 +77,15 @@ static int cpufreq_set(unsigned int freq
dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq);
 
mutex_lock(&userspace_mutex);
-   if (!cpu_is_managed[policy->cpu])
+   if (!per_cpu(cpu_is_managed, policy->cpu))
goto err;
 
-   cpu_set_freq[policy->cpu] = freq;
+   per_cpu(cpu_set_freq, policy->cpu) = freq;
 
-   if (freq < cpu_min_freq[policy->cpu])
-   freq = cpu_min_freq[policy->cpu];
-   if (freq > cpu_max_freq[policy->cpu])
-   freq = cpu_max_freq[policy->cpu];
+   if (freq < per_cpu(cpu_min_freq, policy->cpu))
+   freq = per_cpu(cpu_min_freq, policy->cpu);
+   if (freq > per_cpu(cpu_max_freq, policy->cpu))
+   freq = per_cpu(cpu_max_freq, policy->cpu);
 
/*
 * We're safe from concurrent calls to ->target() here
@@ -105,7 +105,7 @@ static int cpufreq_set(unsigned int freq
 /** sysfs interface /
 static ssize_t show_speed (struct cpufreq_policy *policy, char *buf)
 {
-   return sprintf (buf, "%u\n", cpu_cur_freq[policy->cpu]);
+   return sprintf (buf, "%u\n", per_cpu(cpu_cur_freq, policy->cpu));
 }
 
 static ssize_t
@@ -154,12 +154,16 @@ static int cpufreq_governor_userspace(st
}
cpus_using_userspace_governor++;
 
-   cpu_is_managed[cpu] = 1;
-   cpu_min_freq[cpu] = policy->min;
-   cpu_max_freq[cpu] = policy->max;
-   cpu_cur_freq[cpu] = policy->cur;
-   cpu_set_freq[cpu] = policy->cur;
-   dprintk("managing cpu %u started (%u - %u kHz, currently %u 
kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]);
+   per_cpu(cpu_is_managed, cpu) = 1;
+   per_cpu(cpu_min_freq, cpu) = policy->min;
+   per_cpu(cpu_max_freq, cpu) = policy->max;
+   per_cpu(cpu_cur_freq, cpu) = policy->cur;
+   per_cpu(cpu_set_freq, cpu) = policy->cur;
+   dprintk("managing cpu %u started "
+   "(%u - %u kHz, currently %u kHz)\n", cpu,
+   per_cpu(cpu_min_freq, cpu),
+   per_cpu(cpu_max_freq, cpu),
+   per_cpu(cpu_cur_freq, cpu));
 start_out:
mutex_unlock(&userspace_mutex);
break;
@@ -172,11 +176,12 @@ start_out:
CPUFREQ_TRANSITION_NOTIFIER);
}
 
-   cpu_is_managed[cpu] = 0;
-   cpu_min_freq[cpu] = 0;
-   cpu_max_freq[cpu] = 0;
-   cpu_set_freq[cpu] = 0;
-   sysfs_remove_file (&policy->kobj, 
&freq_attr_scaling_setspeed.attr);
+   per_cpu(cpu_is_managed, cpu) = 0;
+   per_cpu(cpu_min_freq, cpu) = 0;
+   per_cpu(cpu_max_freq, cpu) = 0;
+   per_cpu(cpu_set_freq, cpu) = 0;
+   sysfs_remove_file (&policy->kobj,
+   &freq_attr_scaling_setspeed.attr);
dprintk("managing cpu %u stopped\n", cpu);
mutex_unlock(&userspace_mutex);
break;
@@ -185,22 +190,24 @@ start_out:
dprintk("limit event for cpu %u: %u - %u kHz,"
"currently %u kHz, last set to %u kHz\