aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/perf_event.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/perf_event.h')
-rw-r--r--include/linux/perf_event.h59
1 files changed, 58 insertions, 1 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 6f8cd7da1a01..95477038a72a 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -452,6 +452,8 @@ enum perf_callchain_context {
452#include <linux/fs.h> 452#include <linux/fs.h>
453#include <linux/pid_namespace.h> 453#include <linux/pid_namespace.h>
454#include <linux/workqueue.h> 454#include <linux/workqueue.h>
455#include <linux/ftrace.h>
456#include <linux/cpu.h>
455#include <asm/atomic.h> 457#include <asm/atomic.h>
456 458
457#define PERF_MAX_STACK_DEPTH 255 459#define PERF_MAX_STACK_DEPTH 255
@@ -847,6 +849,44 @@ perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
847 __perf_sw_event(event_id, nr, nmi, regs, addr); 849 __perf_sw_event(event_id, nr, nmi, regs, addr);
848} 850}
849 851
852extern void
853perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int skip);
854
855/*
856 * Take a snapshot of the regs. Skip ip and frame pointer to
857 * the nth caller. We only need a few of the regs:
858 * - ip for PERF_SAMPLE_IP
859 * - cs for user_mode() tests
860 * - bp for callchains
861 * - eflags, for future purposes, just in case
862 */
863static inline void perf_fetch_caller_regs(struct pt_regs *regs, int skip)
864{
865 unsigned long ip;
866
867 memset(regs, 0, sizeof(*regs));
868
869 switch (skip) {
870 case 1 :
871 ip = CALLER_ADDR0;
872 break;
873 case 2 :
874 ip = CALLER_ADDR1;
875 break;
876 case 3 :
877 ip = CALLER_ADDR2;
878 break;
879 case 4:
880 ip = CALLER_ADDR3;
881 break;
882 /* No need to support further for now */
883 default:
884 ip = 0;
885 }
886
887 return perf_arch_fetch_caller_regs(regs, ip, skip);
888}
889
850extern void __perf_event_mmap(struct vm_area_struct *vma); 890extern void __perf_event_mmap(struct vm_area_struct *vma);
851 891
852static inline void perf_event_mmap(struct vm_area_struct *vma) 892static inline void perf_event_mmap(struct vm_area_struct *vma)
@@ -880,7 +920,8 @@ static inline bool perf_paranoid_kernel(void)
880} 920}
881 921
882extern void perf_event_init(void); 922extern void perf_event_init(void);
883extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record, int entry_size); 923extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record,
924 int entry_size, struct pt_regs *regs);
884extern void perf_bp_event(struct perf_event *event, void *data); 925extern void perf_bp_event(struct perf_event *event, void *data);
885 926
886#ifndef perf_misc_flags 927#ifndef perf_misc_flags
@@ -936,5 +977,21 @@ static inline void perf_event_disable(struct perf_event *event) { }
936#define perf_output_put(handle, x) \ 977#define perf_output_put(handle, x) \
937 perf_output_copy((handle), &(x), sizeof(x)) 978 perf_output_copy((handle), &(x), sizeof(x))
938 979
980/*
981 * This has to have a higher priority than migration_notifier in sched.c.
982 */
983#define perf_cpu_notifier(fn) \
984do { \
985 static struct notifier_block fn##_nb __cpuinitdata = \
986 { .notifier_call = fn, .priority = 20 }; \
987 fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \
988 (void *)(unsigned long)smp_processor_id()); \
989 fn(&fn##_nb, (unsigned long)CPU_STARTING, \
990 (void *)(unsigned long)smp_processor_id()); \
991 fn(&fn##_nb, (unsigned long)CPU_ONLINE, \
992 (void *)(unsigned long)smp_processor_id()); \
993 register_cpu_notifier(&fn##_nb); \
994} while (0)
995
939#endif /* __KERNEL__ */ 996#endif /* __KERNEL__ */
940#endif /* _LINUX_PERF_EVENT_H */ 997#endif /* _LINUX_PERF_EVENT_H */