summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-06-19 18:27:26 +0200
committerIngo Molnar <mingo@elte.hu>2009-06-23 11:42:44 +0200
commitf29ac756a40d0f1bb07d682ea521e7b666ff06d5 (patch)
tree6fabe2f38ae10f824e57fdd5b035ba81b75a71a8 /include/linux
parent3d906ef10a539ff336010afab8f6f9c4fe379695 (diff)
downloadlinux-f29ac756a40d0f1bb07d682ea521e7b666ff06d5.tar.gz
linux-f29ac756a40d0f1bb07d682ea521e7b666ff06d5.tar.bz2
linux-f29ac756a40d0f1bb07d682ea521e7b666ff06d5.zip
perf_counter: Optimize perf_swcounter_event()
Similar to tracepoints, use an enable variable to reduce overhead when unused. Only look for a counter of a particular event type when we know there is at least one in the system. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/perf_counter.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index 89698d8aba5c..e7213e46cf9c 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -669,7 +669,16 @@ static inline int is_software_counter(struct perf_counter *counter)
(counter->attr.type != PERF_TYPE_HW_CACHE);
}
-extern void perf_swcounter_event(u32, u64, int, struct pt_regs *, u64);
+extern atomic_t perf_swcounter_enabled[PERF_COUNT_SW_MAX];
+
+extern void __perf_swcounter_event(u32, u64, int, struct pt_regs *, u64);
+
+static inline void
+perf_swcounter_event(u32 event, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
+{
+ if (atomic_read(&perf_swcounter_enabled[event]))
+ __perf_swcounter_event(event, nr, nmi, regs, addr);
+}
extern void __perf_counter_mmap(struct vm_area_struct *vma);