Re: [tip:sched/core] sched/fair: Fix group power_orig computation

2013-11-12 Thread Peter Zijlstra
On Tue, Nov 12, 2013 at 04:25:47PM +0530, Srikar Dronamraju wrote:
> From: Srikar Dronamraju 
> Date: Tue, 12 Nov 2013 03:05:31 -0500
> Subject: [PATCH] sched: Check sched_domain before computing group power.
> 
> After Commit-id 863bffc80898 (sched/fair: Fix group power_orig
> computation), we might end up computing group power before the
> sched_domain for a cpu is updated.
> 
> Check for rq->sd before updating group power.
> 
> Signed-off-by: Srikar Dronamraju 

Thanks! My head hurts a bit from going through the overlap init paths
but this does indeed revert to the previous behaviour.

I'm not entirely sure if either are fully correct, but given we
initialize the sgp->power to some 'reasonable' default we can rely on
runtime updates to correct any funnies.

> ---
>  kernel/sched/fair.c |7 ++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index df77c60..f86f704 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -5354,8 +5354,13 @@ void update_group_power(struct sched_domain *sd, int 
> cpu)
>*/
>  
>   for_each_cpu(cpu, sched_group_cpus(sdg)) {
> - struct sched_group *sg = cpu_rq(cpu)->sd->groups;
> + struct rq *rq = cpu_rq(cpu);
> + struct sched_group *sg;
>  
> + if (!rq->sd)
> + continue;
> +
> + sg = rq->sd->groups;
>   power_orig += sg->sgp->power_orig;
>   power += sg->sgp->power;
>   }
> -- 
> 1.7.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:sched/core] sched/fair: Fix group power_orig computation

2013-11-12 Thread Srikar Dronamraju

With Commit-id 863bffc80898 (sched/fair: Fix group power_orig computation)
which is part of latest tip/master, numa machine may fail to boot both
on powerpc and x86_64.

On powerpc

[0.710162] Unable to handle kernel paging request for data at address 
0x0010
[0.710170] Faulting instruction address: 0xc00f3db4
[0.710177] Oops: Kernel access of bad area, sig: 11 [#1]
[0.710182] SMP NR_CPUS=1024 NUMA pSeries
[0.710190] Modules linked in:
[0.710199] CPU: 53 PID: 1 Comm: swapper/53 Not tainted 3.12.0-tip_master+ #1
[0.710205] task: c0171398 ti: c01713a0 task.ti: 
c01713a0
[0.710211] NIP: c00f3db4 LR: c00f3de0 CTR: 
[0.710217] REGS: c01713a036d0 TRAP: 0300   Not tainted  
(3.12.0-tip_master+)
[0.710223] MSR: 80009032   CR: 48002044  XER: 
2003
[0.710243] SOFTE: 1
[0.710246] CFAR: c000908c
[0.710250] DAR: 0010, DSISR: 4000
[0.710254]
GPR00: c0e85e00 c01713a03950 c15a7a58 0030
GPR04: 0030  0400 1dcd6500
GPR08:    c160c958
GPR12:  c7edb980 c007e2e374a8 c1607a58
GPR16: c01ef38f8f58 0180 c1770258 0001
GPR20: 005f c01ef38f8f40 0001 c14b9acf
GPR24:  c01712884a40 c1607a58 c0e87a58
GPR28: c160fc54 c01712884a58  
[0.710349] NIP [c00f3db4] .update_group_power+0xd4/0x2e0
[0.710355] LR [c00f3de0] .update_group_power+0x100/0x2e0
[0.710360] Call Trace:
[0.710364] [c01713a03950] [c00f3d28] 
.update_group_power+0x48/0x2e0 (unreliable)
[0.710375] [c01713a03a00] [c00ed73c] 
.build_sched_domains+0xadc/0xd90
[0.710385] [c01713a03b70] [c0bf39b0] .sched_init_smp+0x528/0x66c
[0.710394] [c01713a03ce0] [c0bd46a8] 
.kernel_init_freeable+0x200/0x398
[0.710405] [c01713a03db0] [c000bc04] .kernel_init+0x24/0x140
[0.710413] [c01713a03e30] [c000a16c] 
.ret_from_kernel_thread+0x5c/0x70
[0.710419] Instruction dump:
[0.710424] 3bb90018 3bc0 3be0 3860 3f62ff8e 4834 6000 
397a4f00
[0.710439] 381be3a8 7d2b482a 7d204a14 e9290950  e9290010 81690004 
80090008
[0.710465] ---[ end trace b5091a0959b24fe3 ]---
[0.710469]
[2.710530] Kernel panic - not syncing: Fatal exception
[2.710943] Rebooting in 10 seconds..

On x86_64

CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.12.0-tip_v312+ #5
Hardware name: IBM System x3750 M4 -[8722C1A]-/00D1432, BIOS -[KOE116JUS-1.10]- 
09/25/2012
task: 8810373a6040 ti: 8810373a8000 task.ti: 8810373a8000
RIP: 0010:[]  [] 
update_group_power+0xa3/0x130
RSP: :8810373a9db8  EFLAGS: 00010283
RAX: 0008 RBX:  RCX: 
RDX:  RSI: 0040 RDI: 0040
RBP: 8810373a9de8 R08: 88203632f818 R09: 
R10: 0001 R11: 0001 R12: 
R13: 001d3cc0 R14: 88203632f818 R15: 88203632f800
FS:  () GS:88103de0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0010 CR3: 01a0b000 CR4: 000407f0
Stack:
 8810373a9dd8 881035aa0c00 88203632f800 8820362fa800
 0008 0008 8810373a9e58 8108627b
 8810373a9e18 8129fcf8 373a76e0 003f
Call Trace:
 [] build_sched_domains+0x37b/0x3f0
 [] ? alloc_cpumask_var_node+0x58/0x80
 [] sched_init_smp+0x8f/0x13c
 [] kernel_init_freeable+0x27b/0x303
 [] ? kernel_init+0xe/0xf0
 [] ? trace_hardirqs_on_caller+0xfd/0x1c0
 [] ? rest_init+0xd0/0xd0
 [] kernel_init+0xe/0xf0
 [] ret_from_fork+0x7c/0xb0
 [] ? rest_init+0xd0/0xd0
Code: ad 00 4d 8d 77 18 45 31 e4 31 db b8 ff ff ff ff eb 2d 66 0f 1f 44 00 00 
48 63 d0 48 8b 14 d5 
c0 9d b4 81 49 8b 94 15 50 09 00 00 <48> 8b 52 10 48 8b 52 10 8b 4a 08 8b 52 04 
49 01 cc 48 01 d3 8
3
RIP  [] update_group_power+0xa3/0x130
 RSP 
CR2: 0010
---[ end trace cd8cb7fb261d7bea ]---
Kernel panic - not syncing: Fatal exception

This can be fixed by a simple check below.

-- 
Thanks and Regards
Srikar Dronamraju

>8-
>From bfc5dced04472c6c499aa3c6773ddef42d83fefc Mon Sep 17 00:00:00 2001
From: Srikar Dronamraju 
Date: Tue, 12 Nov 2013 03:05:31 -0500
Subject: [PATCH] sched: Check sched_domain before computing group power.

After Commit-id 863bffc80898 (sched/fair: Fix group power_orig
computation), we might end up computing group power before the
sched_domain for a cpu is updated.

Check for rq->sd before updating group power.

Signed-off-by: Srikar Dronamraju 

Re: [tip:sched/core] sched/fair: Fix group power_orig computation

2013-11-12 Thread Srikar Dronamraju

With Commit-id 863bffc80898 (sched/fair: Fix group power_orig computation)
which is part of latest tip/master, numa machine may fail to boot both
on powerpc and x86_64.

On powerpc

[0.710162] Unable to handle kernel paging request for data at address 
0x0010
[0.710170] Faulting instruction address: 0xc00f3db4
[0.710177] Oops: Kernel access of bad area, sig: 11 [#1]
[0.710182] SMP NR_CPUS=1024 NUMA pSeries
[0.710190] Modules linked in:
[0.710199] CPU: 53 PID: 1 Comm: swapper/53 Not tainted 3.12.0-tip_master+ #1
[0.710205] task: c0171398 ti: c01713a0 task.ti: 
c01713a0
[0.710211] NIP: c00f3db4 LR: c00f3de0 CTR: 
[0.710217] REGS: c01713a036d0 TRAP: 0300   Not tainted  
(3.12.0-tip_master+)
[0.710223] MSR: 80009032 SF,EE,ME,IR,DR,RI  CR: 48002044  XER: 
2003
[0.710243] SOFTE: 1
[0.710246] CFAR: c000908c
[0.710250] DAR: 0010, DSISR: 4000
[0.710254]
GPR00: c0e85e00 c01713a03950 c15a7a58 0030
GPR04: 0030  0400 1dcd6500
GPR08:    c160c958
GPR12:  c7edb980 c007e2e374a8 c1607a58
GPR16: c01ef38f8f58 0180 c1770258 0001
GPR20: 005f c01ef38f8f40 0001 c14b9acf
GPR24:  c01712884a40 c1607a58 c0e87a58
GPR28: c160fc54 c01712884a58  
[0.710349] NIP [c00f3db4] .update_group_power+0xd4/0x2e0
[0.710355] LR [c00f3de0] .update_group_power+0x100/0x2e0
[0.710360] Call Trace:
[0.710364] [c01713a03950] [c00f3d28] 
.update_group_power+0x48/0x2e0 (unreliable)
[0.710375] [c01713a03a00] [c00ed73c] 
.build_sched_domains+0xadc/0xd90
[0.710385] [c01713a03b70] [c0bf39b0] .sched_init_smp+0x528/0x66c
[0.710394] [c01713a03ce0] [c0bd46a8] 
.kernel_init_freeable+0x200/0x398
[0.710405] [c01713a03db0] [c000bc04] .kernel_init+0x24/0x140
[0.710413] [c01713a03e30] [c000a16c] 
.ret_from_kernel_thread+0x5c/0x70
[0.710419] Instruction dump:
[0.710424] 3bb90018 3bc0 3be0 3860 3f62ff8e 4834 6000 
397a4f00
[0.710439] 381be3a8 7d2b482a 7d204a14 e9290950 e9290010 e9290010 81690004 
80090008
[0.710465] ---[ end trace b5091a0959b24fe3 ]---
[0.710469]
[2.710530] Kernel panic - not syncing: Fatal exception
[2.710943] Rebooting in 10 seconds..

On x86_64

CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.12.0-tip_v312+ #5
Hardware name: IBM System x3750 M4 -[8722C1A]-/00D1432, BIOS -[KOE116JUS-1.10]- 
09/25/2012
task: 8810373a6040 ti: 8810373a8000 task.ti: 8810373a8000
RIP: 0010:[8108aa53]  [8108aa53] 
update_group_power+0xa3/0x130
RSP: :8810373a9db8  EFLAGS: 00010283
RAX: 0008 RBX:  RCX: 
RDX:  RSI: 0040 RDI: 0040
RBP: 8810373a9de8 R08: 88203632f818 R09: 
R10: 0001 R11: 0001 R12: 
R13: 001d3cc0 R14: 88203632f818 R15: 88203632f800
FS:  () GS:88103de0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0010 CR3: 01a0b000 CR4: 000407f0
Stack:
 8810373a9dd8 881035aa0c00 88203632f800 8820362fa800
 0008 0008 8810373a9e58 8108627b
 8810373a9e18 8129fcf8 373a76e0 003f
Call Trace:
 [8108627b] build_sched_domains+0x37b/0x3f0
 [8129fcf8] ? alloc_cpumask_var_node+0x58/0x80
 [81d59783] sched_init_smp+0x8f/0x13c
 [81d3db78] kernel_init_freeable+0x27b/0x303
 [81593c6e] ? kernel_init+0xe/0xf0
 [810a0ead] ? trace_hardirqs_on_caller+0xfd/0x1c0
 [81593c60] ? rest_init+0xd0/0xd0
 [81593c6e] kernel_init+0xe/0xf0
 [815a9eac] ret_from_fork+0x7c/0xb0
 [81593c60] ? rest_init+0xd0/0xd0
Code: ad 00 4d 8d 77 18 45 31 e4 31 db b8 ff ff ff ff eb 2d 66 0f 1f 44 00 00 
48 63 d0 48 8b 14 d5 
c0 9d b4 81 49 8b 94 15 50 09 00 00 48 8b 52 10 48 8b 52 10 8b 4a 08 8b 52 04 
49 01 cc 48 01 d3 8
3
RIP  [8108aa53] update_group_power+0xa3/0x130
 RSP 8810373a9db8
CR2: 0010
---[ end trace cd8cb7fb261d7bea ]---
Kernel panic - not syncing: Fatal exception

This can be fixed by a simple check below.

-- 
Thanks and Regards
Srikar Dronamraju

8-
From bfc5dced04472c6c499aa3c6773ddef42d83fefc Mon Sep 17 00:00:00 2001
From: Srikar Dronamraju sri...@linux.vnet.ibm.com
Date: Tue, 12 Nov 2013 03:05:31 -0500
Subject: [PATCH] sched: Check sched_domain 

Re: [tip:sched/core] sched/fair: Fix group power_orig computation

2013-11-12 Thread Peter Zijlstra
On Tue, Nov 12, 2013 at 04:25:47PM +0530, Srikar Dronamraju wrote:
 From: Srikar Dronamraju sri...@linux.vnet.ibm.com
 Date: Tue, 12 Nov 2013 03:05:31 -0500
 Subject: [PATCH] sched: Check sched_domain before computing group power.
 
 After Commit-id 863bffc80898 (sched/fair: Fix group power_orig
 computation), we might end up computing group power before the
 sched_domain for a cpu is updated.
 
 Check for rq-sd before updating group power.
 
 Signed-off-by: Srikar Dronamraju sri...@linux.vnet.ibm.com

Thanks! My head hurts a bit from going through the overlap init paths
but this does indeed revert to the previous behaviour.

I'm not entirely sure if either are fully correct, but given we
initialize the sgp-power to some 'reasonable' default we can rely on
runtime updates to correct any funnies.

 ---
  kernel/sched/fair.c |7 ++-
  1 files changed, 6 insertions(+), 1 deletions(-)
 
 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
 index df77c60..f86f704 100644
 --- a/kernel/sched/fair.c
 +++ b/kernel/sched/fair.c
 @@ -5354,8 +5354,13 @@ void update_group_power(struct sched_domain *sd, int 
 cpu)
*/
  
   for_each_cpu(cpu, sched_group_cpus(sdg)) {
 - struct sched_group *sg = cpu_rq(cpu)-sd-groups;
 + struct rq *rq = cpu_rq(cpu);
 + struct sched_group *sg;
  
 + if (!rq-sd)
 + continue;
 +
 + sg = rq-sd-groups;
   power_orig += sg-sgp-power_orig;
   power += sg-sgp-power;
   }
 -- 
 1.7.1
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:sched/core] sched/fair: Fix group power_orig computation

2013-09-12 Thread Michael Neuling
tip-bot for Peter Zijlstra  wrote:

> Commit-ID:  863bffc80898b8df295ebac111af2335ec05f85d
> Gitweb: http://git.kernel.org/tip/863bffc80898b8df295ebac111af2335ec05f85d
> Author: Peter Zijlstra 
> AuthorDate: Wed, 28 Aug 2013 11:44:39 +0200
> Committer:  Ingo Molnar 
> CommitDate: Thu, 12 Sep 2013 19:14:43 +0200
> 
> sched/fair: Fix group power_orig computation
> 
> When looking at the code I noticed we don't actually compute
> sgp->power_orig correctly for groups, fix that.
> 
> Currently the only consumer of that value is fix_small_capacity()
> which is only used on POWER7+ and that code excludes this case by
> being limited to SD_SHARE_CPUPOWER which is only ever set on the SMT
> domain which must be the lowest domain and this has singleton groups.
> 
> So nothing should be affected by this change.
> 
> Cc: Michael Neuling 
> Signed-off-by: Peter Zijlstra 
> Link: http://lkml.kernel.org/n/tip-db2pe0vxwunv37plc7onn...@git.kernel.org
> Signed-off-by: Ingo Molnar 

FWIW, this doesn't seem to break POWER7.  

Thanks!
Mikey

> ---
>  kernel/sched/fair.c | 16 +++-
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index f9f4385..baba313 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4450,7 +4450,7 @@ void update_group_power(struct sched_domain *sd, int 
> cpu)
>  {
>   struct sched_domain *child = sd->child;
>   struct sched_group *group, *sdg = sd->groups;
> - unsigned long power;
> + unsigned long power, power_orig;
>   unsigned long interval;
>  
>   interval = msecs_to_jiffies(sd->balance_interval);
> @@ -4462,7 +4462,7 @@ void update_group_power(struct sched_domain *sd, int 
> cpu)
>   return;
>   }
>  
> - power = 0;
> + power_orig = power = 0;
>  
>   if (child->flags & SD_OVERLAP) {
>   /*
> @@ -4470,8 +4470,12 @@ void update_group_power(struct sched_domain *sd, int 
> cpu)
>* span the current group.
>*/
>  
> - for_each_cpu(cpu, sched_group_cpus(sdg))
> - power += power_of(cpu);
> + for_each_cpu(cpu, sched_group_cpus(sdg)) {
> + struct sched_group *sg = cpu_rq(cpu)->sd->groups;
> +
> + power_orig += sg->sgp->power_orig;
> + power += sg->sgp->power;
> + }
>   } else  {
>   /*
>* !SD_OVERLAP domains can assume that child groups
> @@ -4480,12 +4484,14 @@ void update_group_power(struct sched_domain *sd, int 
> cpu)
>  
>   group = child->groups;
>   do {
> + power_orig += group->sgp->power_orig;
>   power += group->sgp->power;
>   group = group->next;
>   } while (group != child->groups);
>   }
>  
> - sdg->sgp->power_orig = sdg->sgp->power = power;
> + sdg->sgp->power_orig = power_orig;
> + sdg->sgp->power = power;
>  }
>  
>  /*
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched/fair: Fix group power_orig computation

2013-09-12 Thread tip-bot for Peter Zijlstra
Commit-ID:  863bffc80898b8df295ebac111af2335ec05f85d
Gitweb: http://git.kernel.org/tip/863bffc80898b8df295ebac111af2335ec05f85d
Author: Peter Zijlstra 
AuthorDate: Wed, 28 Aug 2013 11:44:39 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 12 Sep 2013 19:14:43 +0200

sched/fair: Fix group power_orig computation

When looking at the code I noticed we don't actually compute
sgp->power_orig correctly for groups, fix that.

Currently the only consumer of that value is fix_small_capacity()
which is only used on POWER7+ and that code excludes this case by
being limited to SD_SHARE_CPUPOWER which is only ever set on the SMT
domain which must be the lowest domain and this has singleton groups.

So nothing should be affected by this change.

Cc: Michael Neuling 
Signed-off-by: Peter Zijlstra 
Link: http://lkml.kernel.org/n/tip-db2pe0vxwunv37plc7onn...@git.kernel.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f9f4385..baba313 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4450,7 +4450,7 @@ void update_group_power(struct sched_domain *sd, int cpu)
 {
struct sched_domain *child = sd->child;
struct sched_group *group, *sdg = sd->groups;
-   unsigned long power;
+   unsigned long power, power_orig;
unsigned long interval;
 
interval = msecs_to_jiffies(sd->balance_interval);
@@ -4462,7 +4462,7 @@ void update_group_power(struct sched_domain *sd, int cpu)
return;
}
 
-   power = 0;
+   power_orig = power = 0;
 
if (child->flags & SD_OVERLAP) {
/*
@@ -4470,8 +4470,12 @@ void update_group_power(struct sched_domain *sd, int cpu)
 * span the current group.
 */
 
-   for_each_cpu(cpu, sched_group_cpus(sdg))
-   power += power_of(cpu);
+   for_each_cpu(cpu, sched_group_cpus(sdg)) {
+   struct sched_group *sg = cpu_rq(cpu)->sd->groups;
+
+   power_orig += sg->sgp->power_orig;
+   power += sg->sgp->power;
+   }
} else  {
/*
 * !SD_OVERLAP domains can assume that child groups
@@ -4480,12 +4484,14 @@ void update_group_power(struct sched_domain *sd, int 
cpu)
 
group = child->groups;
do {
+   power_orig += group->sgp->power_orig;
power += group->sgp->power;
group = group->next;
} while (group != child->groups);
}
 
-   sdg->sgp->power_orig = sdg->sgp->power = power;
+   sdg->sgp->power_orig = power_orig;
+   sdg->sgp->power = power;
 }
 
 /*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched/fair: Fix group power_orig computation

2013-09-12 Thread tip-bot for Peter Zijlstra
Commit-ID:  863bffc80898b8df295ebac111af2335ec05f85d
Gitweb: http://git.kernel.org/tip/863bffc80898b8df295ebac111af2335ec05f85d
Author: Peter Zijlstra pet...@infradead.org
AuthorDate: Wed, 28 Aug 2013 11:44:39 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Thu, 12 Sep 2013 19:14:43 +0200

sched/fair: Fix group power_orig computation

When looking at the code I noticed we don't actually compute
sgp-power_orig correctly for groups, fix that.

Currently the only consumer of that value is fix_small_capacity()
which is only used on POWER7+ and that code excludes this case by
being limited to SD_SHARE_CPUPOWER which is only ever set on the SMT
domain which must be the lowest domain and this has singleton groups.

So nothing should be affected by this change.

Cc: Michael Neuling mi...@neuling.org
Signed-off-by: Peter Zijlstra pet...@infradead.org
Link: http://lkml.kernel.org/n/tip-db2pe0vxwunv37plc7onn...@git.kernel.org
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 kernel/sched/fair.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f9f4385..baba313 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4450,7 +4450,7 @@ void update_group_power(struct sched_domain *sd, int cpu)
 {
struct sched_domain *child = sd-child;
struct sched_group *group, *sdg = sd-groups;
-   unsigned long power;
+   unsigned long power, power_orig;
unsigned long interval;
 
interval = msecs_to_jiffies(sd-balance_interval);
@@ -4462,7 +4462,7 @@ void update_group_power(struct sched_domain *sd, int cpu)
return;
}
 
-   power = 0;
+   power_orig = power = 0;
 
if (child-flags  SD_OVERLAP) {
/*
@@ -4470,8 +4470,12 @@ void update_group_power(struct sched_domain *sd, int cpu)
 * span the current group.
 */
 
-   for_each_cpu(cpu, sched_group_cpus(sdg))
-   power += power_of(cpu);
+   for_each_cpu(cpu, sched_group_cpus(sdg)) {
+   struct sched_group *sg = cpu_rq(cpu)-sd-groups;
+
+   power_orig += sg-sgp-power_orig;
+   power += sg-sgp-power;
+   }
} else  {
/*
 * !SD_OVERLAP domains can assume that child groups
@@ -4480,12 +4484,14 @@ void update_group_power(struct sched_domain *sd, int 
cpu)
 
group = child-groups;
do {
+   power_orig += group-sgp-power_orig;
power += group-sgp-power;
group = group-next;
} while (group != child-groups);
}
 
-   sdg-sgp-power_orig = sdg-sgp-power = power;
+   sdg-sgp-power_orig = power_orig;
+   sdg-sgp-power = power;
 }
 
 /*
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:sched/core] sched/fair: Fix group power_orig computation

2013-09-12 Thread Michael Neuling
tip-bot for Peter Zijlstra tip...@zytor.com wrote:

 Commit-ID:  863bffc80898b8df295ebac111af2335ec05f85d
 Gitweb: http://git.kernel.org/tip/863bffc80898b8df295ebac111af2335ec05f85d
 Author: Peter Zijlstra pet...@infradead.org
 AuthorDate: Wed, 28 Aug 2013 11:44:39 +0200
 Committer:  Ingo Molnar mi...@kernel.org
 CommitDate: Thu, 12 Sep 2013 19:14:43 +0200
 
 sched/fair: Fix group power_orig computation
 
 When looking at the code I noticed we don't actually compute
 sgp-power_orig correctly for groups, fix that.
 
 Currently the only consumer of that value is fix_small_capacity()
 which is only used on POWER7+ and that code excludes this case by
 being limited to SD_SHARE_CPUPOWER which is only ever set on the SMT
 domain which must be the lowest domain and this has singleton groups.
 
 So nothing should be affected by this change.
 
 Cc: Michael Neuling mi...@neuling.org
 Signed-off-by: Peter Zijlstra pet...@infradead.org
 Link: http://lkml.kernel.org/n/tip-db2pe0vxwunv37plc7onn...@git.kernel.org
 Signed-off-by: Ingo Molnar mi...@kernel.org

FWIW, this doesn't seem to break POWER7.  

Thanks!
Mikey

 ---
  kernel/sched/fair.c | 16 +++-
  1 file changed, 11 insertions(+), 5 deletions(-)
 
 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
 index f9f4385..baba313 100644
 --- a/kernel/sched/fair.c
 +++ b/kernel/sched/fair.c
 @@ -4450,7 +4450,7 @@ void update_group_power(struct sched_domain *sd, int 
 cpu)
  {
   struct sched_domain *child = sd-child;
   struct sched_group *group, *sdg = sd-groups;
 - unsigned long power;
 + unsigned long power, power_orig;
   unsigned long interval;
  
   interval = msecs_to_jiffies(sd-balance_interval);
 @@ -4462,7 +4462,7 @@ void update_group_power(struct sched_domain *sd, int 
 cpu)
   return;
   }
  
 - power = 0;
 + power_orig = power = 0;
  
   if (child-flags  SD_OVERLAP) {
   /*
 @@ -4470,8 +4470,12 @@ void update_group_power(struct sched_domain *sd, int 
 cpu)
* span the current group.
*/
  
 - for_each_cpu(cpu, sched_group_cpus(sdg))
 - power += power_of(cpu);
 + for_each_cpu(cpu, sched_group_cpus(sdg)) {
 + struct sched_group *sg = cpu_rq(cpu)-sd-groups;
 +
 + power_orig += sg-sgp-power_orig;
 + power += sg-sgp-power;
 + }
   } else  {
   /*
* !SD_OVERLAP domains can assume that child groups
 @@ -4480,12 +4484,14 @@ void update_group_power(struct sched_domain *sd, int 
 cpu)
  
   group = child-groups;
   do {
 + power_orig += group-sgp-power_orig;
   power += group-sgp-power;
   group = group-next;
   } while (group != child-groups);
   }
  
 - sdg-sgp-power_orig = sdg-sgp-power = power;
 + sdg-sgp-power_orig = power_orig;
 + sdg-sgp-power = power;
  }
  
  /*
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/