Re: [PATCHv2] perf powerpc: Don't call perf_event_disable from atomic context
From: Jiri Olsa
Date: Mon Oct 24 2016 - 11:49:58 EST
On Mon, Oct 24, 2016 at 02:26:39PM +0200, Peter Zijlstra wrote:
>
>
>
> On Thu, Oct 06, 2016 at 02:33:01PM +0200, Jiri Olsa wrote:
> > diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
> > index aec9a1b1d25b..4d3bcbbf626a 100644
> > --- a/arch/powerpc/kernel/hw_breakpoint.c
> > +++ b/arch/powerpc/kernel/hw_breakpoint.c
> > @@ -275,7 +275,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)
> > if (!stepped) {
> > WARN(1, "Unable to handle hardware breakpoint. Breakpoint at "
> > "0x%lx will be disabled.", info->address);
> > - perf_event_disable(bp);
> > + perf_event_disable_inatomic(bp);
> > goto out;
> > }
> > /*
> > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> > index 5c5362584aba..c794fd84a595 100644
> > --- a/include/linux/perf_event.h
> > +++ b/include/linux/perf_event.h
> > @@ -1248,6 +1248,7 @@ extern u64 perf_swevent_set_period(struct perf_event *event);
> > extern void perf_event_enable(struct perf_event *event);
> > extern void perf_event_disable(struct perf_event *event);
> > extern void perf_event_disable_local(struct perf_event *event);
> > +extern void perf_event_disable_inatomic(struct perf_event *event);
> > extern void perf_event_task_tick(void);
> > #else /* !CONFIG_PERF_EVENTS: */
> > static inline void *
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index 7c0d263f6bc5..3d650ccf4def 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -1960,6 +1960,13 @@ void perf_event_disable(struct perf_event *event)
> > }
> > EXPORT_SYMBOL_GPL(perf_event_disable);
> >
> > +void perf_event_disable_inatomic(struct perf_event *event)
> > +{
> > + event->pending_kill = POLL_HUP;
> > + event->pending_disable = 1;
> > + irq_work_queue(&event->pending);
> > +}
> > +
> > static void perf_set_shadow_time(struct perf_event *event,
> > struct perf_event_context *ctx,
> > u64 tstamp)
> > @@ -7074,9 +7081,7 @@ static int __perf_event_overflow(struct perf_event *event,
> > event->pending_kill = POLL_IN;
> > if (events && atomic_dec_and_test(&event->event_limit)) {
> > ret = 1;
> > - event->pending_kill = POLL_HUP;
> > - event->pending_disable = 1;
> > - irq_work_queue(&event->pending);
> > + perf_event_disable_inatomic(event);
> > }
> >
> > event->overflow_handler(event, data, regs);
>
>
> I'm a wee bit confused on the event->pending_kill assignment in that
> helper. AFAICT that's not actually used in the PPC case, and if for some
> reason, pending_wakeup gets set, do we want to deliver a HUP? The old
> code didn't do that.
right, delivering the signal might change what app is expecting,
how about attached change.. I still need to test it
thanks,
jirka
---
diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 9781c69eae57..58024eecbd9e 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -275,7 +275,7 @@ int hw_breakpoint_handler(struct die_args *args)
if (!stepped) {
WARN(1, "Unable to handle hardware breakpoint. Breakpoint at "
"0x%lx will be disabled.", info->address);
- perf_event_disable(bp);
+ perf_event_disable_inatomic(bp, 0);
goto out;
}
/*
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 060d0ede88df..055bc837bfc1 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1257,6 +1257,7 @@ extern u64 perf_swevent_set_period(struct perf_event *event);
extern void perf_event_enable(struct perf_event *event);
extern void perf_event_disable(struct perf_event *event);
extern void perf_event_disable_local(struct perf_event *event);
+extern void perf_event_disable_inatomic(struct perf_event *event, int kill);
extern void perf_event_task_tick(void);
#else /* !CONFIG_PERF_EVENTS: */
static inline void *
diff --git a/kernel/events/core.c b/kernel/events/core.c
index c6e47e97b33f..04477983945e 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1960,6 +1960,13 @@ void perf_event_disable(struct perf_event *event)
}
EXPORT_SYMBOL_GPL(perf_event_disable);
+void perf_event_disable_inatomic(struct perf_event *event, int kill)
+{
+ event->pending_kill = kill;
+ event->pending_disable = 1;
+ irq_work_queue(&event->pending);
+}
+
static void perf_set_shadow_time(struct perf_event *event,
struct perf_event_context *ctx,
u64 tstamp)
@@ -7074,9 +7081,7 @@ static int __perf_event_overflow(struct perf_event *event,
event->pending_kill = POLL_IN;
if (events && atomic_dec_and_test(&event->event_limit)) {
ret = 1;
- event->pending_kill = POLL_HUP;
- event->pending_disable = 1;
- irq_work_queue(&event->pending);
+ perf_event_disable_inatomic(event, POLL_HUP);
}
READ_ONCE(event->overflow_handler)(event, data, regs);