diff options
| author | K.Prasad <Prasad.Krishnan@gmail.com> | 2012-08-02 04:16:35 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2012-09-04 11:29:53 -0400 |
| commit | 500ad2d8b01390c98bc6dce068bccfa9534b8212 (patch) | |
| tree | a7e1330e5380d4cb4be02820a86fbea1dc0da5c9 | |
| parent | 3ec18cd8b8f8395d0df604c62ab3bc2cf3a966b4 (diff) | |
perf/hwpb: Invoke __perf_event_disable() if interrupts are already disabled
While debugging a warning message on PowerPC while using hardware
breakpoints, it was discovered that when perf_event_disable is invoked
through hw_breakpoint_handler function with interrupts disabled, a
subsequent IPI in the code path would trigger a WARN_ON_ONCE message in
smp_call_function_single function.
This patch calls __perf_event_disable() when interrupts are already
disabled, instead of perf_event_disable().
Reported-by: Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
Signed-off-by: K.Prasad <Prasad.Krishnan@gmail.com>
[naveen.n.rao@linux.vnet.ibm.com: v3: Check to make sure we target current task]
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20120802081635.5811.17737.stgit@localhost.localdomain
[ Fixed build error on MIPS. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | include/linux/perf_event.h | 2 | ||||
| -rw-r--r-- | kernel/events/core.c | 2 | ||||
| -rw-r--r-- | kernel/events/hw_breakpoint.c | 11 |
3 files changed, 13 insertions, 2 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index ad04dfcd6f35..33ed9d605f91 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
| @@ -1296,6 +1296,7 @@ extern int perf_swevent_get_recursion_context(void); | |||
| 1296 | extern void perf_swevent_put_recursion_context(int rctx); | 1296 | extern void perf_swevent_put_recursion_context(int rctx); |
| 1297 | extern void perf_event_enable(struct perf_event *event); | 1297 | extern void perf_event_enable(struct perf_event *event); |
| 1298 | extern void perf_event_disable(struct perf_event *event); | 1298 | extern void perf_event_disable(struct perf_event *event); |
| 1299 | extern int __perf_event_disable(void *info); | ||
| 1299 | extern void perf_event_task_tick(void); | 1300 | extern void perf_event_task_tick(void); |
| 1300 | #else | 1301 | #else |
| 1301 | static inline void | 1302 | static inline void |
| @@ -1334,6 +1335,7 @@ static inline int perf_swevent_get_recursion_context(void) { return -1; } | |||
| 1334 | static inline void perf_swevent_put_recursion_context(int rctx) { } | 1335 | static inline void perf_swevent_put_recursion_context(int rctx) { } |
| 1335 | static inline void perf_event_enable(struct perf_event *event) { } | 1336 | static inline void perf_event_enable(struct perf_event *event) { } |
| 1336 | static inline void perf_event_disable(struct perf_event *event) { } | 1337 | static inline void perf_event_disable(struct perf_event *event) { } |
| 1338 | static inline int __perf_event_disable(void *info) { return -1; } | ||
| 1337 | static inline void perf_event_task_tick(void) { } | 1339 | static inline void perf_event_task_tick(void) { } |
| 1338 | #endif | 1340 | #endif |
| 1339 | 1341 | ||
diff --git a/kernel/events/core.c b/kernel/events/core.c index efef4282b8e8..7fee567153f0 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
| @@ -1253,7 +1253,7 @@ retry: | |||
| 1253 | /* | 1253 | /* |
| 1254 | * Cross CPU call to disable a performance event | 1254 | * Cross CPU call to disable a performance event |
| 1255 | */ | 1255 | */ |
| 1256 | static int __perf_event_disable(void *info) | 1256 | int __perf_event_disable(void *info) |
| 1257 | { | 1257 | { |
| 1258 | struct perf_event *event = info; | 1258 | struct perf_event *event = info; |
| 1259 | struct perf_event_context *ctx = event->ctx; | 1259 | struct perf_event_context *ctx = event->ctx; |
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index bb38c4d3ee12..9a7b487c6fe2 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c | |||
| @@ -453,7 +453,16 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att | |||
| 453 | int old_type = bp->attr.bp_type; | 453 | int old_type = bp->attr.bp_type; |
| 454 | int err = 0; | 454 | int err = 0; |
| 455 | 455 | ||
| 456 | perf_event_disable(bp); | 456 | /* |
| 457 | * modify_user_hw_breakpoint can be invoked with IRQs disabled and hence it | ||
| 458 | * will not be possible to raise IPIs that invoke __perf_event_disable. | ||
| 459 | * So call the function directly after making sure we are targeting the | ||
| 460 | * current task. | ||
| 461 | */ | ||
| 462 | if (irqs_disabled() && bp->ctx && bp->ctx->task == current) | ||
| 463 | __perf_event_disable(bp); | ||
| 464 | else | ||
| 465 | perf_event_disable(bp); | ||
| 457 | 466 | ||
| 458 | bp->attr.bp_addr = attr->bp_addr; | 467 | bp->attr.bp_addr = attr->bp_addr; |
| 459 | bp->attr.bp_type = attr->bp_type; | 468 | bp->attr.bp_type = attr->bp_type; |
