diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2010-10-14 16:32:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-10-18 13:58:59 -0400 |
commit | 7e54a5a0b655734326dc78c2b5efc1eb35497bb6 (patch) | |
tree | 71346dfdb01ef387ad1aaaccbf72b3127814ce92 | |
parent | 82cd6def9806dcb6a325fb6abbc1d61388a15f6a (diff) |
perf: Optimize sw events
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/linux/perf_event.h | 20 | ||||
-rw-r--r-- | kernel/perf_event.c | 4 |
2 files changed, 13 insertions, 11 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 7f0e7f52af8b..3b80cbf509ef 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -1012,18 +1012,20 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs) | |||
1012 | perf_arch_fetch_caller_regs(regs, CALLER_ADDR0); | 1012 | perf_arch_fetch_caller_regs(regs, CALLER_ADDR0); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | static inline void | 1015 | static __always_inline void |
1016 | perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr) | 1016 | perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr) |
1017 | { | 1017 | { |
1018 | if (atomic_read(&perf_swevent_enabled[event_id])) { | 1018 | struct pt_regs hot_regs; |
1019 | struct pt_regs hot_regs; | 1019 | |
1020 | 1020 | JUMP_LABEL(&perf_swevent_enabled[event_id], have_event); | |
1021 | if (!regs) { | 1021 | return; |
1022 | perf_fetch_caller_regs(&hot_regs); | 1022 | |
1023 | regs = &hot_regs; | 1023 | have_event: |
1024 | } | 1024 | if (!regs) { |
1025 | __perf_sw_event(event_id, nr, nmi, regs, addr); | 1025 | perf_fetch_caller_regs(&hot_regs); |
1026 | regs = &hot_regs; | ||
1026 | } | 1027 | } |
1028 | __perf_sw_event(event_id, nr, nmi, regs, addr); | ||
1027 | } | 1029 | } |
1028 | 1030 | ||
1029 | extern void perf_event_mmap(struct vm_area_struct *vma); | 1031 | extern void perf_event_mmap(struct vm_area_struct *vma); |
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index f7febb02ab97..05ecf6f7c672 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -4669,7 +4669,7 @@ static void sw_perf_event_destroy(struct perf_event *event) | |||
4669 | 4669 | ||
4670 | WARN_ON(event->parent); | 4670 | WARN_ON(event->parent); |
4671 | 4671 | ||
4672 | atomic_dec(&perf_swevent_enabled[event_id]); | 4672 | jump_label_dec(&perf_swevent_enabled[event_id]); |
4673 | swevent_hlist_put(event); | 4673 | swevent_hlist_put(event); |
4674 | } | 4674 | } |
4675 | 4675 | ||
@@ -4699,7 +4699,7 @@ static int perf_swevent_init(struct perf_event *event) | |||
4699 | if (err) | 4699 | if (err) |
4700 | return err; | 4700 | return err; |
4701 | 4701 | ||
4702 | atomic_inc(&perf_swevent_enabled[event_id]); | 4702 | jump_label_inc(&perf_swevent_enabled[event_id]); |
4703 | event->destroy = sw_perf_event_destroy; | 4703 | event->destroy = sw_perf_event_destroy; |
4704 | } | 4704 | } |
4705 | 4705 | ||