Re: [PATCH] cpufreq_stats: fix race between stats allocation and first usage

2012-12-15 Thread Rafael J. Wysocki
On Saturday, December 15, 2012 11:01:49 AM Konstantin Khlebnikov wrote:
> Rafael J. Wysocki wrote:
> > On Friday, December 14, 2012 02:59:21 PM Konstantin Khlebnikov wrote:
> >> This patch forces complete struct cpufreq_stats allocation for all cpus 
> >> before
> >> registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some 
> >> conditions
> >> cpufreq_stat_notifier_trans() can be called in the middle of stats 
> >> allocation,
> >> in this case cpufreq_stats_table already exists, but stat->freq_table is 
> >> NULL.
> >
> > I'll queue it up for submission as v3.8 material.
> >
> > Does it need to be marked as -stable material too?
> 
> It's very old and rare bug. I think you can leave it as is.

OK

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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: [PATCH] cpufreq_stats: fix race between stats allocation and first usage

2012-12-15 Thread Rafael J. Wysocki
On Saturday, December 15, 2012 11:01:49 AM Konstantin Khlebnikov wrote:
 Rafael J. Wysocki wrote:
  On Friday, December 14, 2012 02:59:21 PM Konstantin Khlebnikov wrote:
  This patch forces complete struct cpufreq_stats allocation for all cpus 
  before
  registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some 
  conditions
  cpufreq_stat_notifier_trans() can be called in the middle of stats 
  allocation,
  in this case cpufreq_stats_table already exists, but stat-freq_table is 
  NULL.
 
  I'll queue it up for submission as v3.8 material.
 
  Does it need to be marked as -stable material too?
 
 It's very old and rare bug. I think you can leave it as is.

OK

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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: [PATCH] cpufreq_stats: fix race between stats allocation and first usage

2012-12-14 Thread Konstantin Khlebnikov

Rafael J. Wysocki wrote:

On Friday, December 14, 2012 02:59:21 PM Konstantin Khlebnikov wrote:

This patch forces complete struct cpufreq_stats allocation for all cpus before
registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some conditions
cpufreq_stat_notifier_trans() can be called in the middle of stats allocation,
in this case cpufreq_stats_table already exists, but stat->freq_table is NULL.


I'll queue it up for submission as v3.8 material.

Does it need to be marked as -stable material too?


It's very old and rare bug. I think you can leave it as is.



Rafael



Signed-off-by: Konstantin Khlebnikov
Cc: Rafael J. Wysocki
Cc: cpufreq
Cc: linux-pm

---

<1>[  363.116198] BUG: unable to handle kernel NULL pointer dereference at 
(null)
<1>[  363.116668] IP: [] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
<4>[  363.116977] PGD 23177e067 PUD 2349c1067 PMD 0
<4>[  363.117151] Oops:  [#1] SMP
<4>[  363.117151] last sysfs file: /sys/module/freq_table/initstate
<4>[  363.117151] CPU 5
<4>[  363.117151] Modules linked in: cpufreq_stats(+)(U) [a lot] [last 
unloaded: umc]
<4>[  363.117151]
<4>[  363.117151] Pid: 1690, comm: kondemand/5 veid: 0 Tainted: PWC 
---  T 2.6.32-279.5.1.el6-042stab061.7-vz #112 042stab061_7 System 
manufacturer System Product Name/Crosshair IV Formula
<4>[  363.117151] RIP: 0010:[]  [] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
<4>[  363.117151] RSP: 0018:880234281920  EFLAGS: 00010246
<4>[  363.117151] RAX: 001e12e8 RBX:  RCX: 
002ab980
<4>[  363.117151] RDX: 0004 RSI:  RDI: 
0005
<4>[  363.117151] RBP: 880234281940 R08:  R09: 

<4>[  363.117151] R10:  R11:  R12: 
880218ce7400
<4>[  363.117151] R13:  R14:  R15: 

<4>[  363.117151] FS:  7f499ffe0700() GS:88003100() 
knlGS:
<4>[  363.117151] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
<4>[  363.117151] CR2:  CR3: 000230af7000 CR4: 
06e0
<4>[  363.117151] DR0:  DR1:  DR2: 

<4>[  363.117151] DR3:  DR6: 0ff0 DR7: 
0400
<4>[  363.117151] Process kondemand/5 (pid: 1690, veid: 0, threadinfo 
88023428, task 8802330c48c0)
<4>[  363.117151] Stack:
<4>[  363.117151]  810cf4f3 0001  
a11a7ac0
<4>[  363.117151]  880234281990 815454a8 880234281c80 

<4>[  363.117151]  880234281a10 833be978 833be8e0 
0001
<4>[  363.117151] Call Trace:
<4>[  363.117151]  [] ? is_module_text_address+0x23/0x30
<4>[  363.117151]  [] notifier_call_chain+0x58/0xb0
<4>[  363.117151]  [] __srcu_notifier_call_chain+0x5d/0x90
<4>[  363.117151]  [] srcu_notifier_call_chain+0x16/0x20
<4>[  363.117151]  [] cpufreq_notify_transition+0x12a/0x190
<4>[  363.117151]  [] powernowk8_target+0x628/0xb30 
[powernow_k8]
<4>[  363.117151]  [] __cpufreq_driver_target+0x8b/0x90
<4>[  363.117151]  [] do_dbs_timer+0x3b8/0x3bc 
[cpufreq_ondemand]
<4>[  363.117151]  [] ? do_dbs_timer+0x0/0x3bc 
[cpufreq_ondemand]
<4>[  363.117151]  [] worker_thread+0x264/0x440
<4>[  363.117151]  [] ? worker_thread+0x213/0x440
<4>[  363.117151]  [] ? worker_thread+0x0/0x440
<4>[  363.117151]  [] ? autoremove_wake_function+0x0/0x40
<4>[  363.117151]  [] ? worker_thread+0x0/0x440
<4>[  363.117151]  [] kthread+0x96/0xa0
<4>[  363.117151]  [] child_rip+0xa/0x20
<4>[  363.117151]  [] ? restore_args+0x0/0x30
<4>[  363.117151]  [] ? kthread+0x0/0xa0
<4>[  363.117151]  [] ? child_rip+0x0/0x20
<4>[  363.117151] Code: 89 f9 48 8b 0c cd 20 53 9c 81 4c 8b 24 08 4d 85 e4 74 d3 8b 
4a 08 41 8b 54 24 10 45 8b 6c 24 18 85 d2 74 22 49 8b 74 24 28 31 db<3b>  0e 75 10 eb 
1a 66 0f 1f 44 00 00 48 63 c3 3b 0c 86 74 0c 83
<1>[  363.117151] RIP  [] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
<4>[  363.117151]  RSP
<4>[  363.117151] CR2: 
---
  drivers/cpufreq/cpufreq_stats.c |   11 +++
  1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index e40e508..9d7732b 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -364,18 +364,21 @@ static int __init cpufreq_stats_init(void)
if (ret)
return ret;

+   register_hotcpu_notifier(_stat_cpu_notifier);
+   for_each_online_cpu(cpu)
+   cpufreq_update_policy(cpu);
+
ret = cpufreq_register_notifier(_trans_block,
CPUFREQ_TRANSITION_NOTIFIER);
if (ret) {
cpufreq_unregister_notifier(_policy_block,
CPUFREQ_POLICY_NOTIFIER);
+   unregister_hotcpu_notifier(_stat_cpu_notifier);
+

Re: [PATCH] cpufreq_stats: fix race between stats allocation and first usage

2012-12-14 Thread Rafael J. Wysocki
On Friday, December 14, 2012 02:59:21 PM Konstantin Khlebnikov wrote:
> This patch forces complete struct cpufreq_stats allocation for all cpus before
> registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some conditions
> cpufreq_stat_notifier_trans() can be called in the middle of stats allocation,
> in this case cpufreq_stats_table already exists, but stat->freq_table is NULL.

I'll queue it up for submission as v3.8 material.

Does it need to be marked as -stable material too?

Rafael


> Signed-off-by: Konstantin Khlebnikov 
> Cc: Rafael J. Wysocki 
> Cc: cpufreq 
> Cc: linux-pm 
> 
> ---
> 
> <1>[  363.116198] BUG: unable to handle kernel NULL pointer dereference at 
> (null)
> <1>[  363.116668] IP: [] 
> cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
> <4>[  363.116977] PGD 23177e067 PUD 2349c1067 PMD 0
> <4>[  363.117151] Oops:  [#1] SMP
> <4>[  363.117151] last sysfs file: /sys/module/freq_table/initstate
> <4>[  363.117151] CPU 5
> <4>[  363.117151] Modules linked in: cpufreq_stats(+)(U) [a lot] [last 
> unloaded: umc]
> <4>[  363.117151]
> <4>[  363.117151] Pid: 1690, comm: kondemand/5 veid: 0 Tainted: PWC 
> ---  T 2.6.32-279.5.1.el6-042stab061.7-vz #112 042stab061_7 
> System manufacturer System Product Name/Crosshair IV Formula
> <4>[  363.117151] RIP: 0010:[]  [] 
> cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
> <4>[  363.117151] RSP: 0018:880234281920  EFLAGS: 00010246
> <4>[  363.117151] RAX: 001e12e8 RBX:  RCX: 
> 002ab980
> <4>[  363.117151] RDX: 0004 RSI:  RDI: 
> 0005
> <4>[  363.117151] RBP: 880234281940 R08:  R09: 
> 
> <4>[  363.117151] R10:  R11:  R12: 
> 880218ce7400
> <4>[  363.117151] R13:  R14:  R15: 
> 
> <4>[  363.117151] FS:  7f499ffe0700() GS:88003100() 
> knlGS:
> <4>[  363.117151] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
> <4>[  363.117151] CR2:  CR3: 000230af7000 CR4: 
> 06e0
> <4>[  363.117151] DR0:  DR1:  DR2: 
> 
> <4>[  363.117151] DR3:  DR6: 0ff0 DR7: 
> 0400
> <4>[  363.117151] Process kondemand/5 (pid: 1690, veid: 0, threadinfo 
> 88023428, task 8802330c48c0)
> <4>[  363.117151] Stack:
> <4>[  363.117151]  810cf4f3 0001  
> a11a7ac0
> <4>[  363.117151]  880234281990 815454a8 880234281c80 
> 
> <4>[  363.117151]  880234281a10 833be978 833be8e0 
> 0001
> <4>[  363.117151] Call Trace:
> <4>[  363.117151]  [] ? is_module_text_address+0x23/0x30
> <4>[  363.117151]  [] notifier_call_chain+0x58/0xb0
> <4>[  363.117151]  [] __srcu_notifier_call_chain+0x5d/0x90
> <4>[  363.117151]  [] srcu_notifier_call_chain+0x16/0x20
> <4>[  363.117151]  [] cpufreq_notify_transition+0x12a/0x190
> <4>[  363.117151]  [] powernowk8_target+0x628/0xb30 
> [powernow_k8]
> <4>[  363.117151]  [] __cpufreq_driver_target+0x8b/0x90
> <4>[  363.117151]  [] do_dbs_timer+0x3b8/0x3bc 
> [cpufreq_ondemand]
> <4>[  363.117151]  [] ? do_dbs_timer+0x0/0x3bc 
> [cpufreq_ondemand]
> <4>[  363.117151]  [] worker_thread+0x264/0x440
> <4>[  363.117151]  [] ? worker_thread+0x213/0x440
> <4>[  363.117151]  [] ? worker_thread+0x0/0x440
> <4>[  363.117151]  [] ? autoremove_wake_function+0x0/0x40
> <4>[  363.117151]  [] ? worker_thread+0x0/0x440
> <4>[  363.117151]  [] kthread+0x96/0xa0
> <4>[  363.117151]  [] child_rip+0xa/0x20
> <4>[  363.117151]  [] ? restore_args+0x0/0x30
> <4>[  363.117151]  [] ? kthread+0x0/0xa0
> <4>[  363.117151]  [] ? child_rip+0x0/0x20
> <4>[  363.117151] Code: 89 f9 48 8b 0c cd 20 53 9c 81 4c 8b 24 08 4d 85 e4 74 
> d3 8b 4a 08 41 8b 54 24 10 45 8b 6c 24 18 85 d2 74 22 49 8b 74 24 28 31 db 
> <3b> 0e 75 10 eb 1a 66 0f 1f 44 00 00 48 63 c3 3b 0c 86 74 0c 83
> <1>[  363.117151] RIP  [] 
> cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
> <4>[  363.117151]  RSP 
> <4>[  363.117151] CR2: 
> ---
>  drivers/cpufreq/cpufreq_stats.c |   11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index e40e508..9d7732b 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -364,18 +364,21 @@ static int __init cpufreq_stats_init(void)
>   if (ret)
>   return ret;
>  
> + register_hotcpu_notifier(_stat_cpu_notifier);
> + for_each_online_cpu(cpu)
> + cpufreq_update_policy(cpu);
> +
>   ret = cpufreq_register_notifier(_trans_block,
>   CPUFREQ_TRANSITION_NOTIFIER);
>   if (ret) {
>   cpufreq_unregister_notifier(_policy_block,
>  

[PATCH] cpufreq_stats: fix race between stats allocation and first usage

2012-12-14 Thread Konstantin Khlebnikov
This patch forces complete struct cpufreq_stats allocation for all cpus before
registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some conditions
cpufreq_stat_notifier_trans() can be called in the middle of stats allocation,
in this case cpufreq_stats_table already exists, but stat->freq_table is NULL.

Signed-off-by: Konstantin Khlebnikov 
Cc: Rafael J. Wysocki 
Cc: cpufreq 
Cc: linux-pm 

---

<1>[  363.116198] BUG: unable to handle kernel NULL pointer dereference at 
(null)
<1>[  363.116668] IP: [] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
<4>[  363.116977] PGD 23177e067 PUD 2349c1067 PMD 0
<4>[  363.117151] Oops:  [#1] SMP
<4>[  363.117151] last sysfs file: /sys/module/freq_table/initstate
<4>[  363.117151] CPU 5
<4>[  363.117151] Modules linked in: cpufreq_stats(+)(U) [a lot] [last 
unloaded: umc]
<4>[  363.117151]
<4>[  363.117151] Pid: 1690, comm: kondemand/5 veid: 0 Tainted: PWC 
---  T 2.6.32-279.5.1.el6-042stab061.7-vz #112 042stab061_7 System 
manufacturer System Product Name/Crosshair IV Formula
<4>[  363.117151] RIP: 0010:[]  [] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
<4>[  363.117151] RSP: 0018:880234281920  EFLAGS: 00010246
<4>[  363.117151] RAX: 001e12e8 RBX:  RCX: 
002ab980
<4>[  363.117151] RDX: 0004 RSI:  RDI: 
0005
<4>[  363.117151] RBP: 880234281940 R08:  R09: 

<4>[  363.117151] R10:  R11:  R12: 
880218ce7400
<4>[  363.117151] R13:  R14:  R15: 

<4>[  363.117151] FS:  7f499ffe0700() GS:88003100() 
knlGS:
<4>[  363.117151] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
<4>[  363.117151] CR2:  CR3: 000230af7000 CR4: 
06e0
<4>[  363.117151] DR0:  DR1:  DR2: 

<4>[  363.117151] DR3:  DR6: 0ff0 DR7: 
0400
<4>[  363.117151] Process kondemand/5 (pid: 1690, veid: 0, threadinfo 
88023428, task 8802330c48c0)
<4>[  363.117151] Stack:
<4>[  363.117151]  810cf4f3 0001  
a11a7ac0
<4>[  363.117151]  880234281990 815454a8 880234281c80 

<4>[  363.117151]  880234281a10 833be978 833be8e0 
0001
<4>[  363.117151] Call Trace:
<4>[  363.117151]  [] ? is_module_text_address+0x23/0x30
<4>[  363.117151]  [] notifier_call_chain+0x58/0xb0
<4>[  363.117151]  [] __srcu_notifier_call_chain+0x5d/0x90
<4>[  363.117151]  [] srcu_notifier_call_chain+0x16/0x20
<4>[  363.117151]  [] cpufreq_notify_transition+0x12a/0x190
<4>[  363.117151]  [] powernowk8_target+0x628/0xb30 
[powernow_k8]
<4>[  363.117151]  [] __cpufreq_driver_target+0x8b/0x90
<4>[  363.117151]  [] do_dbs_timer+0x3b8/0x3bc 
[cpufreq_ondemand]
<4>[  363.117151]  [] ? do_dbs_timer+0x0/0x3bc 
[cpufreq_ondemand]
<4>[  363.117151]  [] worker_thread+0x264/0x440
<4>[  363.117151]  [] ? worker_thread+0x213/0x440
<4>[  363.117151]  [] ? worker_thread+0x0/0x440
<4>[  363.117151]  [] ? autoremove_wake_function+0x0/0x40
<4>[  363.117151]  [] ? worker_thread+0x0/0x440
<4>[  363.117151]  [] kthread+0x96/0xa0
<4>[  363.117151]  [] child_rip+0xa/0x20
<4>[  363.117151]  [] ? restore_args+0x0/0x30
<4>[  363.117151]  [] ? kthread+0x0/0xa0
<4>[  363.117151]  [] ? child_rip+0x0/0x20
<4>[  363.117151] Code: 89 f9 48 8b 0c cd 20 53 9c 81 4c 8b 24 08 4d 85 e4 74 
d3 8b 4a 08 41 8b 54 24 10 45 8b 6c 24 18 85 d2 74 22 49 8b 74 24 28 31 db <3b> 
0e 75 10 eb 1a 66 0f 1f 44 00 00 48 63 c3 3b 0c 86 74 0c 83
<1>[  363.117151] RIP  [] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
<4>[  363.117151]  RSP 
<4>[  363.117151] CR2: 
---
 drivers/cpufreq/cpufreq_stats.c |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index e40e508..9d7732b 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -364,18 +364,21 @@ static int __init cpufreq_stats_init(void)
if (ret)
return ret;
 
+   register_hotcpu_notifier(_stat_cpu_notifier);
+   for_each_online_cpu(cpu)
+   cpufreq_update_policy(cpu);
+
ret = cpufreq_register_notifier(_trans_block,
CPUFREQ_TRANSITION_NOTIFIER);
if (ret) {
cpufreq_unregister_notifier(_policy_block,
CPUFREQ_POLICY_NOTIFIER);
+   unregister_hotcpu_notifier(_stat_cpu_notifier);
+   for_each_online_cpu(cpu)
+   cpufreq_stats_free_table(cpu);
return ret;
}
 
-   register_hotcpu_notifier(_stat_cpu_notifier);
-   for_each_online_cpu(cpu) {
-   cpufreq_update_policy(cpu);
-   

[PATCH] cpufreq_stats: fix race between stats allocation and first usage

2012-12-14 Thread Konstantin Khlebnikov
This patch forces complete struct cpufreq_stats allocation for all cpus before
registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some conditions
cpufreq_stat_notifier_trans() can be called in the middle of stats allocation,
in this case cpufreq_stats_table already exists, but stat-freq_table is NULL.

Signed-off-by: Konstantin Khlebnikov khlebni...@openvz.org
Cc: Rafael J. Wysocki r...@sisk.pl
Cc: cpufreq cpuf...@vger.kernel.org
Cc: linux-pm linux...@vger.kernel.org

---

1[  363.116198] BUG: unable to handle kernel NULL pointer dereference at 
(null)
1[  363.116668] IP: [a11a70e4] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
4[  363.116977] PGD 23177e067 PUD 2349c1067 PMD 0
4[  363.117151] Oops:  [#1] SMP
4[  363.117151] last sysfs file: /sys/module/freq_table/initstate
4[  363.117151] CPU 5
4[  363.117151] Modules linked in: cpufreq_stats(+)(U) [a lot] [last 
unloaded: umc]
4[  363.117151]
4[  363.117151] Pid: 1690, comm: kondemand/5 veid: 0 Tainted: PWC 
---  T 2.6.32-279.5.1.el6-042stab061.7-vz #112 042stab061_7 System 
manufacturer System Product Name/Crosshair IV Formula
4[  363.117151] RIP: 0010:[a11a70e4]  [a11a70e4] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
4[  363.117151] RSP: 0018:880234281920  EFLAGS: 00010246
4[  363.117151] RAX: 001e12e8 RBX:  RCX: 
002ab980
4[  363.117151] RDX: 0004 RSI:  RDI: 
0005
4[  363.117151] RBP: 880234281940 R08:  R09: 

4[  363.117151] R10:  R11:  R12: 
880218ce7400
4[  363.117151] R13:  R14:  R15: 

4[  363.117151] FS:  7f499ffe0700() GS:88003100() 
knlGS:
4[  363.117151] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
4[  363.117151] CR2:  CR3: 000230af7000 CR4: 
06e0
4[  363.117151] DR0:  DR1:  DR2: 

4[  363.117151] DR3:  DR6: 0ff0 DR7: 
0400
4[  363.117151] Process kondemand/5 (pid: 1690, veid: 0, threadinfo 
88023428, task 8802330c48c0)
4[  363.117151] Stack:
4[  363.117151]  810cf4f3 0001  
a11a7ac0
4[  363.117151] d 880234281990 815454a8 880234281c80 

4[  363.117151] d 880234281a10 833be978 833be8e0 
0001
4[  363.117151] Call Trace:
4[  363.117151]  [810cf4f3] ? is_module_text_address+0x23/0x30
4[  363.117151]  [815454a8] notifier_call_chain+0x58/0xb0
4[  363.117151]  [810a5a8d] __srcu_notifier_call_chain+0x5d/0x90
4[  363.117151]  [810a5ad6] srcu_notifier_call_chain+0x16/0x20
4[  363.117151]  [81442a0a] cpufreq_notify_transition+0x12a/0x190
4[  363.117151]  [a026df08] powernowk8_target+0x628/0xb30 
[powernow_k8]
4[  363.117151]  [8144289b] __cpufreq_driver_target+0x8b/0x90
4[  363.117151]  [a0279388] do_dbs_timer+0x3b8/0x3bc 
[cpufreq_ondemand]
4[  363.117151]  [a0278fd0] ? do_dbs_timer+0x0/0x3bc 
[cpufreq_ondemand]
4[  363.117151]  [81097df4] worker_thread+0x264/0x440
4[  363.117151]  [81097da3] ? worker_thread+0x213/0x440
4[  363.117151]  [81097b90] ? worker_thread+0x0/0x440
4[  363.117151]  [8109f050] ? autoremove_wake_function+0x0/0x40
4[  363.117151]  [81097b90] ? worker_thread+0x0/0x440
4[  363.117151]  [8109e986] kthread+0x96/0xa0
4[  363.117151]  [8100c34a] child_rip+0xa/0x20
4[  363.117151]  [8100bc90] ? restore_args+0x0/0x30
4[  363.117151]  [8109e8f0] ? kthread+0x0/0xa0
4[  363.117151]  [8100c340] ? child_rip+0x0/0x20
4[  363.117151] Code: 89 f9 48 8b 0c cd 20 53 9c 81 4c 8b 24 08 4d 85 e4 74 
d3 8b 4a 08 41 8b 54 24 10 45 8b 6c 24 18 85 d2 74 22 49 8b 74 24 28 31 db 3b 
0e 75 10 eb 1a 66 0f 1f 44 00 00 48 63 c3 3b 0c 86 74 0c 83
1[  363.117151] RIP  [a11a70e4] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
4[  363.117151]  RSP 880234281920
4[  363.117151] CR2: 
---
 drivers/cpufreq/cpufreq_stats.c |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index e40e508..9d7732b 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -364,18 +364,21 @@ static int __init cpufreq_stats_init(void)
if (ret)
return ret;
 
+   register_hotcpu_notifier(cpufreq_stat_cpu_notifier);
+   for_each_online_cpu(cpu)
+   cpufreq_update_policy(cpu);
+
ret = cpufreq_register_notifier(notifier_trans_block,
CPUFREQ_TRANSITION_NOTIFIER);
if (ret) {
cpufreq_unregister_notifier(notifier_policy_block,
 

Re: [PATCH] cpufreq_stats: fix race between stats allocation and first usage

2012-12-14 Thread Rafael J. Wysocki
On Friday, December 14, 2012 02:59:21 PM Konstantin Khlebnikov wrote:
 This patch forces complete struct cpufreq_stats allocation for all cpus before
 registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some conditions
 cpufreq_stat_notifier_trans() can be called in the middle of stats allocation,
 in this case cpufreq_stats_table already exists, but stat-freq_table is NULL.

I'll queue it up for submission as v3.8 material.

Does it need to be marked as -stable material too?

Rafael


 Signed-off-by: Konstantin Khlebnikov khlebni...@openvz.org
 Cc: Rafael J. Wysocki r...@sisk.pl
 Cc: cpufreq cpuf...@vger.kernel.org
 Cc: linux-pm linux...@vger.kernel.org
 
 ---
 
 1[  363.116198] BUG: unable to handle kernel NULL pointer dereference at 
 (null)
 1[  363.116668] IP: [a11a70e4] 
 cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
 4[  363.116977] PGD 23177e067 PUD 2349c1067 PMD 0
 4[  363.117151] Oops:  [#1] SMP
 4[  363.117151] last sysfs file: /sys/module/freq_table/initstate
 4[  363.117151] CPU 5
 4[  363.117151] Modules linked in: cpufreq_stats(+)(U) [a lot] [last 
 unloaded: umc]
 4[  363.117151]
 4[  363.117151] Pid: 1690, comm: kondemand/5 veid: 0 Tainted: PWC 
 ---  T 2.6.32-279.5.1.el6-042stab061.7-vz #112 042stab061_7 
 System manufacturer System Product Name/Crosshair IV Formula
 4[  363.117151] RIP: 0010:[a11a70e4]  [a11a70e4] 
 cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
 4[  363.117151] RSP: 0018:880234281920  EFLAGS: 00010246
 4[  363.117151] RAX: 001e12e8 RBX:  RCX: 
 002ab980
 4[  363.117151] RDX: 0004 RSI:  RDI: 
 0005
 4[  363.117151] RBP: 880234281940 R08:  R09: 
 
 4[  363.117151] R10:  R11:  R12: 
 880218ce7400
 4[  363.117151] R13:  R14:  R15: 
 
 4[  363.117151] FS:  7f499ffe0700() GS:88003100() 
 knlGS:
 4[  363.117151] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
 4[  363.117151] CR2:  CR3: 000230af7000 CR4: 
 06e0
 4[  363.117151] DR0:  DR1:  DR2: 
 
 4[  363.117151] DR3:  DR6: 0ff0 DR7: 
 0400
 4[  363.117151] Process kondemand/5 (pid: 1690, veid: 0, threadinfo 
 88023428, task 8802330c48c0)
 4[  363.117151] Stack:
 4[  363.117151]  810cf4f3 0001  
 a11a7ac0
 4[  363.117151] d 880234281990 815454a8 880234281c80 
 
 4[  363.117151] d 880234281a10 833be978 833be8e0 
 0001
 4[  363.117151] Call Trace:
 4[  363.117151]  [810cf4f3] ? is_module_text_address+0x23/0x30
 4[  363.117151]  [815454a8] notifier_call_chain+0x58/0xb0
 4[  363.117151]  [810a5a8d] __srcu_notifier_call_chain+0x5d/0x90
 4[  363.117151]  [810a5ad6] srcu_notifier_call_chain+0x16/0x20
 4[  363.117151]  [81442a0a] cpufreq_notify_transition+0x12a/0x190
 4[  363.117151]  [a026df08] powernowk8_target+0x628/0xb30 
 [powernow_k8]
 4[  363.117151]  [8144289b] __cpufreq_driver_target+0x8b/0x90
 4[  363.117151]  [a0279388] do_dbs_timer+0x3b8/0x3bc 
 [cpufreq_ondemand]
 4[  363.117151]  [a0278fd0] ? do_dbs_timer+0x0/0x3bc 
 [cpufreq_ondemand]
 4[  363.117151]  [81097df4] worker_thread+0x264/0x440
 4[  363.117151]  [81097da3] ? worker_thread+0x213/0x440
 4[  363.117151]  [81097b90] ? worker_thread+0x0/0x440
 4[  363.117151]  [8109f050] ? autoremove_wake_function+0x0/0x40
 4[  363.117151]  [81097b90] ? worker_thread+0x0/0x440
 4[  363.117151]  [8109e986] kthread+0x96/0xa0
 4[  363.117151]  [8100c34a] child_rip+0xa/0x20
 4[  363.117151]  [8100bc90] ? restore_args+0x0/0x30
 4[  363.117151]  [8109e8f0] ? kthread+0x0/0xa0
 4[  363.117151]  [8100c340] ? child_rip+0x0/0x20
 4[  363.117151] Code: 89 f9 48 8b 0c cd 20 53 9c 81 4c 8b 24 08 4d 85 e4 74 
 d3 8b 4a 08 41 8b 54 24 10 45 8b 6c 24 18 85 d2 74 22 49 8b 74 24 28 31 db 
 3b 0e 75 10 eb 1a 66 0f 1f 44 00 00 48 63 c3 3b 0c 86 74 0c 83
 1[  363.117151] RIP  [a11a70e4] 
 cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
 4[  363.117151]  RSP 880234281920
 4[  363.117151] CR2: 
 ---
  drivers/cpufreq/cpufreq_stats.c |   11 +++
  1 file changed, 7 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
 index e40e508..9d7732b 100644
 --- a/drivers/cpufreq/cpufreq_stats.c
 +++ b/drivers/cpufreq/cpufreq_stats.c
 @@ -364,18 +364,21 @@ static int __init cpufreq_stats_init(void)
   if (ret)
   return ret;
  
 + register_hotcpu_notifier(cpufreq_stat_cpu_notifier);
 + 

Re: [PATCH] cpufreq_stats: fix race between stats allocation and first usage

2012-12-14 Thread Konstantin Khlebnikov

Rafael J. Wysocki wrote:

On Friday, December 14, 2012 02:59:21 PM Konstantin Khlebnikov wrote:

This patch forces complete struct cpufreq_stats allocation for all cpus before
registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some conditions
cpufreq_stat_notifier_trans() can be called in the middle of stats allocation,
in this case cpufreq_stats_table already exists, but stat-freq_table is NULL.


I'll queue it up for submission as v3.8 material.

Does it need to be marked as -stable material too?


It's very old and rare bug. I think you can leave it as is.



Rafael



Signed-off-by: Konstantin Khlebnikovkhlebni...@openvz.org
Cc: Rafael J. Wysockir...@sisk.pl
Cc: cpufreqcpuf...@vger.kernel.org
Cc: linux-pmlinux...@vger.kernel.org

---

1[  363.116198] BUG: unable to handle kernel NULL pointer dereference at 
(null)
1[  363.116668] IP: [a11a70e4] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
4[  363.116977] PGD 23177e067 PUD 2349c1067 PMD 0
4[  363.117151] Oops:  [#1] SMP
4[  363.117151] last sysfs file: /sys/module/freq_table/initstate
4[  363.117151] CPU 5
4[  363.117151] Modules linked in: cpufreq_stats(+)(U) [a lot] [last 
unloaded: umc]
4[  363.117151]
4[  363.117151] Pid: 1690, comm: kondemand/5 veid: 0 Tainted: PWC 
---  T 2.6.32-279.5.1.el6-042stab061.7-vz #112 042stab061_7 System 
manufacturer System Product Name/Crosshair IV Formula
4[  363.117151] RIP: 0010:[a11a70e4]  [a11a70e4] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
4[  363.117151] RSP: 0018:880234281920  EFLAGS: 00010246
4[  363.117151] RAX: 001e12e8 RBX:  RCX: 
002ab980
4[  363.117151] RDX: 0004 RSI:  RDI: 
0005
4[  363.117151] RBP: 880234281940 R08:  R09: 

4[  363.117151] R10:  R11:  R12: 
880218ce7400
4[  363.117151] R13:  R14:  R15: 

4[  363.117151] FS:  7f499ffe0700() GS:88003100() 
knlGS:
4[  363.117151] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
4[  363.117151] CR2:  CR3: 000230af7000 CR4: 
06e0
4[  363.117151] DR0:  DR1:  DR2: 

4[  363.117151] DR3:  DR6: 0ff0 DR7: 
0400
4[  363.117151] Process kondemand/5 (pid: 1690, veid: 0, threadinfo 
88023428, task 8802330c48c0)
4[  363.117151] Stack:
4[  363.117151]  810cf4f3 0001  
a11a7ac0
4[  363.117151]d  880234281990 815454a8 880234281c80 

4[  363.117151]d  880234281a10 833be978 833be8e0 
0001
4[  363.117151] Call Trace:
4[  363.117151]  [810cf4f3] ? is_module_text_address+0x23/0x30
4[  363.117151]  [815454a8] notifier_call_chain+0x58/0xb0
4[  363.117151]  [810a5a8d] __srcu_notifier_call_chain+0x5d/0x90
4[  363.117151]  [810a5ad6] srcu_notifier_call_chain+0x16/0x20
4[  363.117151]  [81442a0a] cpufreq_notify_transition+0x12a/0x190
4[  363.117151]  [a026df08] powernowk8_target+0x628/0xb30 
[powernow_k8]
4[  363.117151]  [8144289b] __cpufreq_driver_target+0x8b/0x90
4[  363.117151]  [a0279388] do_dbs_timer+0x3b8/0x3bc 
[cpufreq_ondemand]
4[  363.117151]  [a0278fd0] ? do_dbs_timer+0x0/0x3bc 
[cpufreq_ondemand]
4[  363.117151]  [81097df4] worker_thread+0x264/0x440
4[  363.117151]  [81097da3] ? worker_thread+0x213/0x440
4[  363.117151]  [81097b90] ? worker_thread+0x0/0x440
4[  363.117151]  [8109f050] ? autoremove_wake_function+0x0/0x40
4[  363.117151]  [81097b90] ? worker_thread+0x0/0x440
4[  363.117151]  [8109e986] kthread+0x96/0xa0
4[  363.117151]  [8100c34a] child_rip+0xa/0x20
4[  363.117151]  [8100bc90] ? restore_args+0x0/0x30
4[  363.117151]  [8109e8f0] ? kthread+0x0/0xa0
4[  363.117151]  [8100c340] ? child_rip+0x0/0x20
4[  363.117151] Code: 89 f9 48 8b 0c cd 20 53 9c 81 4c 8b 24 08 4d 85 e4 74 d3 8b 
4a 08 41 8b 54 24 10 45 8b 6c 24 18 85 d2 74 22 49 8b 74 24 28 31 db3b  0e 75 10 eb 
1a 66 0f 1f 44 00 00 48 63 c3 3b 0c 86 74 0c 83
1[  363.117151] RIP  [a11a70e4] 
cpufreq_stat_notifier_trans+0x64/0xf0 [cpufreq_stats]
4[  363.117151]  RSP880234281920
4[  363.117151] CR2: 
---
  drivers/cpufreq/cpufreq_stats.c |   11 +++
  1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index e40e508..9d7732b 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -364,18 +364,21 @@ static int __init cpufreq_stats_init(void)
if (ret)
return ret;

+   register_hotcpu_notifier(cpufreq_stat_cpu_notifier);
+