Re: [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Stephen Rothwell
Just a couple of trivial things.

On Fri, 04 Jul 2008 21:05:40 +0200 [EMAIL PROTECTED] wrote:

 + * (C) Copyright IBM Corporation 2006-2008
  ^^^
You should use ©.

 +#define POLL_TIME10  /* in us */
  ^
How about μ ?

 +struct spu_gov_info_struct {
 + unsigned long busy_spus;/* fixed-point */
 + struct cpufreq_policy *policy;
 + struct delayed_work work;
 + unsigned int poll_int;  /* us */

And again.

 +static int calc_freq(struct spu_gov_info_struct *info)
 +{
 + int cpu;
 + int busy_spus;
 +
 + cpu = info-policy-cpu;
 + busy_spus = atomic_read(cbe_spu_info[cpu_to_node(cpu)].busy_spus);
 +
 + CALC_LOAD(info-busy_spus, EXP, busy_spus * FIXED_1);
 + pr_debug(KERN_ERR cpu %d: busy_spus=%d, info-busy_spus=%d\n, cpu, 
 busy_spus, info-busy_spus);

Split this line.

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgprvbb5njLLW.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Arnd Bergmann
On Monday 07 July 2008, Benjamin Herrenschmidt wrote:
 Also, there's the question of whether this should also go in
 drivers/cpufreq or not and should be reviewed by the cpufreq
 maintainer (whoever that is), no ?

Good point. Let's see if Dave Jones has a few cycles for a review
of this.

Arnd 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Arnd Bergmann
On Monday 07 July 2008, Stephen Rothwell wrote:
  +
  + CALC_LOAD(info-busy_spus, EXP, busy_spus * FIXED_1);
  + pr_debug(KERN_ERR cpu %d: busy_spus=%d, info-busy_spus=%d\n, cpu, 
  busy_spus, info-busy_spus);
 
 Split this line.

Right, also: leave out the KERN_ERR in pr_debug, and use %ld for 
info-busy_spus.

Arnd 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Arnd Bergmann
On Monday 07 July 2008, Stephen Rothwell wrote:
  +#define POLL_TIME10  /* in us */
                                               ^
 How about μ ?

Not sure, how about µ instead? ;-)

Arnd 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Josh Boyer
On Mon, 2008-07-07 at 16:59 +0200, Arnd Bergmann wrote:
 On Monday 07 July 2008, Stephen Rothwell wrote:
   +#define POLL_TIME10  /* in us */
^
  How about μ ?
 
 Not sure, how about µ instead? ;-)

Erm... don't get it.  You have identical characters here.

josh

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Geoff Levand
[EMAIL PROTECTED] wrote:
 This patch adds a cpufreq governor that takes the number of running spus
 into account. It's very similar to the ondemand governor, but not as complex.
 Instead of hacking spu load into the ondemand governor it might be easier to
 have cpufreq accepting multiple governors per cpu in future.
 Don't know if this is the right way, but it would keep the governors simple.

I tried your current cell-2.6.git #cell_next branch with ps3_defconfig and
get these. ps3_defconfig has

 CONFIG_CBE_CPUFREQ=m
 CONFIG_CBE_CPUFREQ_SPU_GOVERNOR=m

I'm not sure if this patch is the one that introduced the problem though.
I guess we need to make an adjustment in the Kconfig.  I'll be away the
rest of this week, and will look at it next week if you don't.

-Geoff

cell-2.6/arch/powerpc/platforms/cell/cbe_spu_governor.c: In function 
'calc_freq':
cell-2.6/arch/powerpc/platforms/cell/cbe_spu_governor.c:53: warning: format 
'%d' expects type 'int', but argument 4 has type 'long unsigned int'

ERROR: .cpufreq_register_governor 
[arch/powerpc/platforms/cell/cbe_spu_governor.ko] undefined!
ERROR: .__cpufreq_driver_target 
[arch/powerpc/platforms/cell/cbe_spu_governor.ko] undefined!
ERROR: .cpufreq_unregister_governor 
[arch/powerpc/platforms/cell/cbe_spu_governor.ko] undefined!
ERROR: .cpufreq_frequency_table_target 
[arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: .cpufreq_register_driver [arch/powerpc/platforms/cell/cbe-cpufreq.ko] 
undefined!
ERROR: .cpufreq_frequency_table_verify 
[arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: .cpufreq_frequency_table_get_attr 
[arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: .cpufreq_notify_transition 
[arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: .cpufreq_frequency_table_cpuinfo 
[arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: .cbe_get_cpu_mic_tm_regs [arch/powerpc/platforms/cell/cbe-cpufreq.ko] 
undefined!
ERROR: .cbe_get_cpu_pmd_regs [arch/powerpc/platforms/cell/cbe-cpufreq.ko] 
undefined!
ERROR: .cpufreq_unregister_driver 
[arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: .cpufreq_frequency_table_put_attr 
[arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!



___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Arnd Bergmann
On Monday 07 July 2008, Josh Boyer wrote:
 0% probability of being spam.
 
 Full report:
 No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4  
 On Mon, 2008-07-07 at 16:59 +0200, Arnd Bergmann wrote:
  On Monday 07 July 2008, Stephen Rothwell wrote:
+#define POLL_TIME    10          /* in us */
                                                 ^
   How about μ ?
  
  Not sure, how about µ instead? ;-)
 
 Erm... don't get it.  You have identical characters here.

That depends on the tool you use to look at it.

Stephen wrote a Unicode character U+03BC from the Greek alphabet part of
unicode, I wrote unicode character U+00B5 from the Latin-1 code page.
In my mail client, latin-1 characters get rendered in the default font,
but it has to change the font for less common scripts.

Arnd 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Josh Boyer
On Mon, 2008-07-07 at 23:15 +0200, Arnd Bergmann wrote:
 On Monday 07 July 2008, Josh Boyer wrote:
  0% probability of being spam.
  
  Full report:
  No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4  
  On Mon, 2008-07-07 at 16:59 +0200, Arnd Bergmann wrote:
   On Monday 07 July 2008, Stephen Rothwell wrote:
 +#define POLL_TIME10  /* in us */
  ^
How about μ ?
   
   Not sure, how about µ instead? ;-)
  
  Erm... don't get it.  You have identical characters here.
 
 That depends on the tool you use to look at it.
 
 Stephen wrote a Unicode character U+03BC from the Greek alphabet part of
 unicode, I wrote unicode character U+00B5 from the Latin-1 code page.
 In my mail client, latin-1 characters get rendered in the default font,
 but it has to change the font for less common scripts.

I thought Unicode was supposed to _improve_ stuff like that... ;)

josh

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-07 Thread Stephen Rothwell
On Mon, 07 Jul 2008 17:17:57 -0400 Josh Boyer [EMAIL PROTECTED] wrote:

 On Mon, 2008-07-07 at 23:15 +0200, Arnd Bergmann wrote:
  On Monday 07 July 2008, Josh Boyer wrote:
   
   On Mon, 2008-07-07 at 16:59 +0200, Arnd Bergmann wrote:
On Monday 07 July 2008, Stephen Rothwell wrote:
  +#define POLL_TIME10  /* in us */
   ^
 How about μ ?

Not sure, how about µ instead? ;-)
   
   Erm... don't get it.  You have identical characters here.
  
  That depends on the tool you use to look at it.
  
  Stephen wrote a Unicode character U+03BC from the Greek alphabet part of
  unicode, I wrote unicode character U+00B5 from the Latin-1 code page.
  In my mail client, latin-1 characters get rendered in the default font,
  but it has to change the font for less common scripts.
 
 I thought Unicode was supposed to _improve_ stuff like that... ;)

In fact, Arnd was right, I used the Greek letter mu (μ) while he chose the
micro sign (µ).  So, the lartter (Unicode 0x00B5) it should be.

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgpNmpT1D5lRD.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-06 Thread Benjamin Herrenschmidt
On Fri, 2008-07-04 at 21:05 +0200, [EMAIL PROTECTED] wrote:
 plain text document attachment
 (0005-powerpc-cell-add-spu-aware-cpufreq-governor.patch)
 This patch adds a cpufreq governor that takes the number of running spus
 into account. It's very similar to the ondemand governor, but not as complex.
 Instead of hacking spu load into the ondemand governor it might be easier to
 have cpufreq accepting multiple governors per cpu in future.
 Don't know if this is the right way, but it would keep the governors simple.
 
 Signed-off-by: Christian Krafft [EMAIL PROTECTED]

Arnd, your S-O-B ?

Also, there's the question of whether this should also go in
drivers/cpufreq or not and should be reviewed by the cpufreq
maintainer (whoever that is), no ?

Cheers,
Ben.

 ---
  arch/powerpc/platforms/cell/Kconfig|   10 ++
  arch/powerpc/platforms/cell/Makefile   |1 +
  arch/powerpc/platforms/cell/cbe_spu_governor.c |  183 
 
  3 files changed, 194 insertions(+), 0 deletions(-)
  create mode 100644 arch/powerpc/platforms/cell/cbe_spu_governor.c
 
 diff --git a/arch/powerpc/platforms/cell/Kconfig 
 b/arch/powerpc/platforms/cell/Kconfig
 index 3959fcf..2dfff9f 100644
 --- a/arch/powerpc/platforms/cell/Kconfig
 +++ b/arch/powerpc/platforms/cell/Kconfig
 @@ -107,6 +107,16 @@ config CBE_CPUFREQ_PMI
 processor will not only be able to run at lower speed,
 but also at lower core voltage.
  
 +config CBE_CPUFREQ_SPU_GOVERNOR
 + tristate CBE frequency scaling based on SPU usage
 + depends on SPU_FS
 + select CBE_CPUFREQ
 + default m
 + help
 +   This governor checks for spu usage to adjust the cpu frequency.
 +   If no spu is running on a given cpu, that cpu will be throttled to
 +   the minimal possible frequency.
 +
  endmenu
  
  config OPROFILE_CELL
 diff --git a/arch/powerpc/platforms/cell/Makefile 
 b/arch/powerpc/platforms/cell/Makefile
 index c2a7e4e..8be5158 100644
 --- a/arch/powerpc/platforms/cell/Makefile
 +++ b/arch/powerpc/platforms/cell/Makefile
 @@ -8,6 +8,7 @@ obj-$(CONFIG_CBE_THERM)   += cbe_thermal.o
  obj-$(CONFIG_CBE_CPUFREQ_PMI)+= cbe_cpufreq_pmi.o
  obj-$(CONFIG_CBE_CPUFREQ)+= cbe-cpufreq.o
  cbe-cpufreq-y+= cbe_cpufreq_pervasive.o 
 cbe_cpufreq.o
 +obj-$(CONFIG_CBE_CPUFREQ_SPU_GOVERNOR)   += cbe_spu_governor.o
  
  ifeq ($(CONFIG_SMP),y)
  obj-$(CONFIG_PPC_CELL_NATIVE)+= smp.o
 diff --git a/arch/powerpc/platforms/cell/cbe_spu_governor.c 
 b/arch/powerpc/platforms/cell/cbe_spu_governor.c
 new file mode 100644
 index 000..7e63009
 --- /dev/null
 +++ b/arch/powerpc/platforms/cell/cbe_spu_governor.c
 @@ -0,0 +1,183 @@
 +/*
 + * spu aware cpufreq governor for the cell processor
 + *
 + * (C) Copyright IBM Corporation 2006-2008
 + *
 + * Author: Christian Krafft [EMAIL PROTECTED]
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2, or (at your option)
 + * any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + */
 +
 +#include linux/cpufreq.h
 +#include linux/sched.h
 +#include linux/timer.h
 +#include linux/workqueue.h
 +#include asm/atomic.h
 +#include asm/machdep.h
 +#include asm/spu.h
 +
 +#define POLL_TIME10  /* in us */
 +#define EXP  753 /* exp(-1) in fixed-point */
 +
 +struct spu_gov_info_struct {
 + unsigned long busy_spus;/* fixed-point */
 + struct cpufreq_policy *policy;
 + struct delayed_work work;
 + unsigned int poll_int;  /* us */
 +};
 +static DEFINE_PER_CPU(struct spu_gov_info_struct, spu_gov_info);
 +
 +static struct workqueue_struct *kspugov_wq;
 +
 +static int calc_freq(struct spu_gov_info_struct *info)
 +{
 + int cpu;
 + int busy_spus;
 +
 + cpu = info-policy-cpu;
 + busy_spus = atomic_read(cbe_spu_info[cpu_to_node(cpu)].busy_spus);
 +
 + CALC_LOAD(info-busy_spus, EXP, busy_spus * FIXED_1);
 + pr_debug(KERN_ERR cpu %d: busy_spus=%d, info-busy_spus=%d\n, cpu, 
 busy_spus, info-busy_spus);
 +
 + return info-policy-max * info-busy_spus / FIXED_1;
 +}
 +
 +static void spu_gov_work(struct work_struct *work)
 +{
 + struct spu_gov_info_struct *info;
 + int delay;
 + unsigned long target_freq;
 +
 + info = container_of(work, struct spu_gov_info_struct, work.work);
 +
 + /* after cancel_delayed_work_sync we unset 

Re: [patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-06 Thread Stephen Rothwell
On Mon, 07 Jul 2008 15:21:59 +1000 Benjamin Herrenschmidt [EMAIL PROTECTED] 
wrote:

 On Fri, 2008-07-04 at 21:05 +0200, [EMAIL PROTECTED] wrote:
  plain text document attachment
  (0005-powerpc-cell-add-spu-aware-cpufreq-governor.patch)

We probably don't need to know that :-)

  This patch adds a cpufreq governor that takes the number of running spus
  into account. It's very similar to the ondemand governor, but not as 
  complex.
  Instead of hacking spu load into the ondemand governor it might be easier to
  have cpufreq accepting multiple governors per cpu in future.
  Don't know if this is the right way, but it would keep the governors simple.
  
  Signed-off-by: Christian Krafft [EMAIL PROTECTED]
 
 Arnd, your S-O-B ?

And a leading From line if it was written by Christian.
-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgphLO4rIrLk0.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

[patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-04 Thread arnd
This patch adds a cpufreq governor that takes the number of running spus
into account. It's very similar to the ondemand governor, but not as complex.
Instead of hacking spu load into the ondemand governor it might be easier to
have cpufreq accepting multiple governors per cpu in future.
Don't know if this is the right way, but it would keep the governors simple.

Signed-off-by: Christian Krafft [EMAIL PROTECTED]
---
 arch/powerpc/platforms/cell/Kconfig|   10 ++
 arch/powerpc/platforms/cell/Makefile   |1 +
 arch/powerpc/platforms/cell/cbe_spu_governor.c |  183 
 3 files changed, 194 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/cell/cbe_spu_governor.c

diff --git a/arch/powerpc/platforms/cell/Kconfig 
b/arch/powerpc/platforms/cell/Kconfig
index 3959fcf..2dfff9f 100644
--- a/arch/powerpc/platforms/cell/Kconfig
+++ b/arch/powerpc/platforms/cell/Kconfig
@@ -107,6 +107,16 @@ config CBE_CPUFREQ_PMI
  processor will not only be able to run at lower speed,
  but also at lower core voltage.
 
+config CBE_CPUFREQ_SPU_GOVERNOR
+   tristate CBE frequency scaling based on SPU usage
+   depends on SPU_FS
+   select CBE_CPUFREQ
+   default m
+   help
+ This governor checks for spu usage to adjust the cpu frequency.
+ If no spu is running on a given cpu, that cpu will be throttled to
+ the minimal possible frequency.
+
 endmenu
 
 config OPROFILE_CELL
diff --git a/arch/powerpc/platforms/cell/Makefile 
b/arch/powerpc/platforms/cell/Makefile
index c2a7e4e..8be5158 100644
--- a/arch/powerpc/platforms/cell/Makefile
+++ b/arch/powerpc/platforms/cell/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_CBE_THERM) += cbe_thermal.o
 obj-$(CONFIG_CBE_CPUFREQ_PMI)  += cbe_cpufreq_pmi.o
 obj-$(CONFIG_CBE_CPUFREQ)  += cbe-cpufreq.o
 cbe-cpufreq-y  += cbe_cpufreq_pervasive.o cbe_cpufreq.o
+obj-$(CONFIG_CBE_CPUFREQ_SPU_GOVERNOR) += cbe_spu_governor.o
 
 ifeq ($(CONFIG_SMP),y)
 obj-$(CONFIG_PPC_CELL_NATIVE)  += smp.o
diff --git a/arch/powerpc/platforms/cell/cbe_spu_governor.c 
b/arch/powerpc/platforms/cell/cbe_spu_governor.c
new file mode 100644
index 000..7e63009
--- /dev/null
+++ b/arch/powerpc/platforms/cell/cbe_spu_governor.c
@@ -0,0 +1,183 @@
+/*
+ * spu aware cpufreq governor for the cell processor
+ *
+ * (C) Copyright IBM Corporation 2006-2008
+ *
+ * Author: Christian Krafft [EMAIL PROTECTED]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include linux/cpufreq.h
+#include linux/sched.h
+#include linux/timer.h
+#include linux/workqueue.h
+#include asm/atomic.h
+#include asm/machdep.h
+#include asm/spu.h
+
+#define POLL_TIME  10  /* in us */
+#define EXP753 /* exp(-1) in fixed-point */
+
+struct spu_gov_info_struct {
+   unsigned long busy_spus;/* fixed-point */
+   struct cpufreq_policy *policy;
+   struct delayed_work work;
+   unsigned int poll_int;  /* us */
+};
+static DEFINE_PER_CPU(struct spu_gov_info_struct, spu_gov_info);
+
+static struct workqueue_struct *kspugov_wq;
+
+static int calc_freq(struct spu_gov_info_struct *info)
+{
+   int cpu;
+   int busy_spus;
+
+   cpu = info-policy-cpu;
+   busy_spus = atomic_read(cbe_spu_info[cpu_to_node(cpu)].busy_spus);
+
+   CALC_LOAD(info-busy_spus, EXP, busy_spus * FIXED_1);
+   pr_debug(KERN_ERR cpu %d: busy_spus=%d, info-busy_spus=%d\n, cpu, 
busy_spus, info-busy_spus);
+
+   return info-policy-max * info-busy_spus / FIXED_1;
+}
+
+static void spu_gov_work(struct work_struct *work)
+{
+   struct spu_gov_info_struct *info;
+   int delay;
+   unsigned long target_freq;
+
+   info = container_of(work, struct spu_gov_info_struct, work.work);
+
+   /* after cancel_delayed_work_sync we unset info-policy */
+   BUG_ON(info-policy == NULL);
+
+   target_freq = calc_freq(info);
+   __cpufreq_driver_target(info-policy, target_freq, CPUFREQ_RELATION_H);
+
+   delay = usecs_to_jiffies(info-poll_int);
+   queue_delayed_work_on(info-policy-cpu, kspugov_wq, info-work, 
delay);
+}
+
+static void spu_gov_init_work(struct spu_gov_info_struct *info)
+{
+   int delay = usecs_to_jiffies(info-poll_int);
+