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.h69
1 files changed, 60 insertions, 9 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 9e7012689a84..8fa71874113f 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -31,6 +31,7 @@ enum perf_type_id {
31 PERF_TYPE_TRACEPOINT = 2, 31 PERF_TYPE_TRACEPOINT = 2,
32 PERF_TYPE_HW_CACHE = 3, 32 PERF_TYPE_HW_CACHE = 3,
33 PERF_TYPE_RAW = 4, 33 PERF_TYPE_RAW = 4,
34 PERF_TYPE_BREAKPOINT = 5,
34 35
35 PERF_TYPE_MAX, /* non-ABI */ 36 PERF_TYPE_MAX, /* non-ABI */
36}; 37};
@@ -102,6 +103,8 @@ enum perf_sw_ids {
102 PERF_COUNT_SW_CPU_MIGRATIONS = 4, 103 PERF_COUNT_SW_CPU_MIGRATIONS = 4,
103 PERF_COUNT_SW_PAGE_FAULTS_MIN = 5, 104 PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
104 PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6, 105 PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
106 PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
107 PERF_COUNT_SW_EMULATION_FAULTS = 8,
105 108
106 PERF_COUNT_SW_MAX, /* non-ABI */ 109 PERF_COUNT_SW_MAX, /* non-ABI */
107}; 110};
@@ -207,9 +210,12 @@ struct perf_event_attr {
207 __u32 wakeup_events; /* wakeup every n events */ 210 __u32 wakeup_events; /* wakeup every n events */
208 __u32 wakeup_watermark; /* bytes before wakeup */ 211 __u32 wakeup_watermark; /* bytes before wakeup */
209 }; 212 };
213
210 __u32 __reserved_2; 214 __u32 __reserved_2;
211 215
212 __u64 __reserved_3; 216 __u64 bp_addr;
217 __u32 bp_type;
218 __u32 bp_len;
213}; 219};
214 220
215/* 221/*
@@ -219,8 +225,9 @@ struct perf_event_attr {
219#define PERF_EVENT_IOC_DISABLE _IO ('$', 1) 225#define PERF_EVENT_IOC_DISABLE _IO ('$', 1)
220#define PERF_EVENT_IOC_REFRESH _IO ('$', 2) 226#define PERF_EVENT_IOC_REFRESH _IO ('$', 2)
221#define PERF_EVENT_IOC_RESET _IO ('$', 3) 227#define PERF_EVENT_IOC_RESET _IO ('$', 3)
222#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, u64) 228#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64)
223#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5) 229#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5)
230#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *)
224 231
225enum perf_event_ioc_flags { 232enum perf_event_ioc_flags {
226 PERF_IOC_FLAG_GROUP = 1U << 0, 233 PERF_IOC_FLAG_GROUP = 1U << 0,
@@ -434,6 +441,10 @@ enum perf_callchain_context {
434# include <asm/perf_event.h> 441# include <asm/perf_event.h>
435#endif 442#endif
436 443
444#ifdef CONFIG_HAVE_HW_BREAKPOINT
445#include <asm/hw_breakpoint.h>
446#endif
447
437#include <linux/list.h> 448#include <linux/list.h>
438#include <linux/mutex.h> 449#include <linux/mutex.h>
439#include <linux/rculist.h> 450#include <linux/rculist.h>
@@ -475,6 +486,11 @@ struct hw_perf_event {
475 s64 remaining; 486 s64 remaining;
476 struct hrtimer hrtimer; 487 struct hrtimer hrtimer;
477 }; 488 };
489#ifdef CONFIG_HAVE_HW_BREAKPOINT
490 union { /* breakpoint */
491 struct arch_hw_breakpoint info;
492 };
493#endif
478 }; 494 };
479 atomic64_t prev_count; 495 atomic64_t prev_count;
480 u64 sample_period; 496 u64 sample_period;
@@ -543,6 +559,12 @@ struct perf_pending_entry {
543 void (*func)(struct perf_pending_entry *); 559 void (*func)(struct perf_pending_entry *);
544}; 560};
545 561
562struct perf_sample_data;
563
564typedef void (*perf_overflow_handler_t)(struct perf_event *, int,
565 struct perf_sample_data *,
566 struct pt_regs *regs);
567
546/** 568/**
547 * struct perf_event - performance event kernel representation: 569 * struct perf_event - performance event kernel representation:
548 */ 570 */
@@ -585,7 +607,7 @@ struct perf_event {
585 u64 tstamp_running; 607 u64 tstamp_running;
586 u64 tstamp_stopped; 608 u64 tstamp_stopped;
587 609
588 struct perf_event_attr attr; 610 struct perf_event_attr attr;
589 struct hw_perf_event hw; 611 struct hw_perf_event hw;
590 612
591 struct perf_event_context *ctx; 613 struct perf_event_context *ctx;
@@ -633,7 +655,14 @@ struct perf_event {
633 655
634 struct pid_namespace *ns; 656 struct pid_namespace *ns;
635 u64 id; 657 u64 id;
658
659 perf_overflow_handler_t overflow_handler;
660
661#ifdef CONFIG_EVENT_PROFILE
662 struct event_filter *filter;
636#endif 663#endif
664
665#endif /* CONFIG_PERF_EVENTS */
637}; 666};
638 667
639/** 668/**
@@ -646,7 +675,7 @@ struct perf_event_context {
646 * Protect the states of the events in the list, 675 * Protect the states of the events in the list,
647 * nr_active, and the list: 676 * nr_active, and the list:
648 */ 677 */
649 spinlock_t lock; 678 raw_spinlock_t lock;
650 /* 679 /*
651 * Protect the list of events. Locking either mutex or lock 680 * Protect the list of events. Locking either mutex or lock
652 * is sufficient to ensure the list doesn't change; to change 681 * is sufficient to ensure the list doesn't change; to change
@@ -706,7 +735,6 @@ struct perf_output_handle {
706 int nmi; 735 int nmi;
707 int sample; 736 int sample;
708 int locked; 737 int locked;
709 unsigned long flags;
710}; 738};
711 739
712#ifdef CONFIG_PERF_EVENTS 740#ifdef CONFIG_PERF_EVENTS
@@ -738,6 +766,14 @@ extern int hw_perf_group_sched_in(struct perf_event *group_leader,
738 struct perf_cpu_context *cpuctx, 766 struct perf_cpu_context *cpuctx,
739 struct perf_event_context *ctx, int cpu); 767 struct perf_event_context *ctx, int cpu);
740extern void perf_event_update_userpage(struct perf_event *event); 768extern void perf_event_update_userpage(struct perf_event *event);
769extern int perf_event_release_kernel(struct perf_event *event);
770extern struct perf_event *
771perf_event_create_kernel_counter(struct perf_event_attr *attr,
772 int cpu,
773 pid_t pid,
774 perf_overflow_handler_t callback);
775extern u64 perf_event_read_value(struct perf_event *event,
776 u64 *enabled, u64 *running);
741 777
742struct perf_sample_data { 778struct perf_sample_data {
743 u64 type; 779 u64 type;
@@ -778,9 +814,14 @@ extern int perf_event_overflow(struct perf_event *event, int nmi,
778 */ 814 */
779static inline int is_software_event(struct perf_event *event) 815static inline int is_software_event(struct perf_event *event)
780{ 816{
781 return (event->attr.type != PERF_TYPE_RAW) && 817 switch (event->attr.type) {
782 (event->attr.type != PERF_TYPE_HARDWARE) && 818 case PERF_TYPE_SOFTWARE:
783 (event->attr.type != PERF_TYPE_HW_CACHE); 819 case PERF_TYPE_TRACEPOINT:
820 /* for now the breakpoint stuff also works as software event */
821 case PERF_TYPE_BREAKPOINT:
822 return 1;
823 }
824 return 0;
784} 825}
785 826
786extern atomic_t perf_swevent_enabled[PERF_COUNT_SW_MAX]; 827extern atomic_t perf_swevent_enabled[PERF_COUNT_SW_MAX];
@@ -814,6 +855,7 @@ extern int sysctl_perf_event_sample_rate;
814extern void perf_event_init(void); 855extern void perf_event_init(void);
815extern void perf_tp_event(int event_id, u64 addr, u64 count, 856extern void perf_tp_event(int event_id, u64 addr, u64 count,
816 void *record, int entry_size); 857 void *record, int entry_size);
858extern void perf_bp_event(struct perf_event *event, void *data);
817 859
818#ifndef perf_misc_flags 860#ifndef perf_misc_flags
819#define perf_misc_flags(regs) (user_mode(regs) ? PERF_RECORD_MISC_USER : \ 861#define perf_misc_flags(regs) (user_mode(regs) ? PERF_RECORD_MISC_USER : \
@@ -827,6 +869,10 @@ extern int perf_output_begin(struct perf_output_handle *handle,
827extern void perf_output_end(struct perf_output_handle *handle); 869extern void perf_output_end(struct perf_output_handle *handle);
828extern void perf_output_copy(struct perf_output_handle *handle, 870extern void perf_output_copy(struct perf_output_handle *handle,
829 const void *buf, unsigned int len); 871 const void *buf, unsigned int len);
872extern int perf_swevent_get_recursion_context(void);
873extern void perf_swevent_put_recursion_context(int rctx);
874extern void perf_event_enable(struct perf_event *event);
875extern void perf_event_disable(struct perf_event *event);
830#else 876#else
831static inline void 877static inline void
832perf_event_task_sched_in(struct task_struct *task, int cpu) { } 878perf_event_task_sched_in(struct task_struct *task, int cpu) { }
@@ -848,12 +894,17 @@ static inline int perf_event_task_enable(void) { return -EINVAL; }
848static inline void 894static inline void
849perf_sw_event(u32 event_id, u64 nr, int nmi, 895perf_sw_event(u32 event_id, u64 nr, int nmi,
850 struct pt_regs *regs, u64 addr) { } 896 struct pt_regs *regs, u64 addr) { }
897static inline void
898perf_bp_event(struct perf_event *event, void *data) { }
851 899
852static inline void perf_event_mmap(struct vm_area_struct *vma) { } 900static inline void perf_event_mmap(struct vm_area_struct *vma) { }
853static inline void perf_event_comm(struct task_struct *tsk) { } 901static inline void perf_event_comm(struct task_struct *tsk) { }
854static inline void perf_event_fork(struct task_struct *tsk) { } 902static inline void perf_event_fork(struct task_struct *tsk) { }
855static inline void perf_event_init(void) { } 903static inline void perf_event_init(void) { }
856 904static inline int perf_swevent_get_recursion_context(void) { return -1; }
905static inline void perf_swevent_put_recursion_context(int rctx) { }
906static inline void perf_event_enable(struct perf_event *event) { }
907static inline void perf_event_disable(struct perf_event *event) { }
857#endif 908#endif
858 909
859#define perf_output_put(handle, x) \ 910#define perf_output_put(handle, x) \