[PATCH 3.16 14/87] powerpc/perf: add missing put_cpu_var in power_pmu_event_init

2019-10-02 Thread Ben Hutchings
3.16.75-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Jan Stancek 

commit 68de8867ea5d99127e836c23f6bccf4d44859623 upstream.

One path in power_pmu_event_init() calls get_cpu_var(), but is
missing matching call to put_cpu_var(), which causes preemption
imbalance and crash in user-space:

  Page fault in user mode with in_atomic() = 1 mm = c01fefa5a280
  NIP = 3fff9bf2cae0  MSR = 90014280f032
  Oops: Weird page fault, sig: 11 [#23]
  SMP NR_CPUS=2048 NUMA PowerNV
  Modules linked in: 
  CPU: 43 PID: 10285 Comm: a.out Tainted: G  D 4.0.0-rc5+ #1
  task: c01fe82c9200 ti: c01fe835c000 task.ti: c01fe835c000
  NIP: 3fff9bf2cae0 LR: 3fff9bee4898 CTR: 3fff9bf2cae0
  REGS: c01fe835fea0 TRAP: 0401   Tainted: G  D  (4.0.0-rc5+)
  MSR: 90014280f032   CR: 2228  
XER: 
  CFAR: 3fff9bee4894 SOFTE: 1
   GPR00: 3fff9bee494c 3fffe01c2ee0 3fff9c084410 10020068
   GPR04:  0002 0008 0001
   GPR08: 0001 3fff9c074a30 3fff9bf2cae0 3fff9bf2cd70
   GPR12: 5222 3fff9c10b700
  NIP [3fff9bf2cae0] 0x3fff9bf2cae0
  LR [3fff9bee4898] 0x3fff9bee4898
  Call Trace:
  ---[ end trace 5d3d952b5d4185d4 ]---

  BUG: sleeping function called from invalid context at 
kernel/locking/rwsem.c:41
  in_atomic(): 1, irqs_disabled(): 0, pid: 10285, name: a.out
  INFO: lockdep is turned off.
  CPU: 43 PID: 10285 Comm: a.out Tainted: G  D 4.0.0-rc5+ #1
  Call Trace:
  [c01fe835f990] [c089c014] .dump_stack+0x98/0xd4 (unreliable)
  [c01fe835fa10] [c00e4138] .___might_sleep+0x1d8/0x2e0
  [c01fe835faa0] [c0888da8] .down_read+0x38/0x110
  [c01fe835fb30] [c00bf2f4] .exit_signals+0x24/0x160
  [c01fe835fbc0] [c00abde0] .do_exit+0xd0/0xe70
  [c01fe835fcb0] [c001f4c4] .die+0x304/0x450
  [c01fe835fd60] [c088e1f4] .do_page_fault+0x2d4/0x900
  [c01fe835fe30] [c0008664] handle_page_fault+0x10/0x30
  note: a.out[10285] exited with preempt_count 1

Reproducer:
  #include 
  #include 
  #include 
  #include 
  #include 
  #include 
  #include 

  static struct perf_event_attr event = {
  .type = PERF_TYPE_RAW,
  .size = sizeof(struct perf_event_attr),
  .sample_type = PERF_SAMPLE_BRANCH_STACK,
  .branch_sample_type = PERF_SAMPLE_BRANCH_ANY_RETURN,
  };

  int main()
  {
  syscall(__NR_perf_event_open, , 0, -1, -1, 0);
  }

Signed-off-by: Jan Stancek 
Signed-off-by: Michael Ellerman 
Signed-off-by: Ben Hutchings 
---
 arch/powerpc/perf/core-book3s.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1825,8 +1825,10 @@ static int power_pmu_event_init(struct p
cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
event->attr.branch_sample_type);
 
-   if(cpuhw->bhrb_filter == -1)
+   if (cpuhw->bhrb_filter == -1) {
+   put_cpu_var(cpu_hw_events);
return -EOPNOTSUPP;
+   }
}
 
put_cpu_var(cpu_hw_events);



Re: powerpc/perf: add missing put_cpu_var in power_pmu_event_init

2015-03-25 Thread Jan Stancek


- Original Message -
> From: "Michael Ellerman" 
> To: "Jan Stancek" , linuxppc-...@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org, pau...@samba.org, an...@samba.org, 
> t...@kernel.org, c...@linux.com, jo...@redhat.com,
> jstan...@redhat.com, j...@jms.id.au
> Sent: Wednesday, 25 March, 2015 6:25:09 AM
> Subject: Re: powerpc/perf: add missing put_cpu_var in power_pmu_event_init
> 
> On Tue, 2015-24-03 at 12:33:22 UTC, Jan Stancek wrote:
> > One path in power_pmu_event_init() calls get_cpu_var(), but is
> > missing matching call to put_cpu_var(), which causes preemption
> > imbalance and crash in user-space:
> > 
> >   Page fault in user mode with in_atomic() = 1 mm = c01fefa5a280
> >   NIP = 3fff9bf2cae0  MSR = 90014280f032
> >   Oops: Weird page fault, sig: 11 [#23]
> 
> 
> 
> Thanks. But I don't see this. I guess you have CONFIG_PREEMPT enabled?

Hi,

CONFIG_PREEMPT_NOTIFIERS=y
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
# CONFIG_PREEMPT is not set
CONFIG_PREEMPT_COUNT=y

but I think the difference comes from:
  CONFIG_DEBUG_ATOMIC_SLEEP=y

I did following:
- took the default config from RHEL7.1 kernel
- ran 'make oldnoconfig'.
- reproducer didn't trigger anything
- then I added "CONFIG_DEBUG_ATOMIC_SLEEP=y"
- this time reproducer triggered a panic (3 out of 3 attempts)

Here's config from panic-ing kernel: http://fpaste.org/202543/

[  133.957305] Page fault in user mode with in_atomic() = 1 mm = 
c5fc7e80
[  133.957399] NIP = 3fff9be0cae0  MSR = 90014280f032
[  133.957405] Oops: Weird page fault, sig: 11 [#1]
[  133.957409] SMP NR_CPUS=2048 NUMA PowerNV
[  133.957414] Modules linked in: ses enclosure shpchp uio_pdrv_genirq 
powernv_rng uio xfs libcrc32c sr_mod sd_mod cdrom ipr libata tg3 ptp pps_core 
dm_mirror dm_region_hash dm_log dm_mod
[  133.957638] CPU: 16 PID: 6035 Comm: a.out Not tainted 4.0.0-rc5+ #4
[  133.957693] task: c00fea44b640 ti: c00fea5e4000 task.ti: 
c00fea5e4000
[  133.957759] NIP: 3fff9be0cae0 LR: 3fff9bdc4898 CTR: 3fff9be0cae0
[  133.957825] REGS: c00fea5e7ea0 TRAP: 0401   Not tainted  (4.0.0-rc5+)
[  133.957880] MSR: 90014280f032   CR: 
2228  XER: 
[  133.958079] CFAR: 3fff9bdc4894 SOFTE: 1 
GPR00: 3fff9bdc494c 31fef3e0 3fff9bf64410 10020068 
GPR04:  0002 0008 0001 
GPR08: 0001 3fff9bf54a30 3fff9be0cae0 3fff9be0cd70 
GPR12: 5222 3fff9bfeb700 
[  133.958485] NIP [3fff9be0cae0] 0x3fff9be0cae0
[  133.958530] LR [3fff9bdc4898] 0x3fff9bdc4898
[  133.958574] Call Trace:
[  133.958597] ---[ end trace 56ec543903422cd9 ]---
[  133.958642] 
[  135.958709] Kernel panic - not syncing: Fatal exception
[  135.958863] Rebooting in 10 seconds..
[  145.970348] BUG: sleeping function called from invalid context at 
kernel/irq/manage.c:104
[  145.970453] in_atomic(): 1, irqs_disabled(): 1, pid: 6035, name: a.out
[  145.970515] CPU: 16 PID: 6035 Comm: a.out Tainted: G  D 
4.0.0-rc5+ #4
[  145.970588] Call Trace:
[  145.970618] [c00fea5e76d0] [c07c2090] .dump_stack+0x98/0xd4 
(unreliable)
[  145.970707] [c00fea5e7750] [c00d5fe4] .___might_sleep+0x124/0x170
[  145.970782] [c00fea5e77c0] [c0112860] .synchronize_irq+0x40/0xe0
[  145.970857] [c00fea5e7880] [c0112fa8] .__free_irq+0xf8/0x2b0
[  145.970931] [c00fea5e7920] [c0113258] .free_irq+0x78/0x100
[  145.971007] [c00fea5e79b0] [c0067ae8] .opal_shutdown+0x88/0x120
[  145.971081] [c00fea5e7a40] [c0063e88] .pnv_shutdown+0x18/0x30
[  145.971157] [c00fea5e7ab0] [c0020c98] .machine_shutdown+0x38/0x50
[  145.971231] [c00fea5e7b20] [c0020d24] .machine_restart+0x14/0x70
[  145.971307] [c00fea5e7ba0] [c00cdc10] 
.emergency_restart+0x20/0x40
[  145.971393] [c00fea5e7c10] [c07bb0a4] .panic+0x224/0x2a4
[  145.971468] [c00fea5e7cb0] [c001e1fc] .die+0x43c/0x450
[  145.971543] [c00fea5e7d60] [c07b62c4] .do_page_fault+0x2d4/0x8f0
[  145.971618] [c00fea5e7e30] [c0008664] handle_page_fault+0x10/0x30

Regards,
Jan
--
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: powerpc/perf: add missing put_cpu_var in power_pmu_event_init

2015-03-25 Thread Jan Stancek


- Original Message -
 From: Michael Ellerman m...@ellerman.id.au
 To: Jan Stancek jstan...@redhat.com, linuxppc-...@lists.ozlabs.org
 Cc: linux-kernel@vger.kernel.org, pau...@samba.org, an...@samba.org, 
 t...@kernel.org, c...@linux.com, jo...@redhat.com,
 jstan...@redhat.com, j...@jms.id.au
 Sent: Wednesday, 25 March, 2015 6:25:09 AM
 Subject: Re: powerpc/perf: add missing put_cpu_var in power_pmu_event_init
 
 On Tue, 2015-24-03 at 12:33:22 UTC, Jan Stancek wrote:
  One path in power_pmu_event_init() calls get_cpu_var(), but is
  missing matching call to put_cpu_var(), which causes preemption
  imbalance and crash in user-space:
  
Page fault in user mode with in_atomic() = 1 mm = c01fefa5a280
NIP = 3fff9bf2cae0  MSR = 90014280f032
Oops: Weird page fault, sig: 11 [#23]
 
 snip
 
 Thanks. But I don't see this. I guess you have CONFIG_PREEMPT enabled?

Hi,

CONFIG_PREEMPT_NOTIFIERS=y
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
# CONFIG_PREEMPT is not set
CONFIG_PREEMPT_COUNT=y

but I think the difference comes from:
  CONFIG_DEBUG_ATOMIC_SLEEP=y

I did following:
- took the default config from RHEL7.1 kernel
- ran 'make oldnoconfig'.
- reproducer didn't trigger anything
- then I added CONFIG_DEBUG_ATOMIC_SLEEP=y
- this time reproducer triggered a panic (3 out of 3 attempts)

Here's config from panic-ing kernel: http://fpaste.org/202543/

[  133.957305] Page fault in user mode with in_atomic() = 1 mm = 
c5fc7e80
[  133.957399] NIP = 3fff9be0cae0  MSR = 90014280f032
[  133.957405] Oops: Weird page fault, sig: 11 [#1]
[  133.957409] SMP NR_CPUS=2048 NUMA PowerNV
[  133.957414] Modules linked in: ses enclosure shpchp uio_pdrv_genirq 
powernv_rng uio xfs libcrc32c sr_mod sd_mod cdrom ipr libata tg3 ptp pps_core 
dm_mirror dm_region_hash dm_log dm_mod
[  133.957638] CPU: 16 PID: 6035 Comm: a.out Not tainted 4.0.0-rc5+ #4
[  133.957693] task: c00fea44b640 ti: c00fea5e4000 task.ti: 
c00fea5e4000
[  133.957759] NIP: 3fff9be0cae0 LR: 3fff9bdc4898 CTR: 3fff9be0cae0
[  133.957825] REGS: c00fea5e7ea0 TRAP: 0401   Not tainted  (4.0.0-rc5+)
[  133.957880] MSR: 90014280f032 SF,HV,VEC,VSX,EE,PR,FP,ME,IR,DR,RI  CR: 
2228  XER: 
[  133.958079] CFAR: 3fff9bdc4894 SOFTE: 1 
GPR00: 3fff9bdc494c 31fef3e0 3fff9bf64410 10020068 
GPR04:  0002 0008 0001 
GPR08: 0001 3fff9bf54a30 3fff9be0cae0 3fff9be0cd70 
GPR12: 5222 3fff9bfeb700 
[  133.958485] NIP [3fff9be0cae0] 0x3fff9be0cae0
[  133.958530] LR [3fff9bdc4898] 0x3fff9bdc4898
[  133.958574] Call Trace:
[  133.958597] ---[ end trace 56ec543903422cd9 ]---
[  133.958642] 
[  135.958709] Kernel panic - not syncing: Fatal exception
[  135.958863] Rebooting in 10 seconds..
[  145.970348] BUG: sleeping function called from invalid context at 
kernel/irq/manage.c:104
[  145.970453] in_atomic(): 1, irqs_disabled(): 1, pid: 6035, name: a.out
[  145.970515] CPU: 16 PID: 6035 Comm: a.out Tainted: G  D 
4.0.0-rc5+ #4
[  145.970588] Call Trace:
[  145.970618] [c00fea5e76d0] [c07c2090] .dump_stack+0x98/0xd4 
(unreliable)
[  145.970707] [c00fea5e7750] [c00d5fe4] .___might_sleep+0x124/0x170
[  145.970782] [c00fea5e77c0] [c0112860] .synchronize_irq+0x40/0xe0
[  145.970857] [c00fea5e7880] [c0112fa8] .__free_irq+0xf8/0x2b0
[  145.970931] [c00fea5e7920] [c0113258] .free_irq+0x78/0x100
[  145.971007] [c00fea5e79b0] [c0067ae8] .opal_shutdown+0x88/0x120
[  145.971081] [c00fea5e7a40] [c0063e88] .pnv_shutdown+0x18/0x30
[  145.971157] [c00fea5e7ab0] [c0020c98] .machine_shutdown+0x38/0x50
[  145.971231] [c00fea5e7b20] [c0020d24] .machine_restart+0x14/0x70
[  145.971307] [c00fea5e7ba0] [c00cdc10] 
.emergency_restart+0x20/0x40
[  145.971393] [c00fea5e7c10] [c07bb0a4] .panic+0x224/0x2a4
[  145.971468] [c00fea5e7cb0] [c001e1fc] .die+0x43c/0x450
[  145.971543] [c00fea5e7d60] [c07b62c4] .do_page_fault+0x2d4/0x8f0
[  145.971618] [c00fea5e7e30] [c0008664] handle_page_fault+0x10/0x30

Regards,
Jan
--
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: powerpc/perf: add missing put_cpu_var in power_pmu_event_init

2015-03-24 Thread Michael Ellerman
On Tue, 2015-24-03 at 12:33:22 UTC, Jan Stancek wrote:
> One path in power_pmu_event_init() calls get_cpu_var(), but is
> missing matching call to put_cpu_var(), which causes preemption
> imbalance and crash in user-space:
> 
>   Page fault in user mode with in_atomic() = 1 mm = c01fefa5a280
>   NIP = 3fff9bf2cae0  MSR = 90014280f032
>   Oops: Weird page fault, sig: 11 [#23]



Thanks. But I don't see this. I guess you have CONFIG_PREEMPT enabled?

cheers
--
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/


[PATCH] powerpc/perf: add missing put_cpu_var in power_pmu_event_init

2015-03-24 Thread Jan Stancek
One path in power_pmu_event_init() calls get_cpu_var(), but is
missing matching call to put_cpu_var(), which causes preemption
imbalance and crash in user-space:

  Page fault in user mode with in_atomic() = 1 mm = c01fefa5a280
  NIP = 3fff9bf2cae0  MSR = 90014280f032
  Oops: Weird page fault, sig: 11 [#23]
  SMP NR_CPUS=2048 NUMA PowerNV
  Modules linked in: 
  CPU: 43 PID: 10285 Comm: a.out Tainted: G  D 4.0.0-rc5+ #1
  task: c01fe82c9200 ti: c01fe835c000 task.ti: c01fe835c000
  NIP: 3fff9bf2cae0 LR: 3fff9bee4898 CTR: 3fff9bf2cae0
  REGS: c01fe835fea0 TRAP: 0401   Tainted: G  D  (4.0.0-rc5+)
  MSR: 90014280f032   CR: 2228  
XER: 
  CFAR: 3fff9bee4894 SOFTE: 1
   GPR00: 3fff9bee494c 3fffe01c2ee0 3fff9c084410 10020068
   GPR04:  0002 0008 0001
   GPR08: 0001 3fff9c074a30 3fff9bf2cae0 3fff9bf2cd70
   GPR12: 5222 3fff9c10b700
  NIP [3fff9bf2cae0] 0x3fff9bf2cae0
  LR [3fff9bee4898] 0x3fff9bee4898
  Call Trace:
  ---[ end trace 5d3d952b5d4185d4 ]---

  BUG: sleeping function called from invalid context at 
kernel/locking/rwsem.c:41
  in_atomic(): 1, irqs_disabled(): 0, pid: 10285, name: a.out
  INFO: lockdep is turned off.
  CPU: 43 PID: 10285 Comm: a.out Tainted: G  D 4.0.0-rc5+ #1
  Call Trace:
  [c01fe835f990] [c089c014] .dump_stack+0x98/0xd4 (unreliable)
  [c01fe835fa10] [c00e4138] .___might_sleep+0x1d8/0x2e0
  [c01fe835faa0] [c0888da8] .down_read+0x38/0x110
  [c01fe835fb30] [c00bf2f4] .exit_signals+0x24/0x160
  [c01fe835fbc0] [c00abde0] .do_exit+0xd0/0xe70
  [c01fe835fcb0] [c001f4c4] .die+0x304/0x450
  [c01fe835fd60] [c088e1f4] .do_page_fault+0x2d4/0x900
  [c01fe835fe30] [c0008664] handle_page_fault+0x10/0x30
  note: a.out[10285] exited with preempt_count 1

Reproducer:
  #include 
  #include 
  #include 
  #include 
  #include 
  #include 
  #include 

  static struct perf_event_attr event = {
  .type = PERF_TYPE_RAW,
  .size = sizeof(struct perf_event_attr),
  .sample_type = PERF_SAMPLE_BRANCH_STACK,
  .branch_sample_type = PERF_SAMPLE_BRANCH_ANY_RETURN,
  };

  int main()
  {
  syscall(__NR_perf_event_open, , 0, -1, -1, 0);
  }

Signed-off-by: Jan Stancek 
---
 arch/powerpc/perf/core-book3s.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 7c4f669..b101c0b 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1832,8 +1832,10 @@ static int power_pmu_event_init(struct perf_event *event)
cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
event->attr.branch_sample_type);
 
-   if(cpuhw->bhrb_filter == -1)
+   if (cpuhw->bhrb_filter == -1) {
+   put_cpu_var(cpu_hw_events);
return -EOPNOTSUPP;
+   }
}
 
put_cpu_var(cpu_hw_events);
-- 
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/


[PATCH] powerpc/perf: add missing put_cpu_var in power_pmu_event_init

2015-03-24 Thread Jan Stancek
One path in power_pmu_event_init() calls get_cpu_var(), but is
missing matching call to put_cpu_var(), which causes preemption
imbalance and crash in user-space:

  Page fault in user mode with in_atomic() = 1 mm = c01fefa5a280
  NIP = 3fff9bf2cae0  MSR = 90014280f032
  Oops: Weird page fault, sig: 11 [#23]
  SMP NR_CPUS=2048 NUMA PowerNV
  Modules linked in: snip
  CPU: 43 PID: 10285 Comm: a.out Tainted: G  D 4.0.0-rc5+ #1
  task: c01fe82c9200 ti: c01fe835c000 task.ti: c01fe835c000
  NIP: 3fff9bf2cae0 LR: 3fff9bee4898 CTR: 3fff9bf2cae0
  REGS: c01fe835fea0 TRAP: 0401   Tainted: G  D  (4.0.0-rc5+)
  MSR: 90014280f032 SF,HV,VEC,VSX,EE,PR,FP,ME,IR,DR,RI  CR: 2228  
XER: 
  CFAR: 3fff9bee4894 SOFTE: 1
   GPR00: 3fff9bee494c 3fffe01c2ee0 3fff9c084410 10020068
   GPR04:  0002 0008 0001
   GPR08: 0001 3fff9c074a30 3fff9bf2cae0 3fff9bf2cd70
   GPR12: 5222 3fff9c10b700
  NIP [3fff9bf2cae0] 0x3fff9bf2cae0
  LR [3fff9bee4898] 0x3fff9bee4898
  Call Trace:
  ---[ end trace 5d3d952b5d4185d4 ]---

  BUG: sleeping function called from invalid context at 
kernel/locking/rwsem.c:41
  in_atomic(): 1, irqs_disabled(): 0, pid: 10285, name: a.out
  INFO: lockdep is turned off.
  CPU: 43 PID: 10285 Comm: a.out Tainted: G  D 4.0.0-rc5+ #1
  Call Trace:
  [c01fe835f990] [c089c014] .dump_stack+0x98/0xd4 (unreliable)
  [c01fe835fa10] [c00e4138] .___might_sleep+0x1d8/0x2e0
  [c01fe835faa0] [c0888da8] .down_read+0x38/0x110
  [c01fe835fb30] [c00bf2f4] .exit_signals+0x24/0x160
  [c01fe835fbc0] [c00abde0] .do_exit+0xd0/0xe70
  [c01fe835fcb0] [c001f4c4] .die+0x304/0x450
  [c01fe835fd60] [c088e1f4] .do_page_fault+0x2d4/0x900
  [c01fe835fe30] [c0008664] handle_page_fault+0x10/0x30
  note: a.out[10285] exited with preempt_count 1

Reproducer:
  #include stdio.h
  #include unistd.h
  #include syscall.h
  #include sys/types.h
  #include sys/stat.h
  #include linux/perf_event.h
  #include linux/hw_breakpoint.h

  static struct perf_event_attr event = {
  .type = PERF_TYPE_RAW,
  .size = sizeof(struct perf_event_attr),
  .sample_type = PERF_SAMPLE_BRANCH_STACK,
  .branch_sample_type = PERF_SAMPLE_BRANCH_ANY_RETURN,
  };

  int main()
  {
  syscall(__NR_perf_event_open, event, 0, -1, -1, 0);
  }

Signed-off-by: Jan Stancek jstan...@redhat.com
---
 arch/powerpc/perf/core-book3s.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 7c4f669..b101c0b 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1832,8 +1832,10 @@ static int power_pmu_event_init(struct perf_event *event)
cpuhw-bhrb_filter = ppmu-bhrb_filter_map(
event-attr.branch_sample_type);
 
-   if(cpuhw-bhrb_filter == -1)
+   if (cpuhw-bhrb_filter == -1) {
+   put_cpu_var(cpu_hw_events);
return -EOPNOTSUPP;
+   }
}
 
put_cpu_var(cpu_hw_events);
-- 
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: powerpc/perf: add missing put_cpu_var in power_pmu_event_init

2015-03-24 Thread Michael Ellerman
On Tue, 2015-24-03 at 12:33:22 UTC, Jan Stancek wrote:
 One path in power_pmu_event_init() calls get_cpu_var(), but is
 missing matching call to put_cpu_var(), which causes preemption
 imbalance and crash in user-space:
 
   Page fault in user mode with in_atomic() = 1 mm = c01fefa5a280
   NIP = 3fff9bf2cae0  MSR = 90014280f032
   Oops: Weird page fault, sig: 11 [#23]

snip

Thanks. But I don't see this. I guess you have CONFIG_PREEMPT enabled?

cheers
--
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/