perf: Fix hw breakpoints overflow period sampling
authorJiri Olsa <jolsa@redhat.com>
Wed, 1 May 2013 15:25:44 +0000 (17:25 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 28 May 2013 06:59:54 +0000 (08:59 +0200)
The hw breakpoint pmu 'add' function is missing the
period_left update needed for SW events.

The perf HW breakpoint events use the SW events framework
to process the overflow, so it needs to be properly initialized
in the PMU 'add' method.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Reviewed-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1367421944-19082-5-git-send-email-jolsa@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/perf_event.h
kernel/events/core.c
kernel/events/hw_breakpoint.c

index f463a46424e240715f2cc0c3bbf58f38955db1a8..fa38612d70b662f6afca09bf93282a9bd3c3b51c 100644 (file)
@@ -743,6 +743,7 @@ extern unsigned int perf_output_skip(struct perf_output_handle *handle,
                                     unsigned int len);
 extern int perf_swevent_get_recursion_context(void);
 extern void perf_swevent_put_recursion_context(int rctx);
+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 int __perf_event_disable(void *info);
@@ -782,6 +783,7 @@ static inline void perf_event_fork(struct task_struct *tsk)         { }
 static inline void perf_event_init(void)                               { }
 static inline int  perf_swevent_get_recursion_context(void)            { return -1; }
 static inline void perf_swevent_put_recursion_context(int rctx)                { }
+static inline u64 perf_swevent_set_period(struct perf_event *event)    { return 0; }
 static inline void perf_event_enable(struct perf_event *event)         { }
 static inline void perf_event_disable(struct perf_event *event)                { }
 static inline int __perf_event_disable(void *info)                     { return -1; }
index 9dc297faf7c01b68cbb1a7a24444b99c300cb8a3..e0dcced282e4f67ace8923ff5a57e56c003e3b3c 100644 (file)
@@ -4961,7 +4961,7 @@ static DEFINE_PER_CPU(struct swevent_htable, swevent_htable);
  * sign as trigger.
  */
 
-static u64 perf_swevent_set_period(struct perf_event *event)
+u64 perf_swevent_set_period(struct perf_event *event)
 {
        struct hw_perf_event *hwc = &event->hw;
        u64 period = hwc->last_period;
index a64f8aeb5c1f5adae53fde406b3d904e1485aa80..966a241e86169ab1aab03e44363a003a0c8f89df 100644 (file)
@@ -612,6 +612,11 @@ static int hw_breakpoint_add(struct perf_event *bp, int flags)
        if (!(flags & PERF_EF_START))
                bp->hw.state = PERF_HES_STOPPED;
 
+       if (is_sampling_event(bp)) {
+               bp->hw.last_period = bp->hw.sample_period;
+               perf_swevent_set_period(bp);
+       }
+
        return arch_install_hw_breakpoint(bp);
 }
 
This page took 0.037869 seconds and 5 git commands to generate.