2 * Performance counters:
4 * Copyright(C) 2008, Thomas Gleixner <tglx@linutronix.de>
5 * Copyright(C) 2008, Red Hat, Inc., Ingo Molnar
7 * Data type definitions, declarations, prototypes.
9 * Started by: Thomas Gleixner and Ingo Molnar
11 * For licencing details see kernel-base/COPYING
13 #ifndef _LINUX_PERF_COUNTER_H
14 #define _LINUX_PERF_COUNTER_H
16 #include <asm/atomic.h>
18 #include <linux/list.h>
19 #include <linux/mutex.h>
20 #include <linux/rculist.h>
21 #include <linux/rcupdate.h>
22 #include <linux/spinlock.h>
27 * Generalized hardware event types, used by the hw_event_type parameter
28 * of the sys_perf_counter_open() syscall:
32 PERF_COUNT_INSTRUCTIONS
,
33 PERF_COUNT_CACHE_REFERENCES
,
34 PERF_COUNT_CACHE_MISSES
,
35 PERF_COUNT_BRANCH_INSTRUCTIONS
,
36 PERF_COUNT_BRANCH_MISSES
,
38 * If this bit is set in the type, then trigger NMI sampling:
40 PERF_COUNT_NMI
= (1 << 30),
41 PERF_COUNT_RAW
= (1 << 31),
45 * IRQ-notification data record type:
47 enum perf_record_type
{
53 struct perf_counter_event
{
60 * struct hw_perf_counter - performance counter hardware details
62 struct hw_perf_counter
{
64 unsigned long config_base
;
65 unsigned long counter_base
;
74 * Hardcoded buffer length limit for now, for IRQ-fed events:
76 #define PERF_DATA_BUFLEN 2048
79 * struct perf_data - performance counter IRQ data sampling ...
85 u8 data
[PERF_DATA_BUFLEN
];
89 * struct perf_counter - performance counter kernel representation:
92 struct list_head list
;
94 #if BITS_PER_LONG == 64
99 struct perf_counter_event event
;
100 struct hw_perf_counter hw
;
102 struct perf_counter_context
*ctx
;
103 struct task_struct
*task
;
106 * Protect attach/detach:
113 enum perf_record_type record_type
;
115 /* read() / irq related data */
116 wait_queue_head_t waitq
;
117 /* optional: for NMIs */
119 struct perf_data
*irqdata
;
120 struct perf_data
*usrdata
;
121 struct perf_data data
[2];
125 * struct perf_counter_context - counter context structure
127 * Used as a container for task counters and CPU counters as well:
129 struct perf_counter_context
{
130 #ifdef CONFIG_PERF_COUNTERS
132 * Protect the list of counters:
135 struct list_head counters
;
138 struct task_struct
*task
;
143 * struct perf_counter_cpu_context - per cpu counter context structure
145 struct perf_cpu_context
{
146 struct perf_counter_context ctx
;
147 struct perf_counter_context
*task_ctx
;
153 * Set by architecture code:
155 extern int perf_max_counters
;
157 #ifdef CONFIG_PERF_COUNTERS
158 extern void perf_counter_task_sched_in(struct task_struct
*task
, int cpu
);
159 extern void perf_counter_task_sched_out(struct task_struct
*task
, int cpu
);
160 extern void perf_counter_task_tick(struct task_struct
*task
, int cpu
);
161 extern void perf_counter_init_task(struct task_struct
*task
);
162 extern void perf_counter_notify(struct pt_regs
*regs
);
163 extern void perf_counter_print_debug(void);
164 extern void hw_perf_restore_ctrl(u64 ctrl
);
165 extern u64
hw_perf_disable_all(void);
168 perf_counter_task_sched_in(struct task_struct
*task
, int cpu
) { }
170 perf_counter_task_sched_out(struct task_struct
*task
, int cpu
) { }
172 perf_counter_task_tick(struct task_struct
*task
, int cpu
) { }
173 static inline void perf_counter_init_task(struct task_struct
*task
) { }
174 static inline void perf_counter_notify(struct pt_regs
*regs
) { }
175 static inline void perf_counter_print_debug(void) { }
176 static inline void hw_perf_restore_ctrl(u64 ctrl
) { }
177 static inline u64
hw_perf_disable_all(void) { return 0; }
180 #endif /* _LINUX_PERF_COUNTER_H */