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.h107
1 files changed, 50 insertions, 57 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index e0786e35f24..c816075c01c 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -61,7 +61,7 @@ enum perf_hw_id {
61/* 61/*
62 * Generalized hardware cache events: 62 * Generalized hardware cache events:
63 * 63 *
64 * { L1-D, L1-I, LLC, ITLB, DTLB, BPU } x 64 * { L1-D, L1-I, LLC, ITLB, DTLB, BPU, NODE } x
65 * { read, write, prefetch } x 65 * { read, write, prefetch } x
66 * { accesses, misses } 66 * { accesses, misses }
67 */ 67 */
@@ -72,6 +72,7 @@ enum perf_hw_cache_id {
72 PERF_COUNT_HW_CACHE_DTLB = 3, 72 PERF_COUNT_HW_CACHE_DTLB = 3,
73 PERF_COUNT_HW_CACHE_ITLB = 4, 73 PERF_COUNT_HW_CACHE_ITLB = 4,
74 PERF_COUNT_HW_CACHE_BPU = 5, 74 PERF_COUNT_HW_CACHE_BPU = 5,
75 PERF_COUNT_HW_CACHE_NODE = 6,
75 76
76 PERF_COUNT_HW_CACHE_MAX, /* non-ABI */ 77 PERF_COUNT_HW_CACHE_MAX, /* non-ABI */
77}; 78};
@@ -508,7 +509,7 @@ struct perf_guest_info_callbacks {
508#include <linux/cpu.h> 509#include <linux/cpu.h>
509#include <linux/irq_work.h> 510#include <linux/irq_work.h>
510#include <linux/jump_label.h> 511#include <linux/jump_label.h>
511#include <asm/atomic.h> 512#include <linux/atomic.h>
512#include <asm/local.h> 513#include <asm/local.h>
513 514
514#define PERF_MAX_STACK_DEPTH 255 515#define PERF_MAX_STACK_DEPTH 255
@@ -536,6 +537,16 @@ struct perf_branch_stack {
536 537
537struct task_struct; 538struct task_struct;
538 539
540/*
541 * extra PMU register associated with an event
542 */
543struct hw_perf_event_extra {
544 u64 config; /* register value */
545 unsigned int reg; /* register address or index */
546 int alloc; /* extra register already allocated */
547 int idx; /* index in shared_regs->regs[] */
548};
549
539/** 550/**
540 * struct hw_perf_event - performance event hardware details: 551 * struct hw_perf_event - performance event hardware details:
541 */ 552 */
@@ -549,9 +560,7 @@ struct hw_perf_event {
549 unsigned long event_base; 560 unsigned long event_base;
550 int idx; 561 int idx;
551 int last_cpu; 562 int last_cpu;
552 unsigned int extra_reg; 563 struct hw_perf_event_extra extra_reg;
553 u64 extra_config;
554 int extra_alloc;
555 }; 564 };
556 struct { /* software */ 565 struct { /* software */
557 struct hrtimer hrtimer; 566 struct hrtimer hrtimer;
@@ -680,36 +689,9 @@ enum perf_event_active_state {
680}; 689};
681 690
682struct file; 691struct file;
683
684#define PERF_BUFFER_WRITABLE 0x01
685
686struct perf_buffer {
687 atomic_t refcount;
688 struct rcu_head rcu_head;
689#ifdef CONFIG_PERF_USE_VMALLOC
690 struct work_struct work;
691 int page_order; /* allocation order */
692#endif
693 int nr_pages; /* nr of data pages */
694 int writable; /* are we writable */
695
696 atomic_t poll; /* POLL_ for wakeups */
697
698 local_t head; /* write position */
699 local_t nest; /* nested writers */
700 local_t events; /* event limit */
701 local_t wakeup; /* wakeup stamp */
702 local_t lost; /* nr records lost */
703
704 long watermark; /* wakeup watermark */
705
706 struct perf_event_mmap_page *user_page;
707 void *data_pages[0];
708};
709
710struct perf_sample_data; 692struct perf_sample_data;
711 693
712typedef void (*perf_overflow_handler_t)(struct perf_event *, int, 694typedef void (*perf_overflow_handler_t)(struct perf_event *,
713 struct perf_sample_data *, 695 struct perf_sample_data *,
714 struct pt_regs *regs); 696 struct pt_regs *regs);
715 697
@@ -745,6 +727,8 @@ struct perf_cgroup {
745}; 727};
746#endif 728#endif
747 729
730struct ring_buffer;
731
748/** 732/**
749 * struct perf_event - performance event kernel representation: 733 * struct perf_event - performance event kernel representation:
750 */ 734 */
@@ -834,7 +818,7 @@ struct perf_event {
834 atomic_t mmap_count; 818 atomic_t mmap_count;
835 int mmap_locked; 819 int mmap_locked;
836 struct user_struct *mmap_user; 820 struct user_struct *mmap_user;
837 struct perf_buffer *buffer; 821 struct ring_buffer *rb;
838 822
839 /* poll related */ 823 /* poll related */
840 wait_queue_head_t waitq; 824 wait_queue_head_t waitq;
@@ -855,6 +839,7 @@ struct perf_event {
855 u64 id; 839 u64 id;
856 840
857 perf_overflow_handler_t overflow_handler; 841 perf_overflow_handler_t overflow_handler;
842 void *overflow_handler_context;
858 843
859#ifdef CONFIG_EVENT_TRACING 844#ifdef CONFIG_EVENT_TRACING
860 struct ftrace_event_call *tp_event; 845 struct ftrace_event_call *tp_event;
@@ -919,8 +904,8 @@ struct perf_event_context {
919 u64 parent_gen; 904 u64 parent_gen;
920 u64 generation; 905 u64 generation;
921 int pin_count; 906 int pin_count;
922 struct rcu_head rcu_head;
923 int nr_cgroups; /* cgroup events present */ 907 int nr_cgroups; /* cgroup events present */
908 struct rcu_head rcu_head;
924}; 909};
925 910
926/* 911/*
@@ -945,13 +930,11 @@ struct perf_cpu_context {
945 930
946struct perf_output_handle { 931struct perf_output_handle {
947 struct perf_event *event; 932 struct perf_event *event;
948 struct perf_buffer *buffer; 933 struct ring_buffer *rb;
949 unsigned long wakeup; 934 unsigned long wakeup;
950 unsigned long size; 935 unsigned long size;
951 void *addr; 936 void *addr;
952 int page; 937 int page;
953 int nmi;
954 int sample;
955}; 938};
956 939
957#ifdef CONFIG_PERF_EVENTS 940#ifdef CONFIG_PERF_EVENTS
@@ -961,8 +944,10 @@ extern void perf_pmu_unregister(struct pmu *pmu);
961 944
962extern int perf_num_counters(void); 945extern int perf_num_counters(void);
963extern const char *perf_pmu_name(void); 946extern const char *perf_pmu_name(void);
964extern void __perf_event_task_sched_in(struct task_struct *task); 947extern void __perf_event_task_sched_in(struct task_struct *prev,
965extern void __perf_event_task_sched_out(struct task_struct *task, struct task_struct *next); 948 struct task_struct *task);
949extern void __perf_event_task_sched_out(struct task_struct *prev,
950 struct task_struct *next);
966extern int perf_event_init_task(struct task_struct *child); 951extern int perf_event_init_task(struct task_struct *child);
967extern void perf_event_exit_task(struct task_struct *child); 952extern void perf_event_exit_task(struct task_struct *child);
968extern void perf_event_free_task(struct task_struct *task); 953extern void perf_event_free_task(struct task_struct *task);
@@ -972,13 +957,15 @@ extern void perf_pmu_disable(struct pmu *pmu);
972extern void perf_pmu_enable(struct pmu *pmu); 957extern void perf_pmu_enable(struct pmu *pmu);
973extern int perf_event_task_disable(void); 958extern int perf_event_task_disable(void);
974extern int perf_event_task_enable(void); 959extern int perf_event_task_enable(void);
960extern int perf_event_refresh(struct perf_event *event, int refresh);
975extern void perf_event_update_userpage(struct perf_event *event); 961extern void perf_event_update_userpage(struct perf_event *event);
976extern int perf_event_release_kernel(struct perf_event *event); 962extern int perf_event_release_kernel(struct perf_event *event);
977extern struct perf_event * 963extern struct perf_event *
978perf_event_create_kernel_counter(struct perf_event_attr *attr, 964perf_event_create_kernel_counter(struct perf_event_attr *attr,
979 int cpu, 965 int cpu,
980 struct task_struct *task, 966 struct task_struct *task,
981 perf_overflow_handler_t callback); 967 perf_overflow_handler_t callback,
968 void *context);
982extern u64 perf_event_read_value(struct perf_event *event, 969extern u64 perf_event_read_value(struct perf_event *event,
983 u64 *enabled, u64 *running); 970 u64 *enabled, u64 *running);
984 971
@@ -1018,7 +1005,7 @@ extern void perf_prepare_sample(struct perf_event_header *header,
1018 struct perf_event *event, 1005 struct perf_event *event,
1019 struct pt_regs *regs); 1006 struct pt_regs *regs);
1020 1007
1021extern int perf_event_overflow(struct perf_event *event, int nmi, 1008extern int perf_event_overflow(struct perf_event *event,
1022 struct perf_sample_data *data, 1009 struct perf_sample_data *data,
1023 struct pt_regs *regs); 1010 struct pt_regs *regs);
1024 1011
@@ -1037,7 +1024,7 @@ static inline int is_software_event(struct perf_event *event)
1037 1024
1038extern struct jump_label_key perf_swevent_enabled[PERF_COUNT_SW_MAX]; 1025extern struct jump_label_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
1039 1026
1040extern void __perf_sw_event(u32, u64, int, struct pt_regs *, u64); 1027extern void __perf_sw_event(u32, u64, struct pt_regs *, u64);
1041 1028
1042#ifndef perf_arch_fetch_caller_regs 1029#ifndef perf_arch_fetch_caller_regs
1043static inline void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip) { } 1030static inline void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip) { }
@@ -1059,7 +1046,7 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs)
1059} 1046}
1060 1047
1061static __always_inline void 1048static __always_inline void
1062perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr) 1049perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
1063{ 1050{
1064 struct pt_regs hot_regs; 1051 struct pt_regs hot_regs;
1065 1052
@@ -1068,23 +1055,26 @@ perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
1068 perf_fetch_caller_regs(&hot_regs); 1055 perf_fetch_caller_regs(&hot_regs);
1069 regs = &hot_regs; 1056 regs = &hot_regs;
1070 } 1057 }
1071 __perf_sw_event(event_id, nr, nmi, regs, addr); 1058 __perf_sw_event(event_id, nr, regs, addr);
1072 } 1059 }
1073} 1060}
1074 1061
1075extern struct jump_label_key perf_sched_events; 1062extern struct jump_label_key perf_sched_events;
1076 1063
1077static inline void perf_event_task_sched_in(struct task_struct *task) 1064static inline void perf_event_task_sched_in(struct task_struct *prev,
1065 struct task_struct *task)
1078{ 1066{
1079 if (static_branch(&perf_sched_events)) 1067 if (static_branch(&perf_sched_events))
1080 __perf_event_task_sched_in(task); 1068 __perf_event_task_sched_in(prev, task);
1081} 1069}
1082 1070
1083static inline void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next) 1071static inline void perf_event_task_sched_out(struct task_struct *prev,
1072 struct task_struct *next)
1084{ 1073{
1085 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 1, NULL, 0); 1074 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0);
1086 1075
1087 __perf_event_task_sched_out(task, next); 1076 if (static_branch(&perf_sched_events))
1077 __perf_event_task_sched_out(prev, next);
1088} 1078}
1089 1079
1090extern void perf_event_mmap(struct vm_area_struct *vma); 1080extern void perf_event_mmap(struct vm_area_struct *vma);
@@ -1143,8 +1133,7 @@ extern void perf_bp_event(struct perf_event *event, void *data);
1143#endif 1133#endif
1144 1134
1145extern int perf_output_begin(struct perf_output_handle *handle, 1135extern int perf_output_begin(struct perf_output_handle *handle,
1146 struct perf_event *event, unsigned int size, 1136 struct perf_event *event, unsigned int size);
1147 int nmi, int sample);
1148extern void perf_output_end(struct perf_output_handle *handle); 1137extern void perf_output_end(struct perf_output_handle *handle);
1149extern void perf_output_copy(struct perf_output_handle *handle, 1138extern void perf_output_copy(struct perf_output_handle *handle,
1150 const void *buf, unsigned int len); 1139 const void *buf, unsigned int len);
@@ -1155,10 +1144,11 @@ extern void perf_event_disable(struct perf_event *event);
1155extern void perf_event_task_tick(void); 1144extern void perf_event_task_tick(void);
1156#else 1145#else
1157static inline void 1146static inline void
1158perf_event_task_sched_in(struct task_struct *task) { } 1147perf_event_task_sched_in(struct task_struct *prev,
1148 struct task_struct *task) { }
1159static inline void 1149static inline void
1160perf_event_task_sched_out(struct task_struct *task, 1150perf_event_task_sched_out(struct task_struct *prev,
1161 struct task_struct *next) { } 1151 struct task_struct *next) { }
1162static inline int perf_event_init_task(struct task_struct *child) { return 0; } 1152static inline int perf_event_init_task(struct task_struct *child) { return 0; }
1163static inline void perf_event_exit_task(struct task_struct *child) { } 1153static inline void perf_event_exit_task(struct task_struct *child) { }
1164static inline void perf_event_free_task(struct task_struct *task) { } 1154static inline void perf_event_free_task(struct task_struct *task) { }
@@ -1166,10 +1156,13 @@ static inline void perf_event_delayed_put(struct task_struct *task) { }
1166static inline void perf_event_print_debug(void) { } 1156static inline void perf_event_print_debug(void) { }
1167static inline int perf_event_task_disable(void) { return -EINVAL; } 1157static inline int perf_event_task_disable(void) { return -EINVAL; }
1168static inline int perf_event_task_enable(void) { return -EINVAL; } 1158static inline int perf_event_task_enable(void) { return -EINVAL; }
1159static inline int perf_event_refresh(struct perf_event *event, int refresh)
1160{
1161 return -EINVAL;
1162}
1169 1163
1170static inline void 1164static inline void
1171perf_sw_event(u32 event_id, u64 nr, int nmi, 1165perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) { }
1172 struct pt_regs *regs, u64 addr) { }
1173static inline void 1166static inline void
1174perf_bp_event(struct perf_event *event, void *data) { } 1167perf_bp_event(struct perf_event *event, void *data) { }
1175 1168