提交 7e54a5a0 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

perf: Optimize sw events

Acked-by: NFrederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 82cd6def
...@@ -1012,18 +1012,20 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs) ...@@ -1012,18 +1012,20 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs)
perf_arch_fetch_caller_regs(regs, CALLER_ADDR0); perf_arch_fetch_caller_regs(regs, CALLER_ADDR0);
} }
static inline void static __always_inline void
perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr) perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
{ {
if (atomic_read(&perf_swevent_enabled[event_id])) { struct pt_regs hot_regs;
struct pt_regs hot_regs;
JUMP_LABEL(&perf_swevent_enabled[event_id], have_event);
if (!regs) { return;
perf_fetch_caller_regs(&hot_regs);
regs = &hot_regs; have_event:
} if (!regs) {
__perf_sw_event(event_id, nr, nmi, regs, addr); perf_fetch_caller_regs(&hot_regs);
regs = &hot_regs;
} }
__perf_sw_event(event_id, nr, nmi, regs, addr);
} }
extern void perf_event_mmap(struct vm_area_struct *vma); extern void perf_event_mmap(struct vm_area_struct *vma);
......
...@@ -4669,7 +4669,7 @@ static void sw_perf_event_destroy(struct perf_event *event) ...@@ -4669,7 +4669,7 @@ static void sw_perf_event_destroy(struct perf_event *event)
WARN_ON(event->parent); WARN_ON(event->parent);
atomic_dec(&perf_swevent_enabled[event_id]); jump_label_dec(&perf_swevent_enabled[event_id]);
swevent_hlist_put(event); swevent_hlist_put(event);
} }
...@@ -4699,7 +4699,7 @@ static int perf_swevent_init(struct perf_event *event) ...@@ -4699,7 +4699,7 @@ static int perf_swevent_init(struct perf_event *event)
if (err) if (err)
return err; return err;
atomic_inc(&perf_swevent_enabled[event_id]); jump_label_inc(&perf_swevent_enabled[event_id]);
event->destroy = sw_perf_event_destroy; event->destroy = sw_perf_event_destroy;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册