14 #ifndef _LINUX_PERF_EVENT_H
15 #define _LINUX_PERF_EVENT_H
23 #ifdef CONFIG_PERF_EVENTS
25 # include <asm/perf_event.h>
26 # include <asm/local64.h>
35 #ifdef CONFIG_HAVE_HW_BREAKPOINT
36 #include <asm/hw_breakpoint.h>
39 #include <linux/list.h>
44 #include <linux/hrtimer.h>
55 #include <asm/local.h>
121 #ifdef CONFIG_PERF_EVENTS
126 unsigned long config_base;
127 unsigned long event_base;
128 int event_base_rdpmc;
138 #ifdef CONFIG_HAVE_HW_BREAKPOINT
160 u64 freq_count_stamp;
167 #define PERF_HES_STOPPED 0x01
168 #define PERF_HES_UPTODATE 0x02
169 #define PERF_HES_ARCH 0x04
176 #define PERF_EVENT_TXN 0x1
206 #define PERF_EF_START 0x01
207 #define PERF_EF_RELOAD 0x02
208 #define PERF_EF_UPDATE 0x04
275 struct perf_sample_data;
278 struct perf_sample_data *,
285 #define SWEVENT_HLIST_BITS 8
286 #define SWEVENT_HLIST_SIZE (1 << SWEVENT_HLIST_BITS)
293 #define PERF_ATTACH_CONTEXT 0x01
294 #define PERF_ATTACH_GROUP 0x02
295 #define PERF_ATTACH_TASK 0x04
297 #ifdef CONFIG_CGROUP_PERF
302 struct perf_cgroup_info {
308 struct cgroup_subsys_state css;
309 struct perf_cgroup_info *
info;
319 #ifdef CONFIG_PERF_EVENTS
330 unsigned int attach_state;
343 u64 total_time_enabled;
344 u64 total_time_running;
389 struct mutex child_mutex;
400 struct mutex mmap_mutex;
426 void *overflow_handler_context;
428 #ifdef CONFIG_EVENT_TRACING
431 #ifdef CONFIG_FUNCTION_TRACER
432 struct ftrace_ops ftrace_ops;
436 #ifdef CONFIG_CGROUP_PERF
437 struct perf_cgroup *cgrp;
438 int cgrp_defer_enabled;
504 #define PERF_NR_CONTEXTS 4
529 #ifdef CONFIG_PERF_EVENTS
559 int src_cpu,
int dst_cpu);
564 struct perf_sample_data {
588 static inline void perf_sample_data_init(
struct perf_sample_data *
data,
594 data->br_stack =
NULL;
597 data->regs_user.regs =
NULL;
598 data->stack_user_size = 0;
603 struct perf_sample_data *
data,
606 struct perf_sample_data *
data,
611 struct perf_sample_data *
data,
616 return event->attr.sample_period != 0;
631 #ifndef perf_arch_fetch_caller_regs
632 static inline void perf_arch_fetch_caller_regs(
struct pt_regs *
regs,
unsigned long ip) { }
643 static inline void perf_fetch_caller_regs(
struct pt_regs *
regs)
645 memset(regs, 0,
sizeof(*regs));
657 perf_fetch_caller_regs(&hot_regs);
669 if (static_key_false(&perf_sched_events.key))
673 static inline void perf_event_task_sched_out(
struct task_struct *prev,
678 if (static_key_false(&perf_sched_events.key))
699 entry->
ip[entry->
nr++] =
ip;
702 extern int sysctl_perf_event_paranoid;
703 extern int sysctl_perf_event_mlock;
704 extern int sysctl_perf_event_sample_rate;
707 void __user *
buffer,
size_t *lenp,
710 static inline bool perf_paranoid_tracepoint_raw(
void)
712 return sysctl_perf_event_paranoid > -1;
715 static inline bool perf_paranoid_cpu(
void)
717 return sysctl_perf_event_paranoid > 0;
720 static inline bool perf_paranoid_kernel(
void)
722 return sysctl_perf_event_paranoid > 1;
727 int entry_size,
struct pt_regs *regs,
732 #ifndef perf_misc_flags
733 # define perf_misc_flags(regs) \
734 (user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL)
735 # define perf_instruction_pointer(regs) instruction_pointer(regs)
747 const void *
buf,
unsigned int len);
761 perf_event_task_sched_out(
struct task_struct *prev,
797 #define perf_output_put(handle, x) perf_output_copy((handle), &(x), sizeof(x))
802 #define perf_cpu_notifier(fn) \
804 static struct notifier_block fn##_nb __cpuinitdata = \
805 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
806 unsigned long cpu = smp_processor_id(); \
807 unsigned long flags; \
808 fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \
809 (void *)(unsigned long)cpu); \
810 local_irq_save(flags); \
811 fn(&fn##_nb, (unsigned long)CPU_STARTING, \
812 (void *)(unsigned long)cpu); \
813 local_irq_restore(flags); \
814 fn(&fn##_nb, (unsigned long)CPU_ONLINE, \
815 (void *)(unsigned long)cpu); \
816 register_cpu_notifier(&fn##_nb); \
820 #define PMU_FORMAT_ATTR(_name, _format) \
822 _name##_show(struct device *dev, \
823 struct device_attribute *attr, \
826 BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
827 return sprintf(page, _format "\n"); \
830 static struct device_attribute format_attr_##_name = __ATTR_RO(_name)