Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Performance counters: |
| 3 | * |
| 4 | * Copyright(C) 2008, Thomas Gleixner <tglx@linutronix.de> |
| 5 | * Copyright(C) 2008, Red Hat, Inc., Ingo Molnar |
| 6 | * |
| 7 | * Data type definitions, declarations, prototypes. |
| 8 | * |
| 9 | * Started by: Thomas Gleixner and Ingo Molnar |
| 10 | * |
| 11 | * For licencing details see kernel-base/COPYING |
| 12 | */ |
| 13 | #ifndef _LINUX_PERF_COUNTER_H |
| 14 | #define _LINUX_PERF_COUNTER_H |
| 15 | |
Paul Mackerras | f3dfd26 | 2009-02-26 22:43:46 +1100 | [diff] [blame] | 16 | #include <linux/types.h> |
| 17 | #include <linux/ioctl.h> |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 18 | |
| 19 | /* |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 20 | * User-space ABI bits: |
| 21 | */ |
| 22 | |
| 23 | /* |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 24 | * hw_event.type |
| 25 | */ |
| 26 | enum perf_event_types { |
| 27 | PERF_TYPE_HARDWARE = 0, |
| 28 | PERF_TYPE_SOFTWARE = 1, |
| 29 | PERF_TYPE_TRACEPOINT = 2, |
| 30 | |
| 31 | /* |
| 32 | * available TYPE space, raw is the max value. |
| 33 | */ |
| 34 | |
| 35 | PERF_TYPE_RAW = 128, |
| 36 | }; |
| 37 | |
| 38 | /* |
| 39 | * Generalized performance counter event types, used by the hw_event.event_id |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 40 | * parameter of the sys_perf_counter_open() syscall: |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 41 | */ |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 42 | enum hw_event_ids { |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 43 | /* |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 44 | * Common hardware events, generalized by the kernel: |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 45 | */ |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 46 | PERF_COUNT_CPU_CYCLES = 0, |
| 47 | PERF_COUNT_INSTRUCTIONS = 1, |
| 48 | PERF_COUNT_CACHE_REFERENCES = 2, |
| 49 | PERF_COUNT_CACHE_MISSES = 3, |
| 50 | PERF_COUNT_BRANCH_INSTRUCTIONS = 4, |
| 51 | PERF_COUNT_BRANCH_MISSES = 5, |
| 52 | PERF_COUNT_BUS_CYCLES = 6, |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 53 | |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 54 | PERF_HW_EVENTS_MAX = 7, |
| 55 | }; |
Ingo Molnar | 6c594c2 | 2008-12-14 12:34:15 +0100 | [diff] [blame] | 56 | |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 57 | /* |
| 58 | * Special "software" counters provided by the kernel, even if the hardware |
| 59 | * does not support performance counters. These counters measure various |
| 60 | * physical and sw events of the kernel (and allow the profiling of them as |
| 61 | * well): |
| 62 | */ |
| 63 | enum sw_event_ids { |
| 64 | PERF_COUNT_CPU_CLOCK = 0, |
| 65 | PERF_COUNT_TASK_CLOCK = 1, |
| 66 | PERF_COUNT_PAGE_FAULTS = 2, |
| 67 | PERF_COUNT_CONTEXT_SWITCHES = 3, |
| 68 | PERF_COUNT_CPU_MIGRATIONS = 4, |
| 69 | PERF_COUNT_PAGE_FAULTS_MIN = 5, |
| 70 | PERF_COUNT_PAGE_FAULTS_MAJ = 6, |
Ingo Molnar | 6c594c2 | 2008-12-14 12:34:15 +0100 | [diff] [blame] | 71 | |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 72 | PERF_SW_EVENTS_MAX = 7, |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | /* |
| 76 | * IRQ-notification data record type: |
| 77 | */ |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 78 | enum perf_counter_record_type { |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 79 | PERF_RECORD_SIMPLE = 0, |
| 80 | PERF_RECORD_IRQ = 1, |
| 81 | PERF_RECORD_GROUP = 2, |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 82 | }; |
| 83 | |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 84 | /* |
| 85 | * Hardware event to monitor via a performance monitoring counter: |
| 86 | */ |
| 87 | struct perf_counter_hw_event { |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 88 | union { |
| 89 | struct { |
| 90 | __u64 event_id : 56, |
| 91 | type : 8; |
| 92 | }; |
| 93 | struct { |
| 94 | __u64 raw_event_id : 63, |
| 95 | raw_type : 1; |
| 96 | }; |
| 97 | __u64 event_config; |
| 98 | }; |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 99 | |
Paul Mackerras | f3dfd26 | 2009-02-26 22:43:46 +1100 | [diff] [blame] | 100 | __u64 irq_period; |
Paul Mackerras | 2743a5b | 2009-03-04 20:36:51 +1100 | [diff] [blame] | 101 | __u64 record_type; |
| 102 | __u64 read_format; |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 103 | |
Paul Mackerras | 2743a5b | 2009-03-04 20:36:51 +1100 | [diff] [blame] | 104 | __u64 disabled : 1, /* off by default */ |
Paul Mackerras | 0475f9e | 2009-02-11 14:35:35 +1100 | [diff] [blame] | 105 | nmi : 1, /* NMI sampling */ |
Paul Mackerras | 0475f9e | 2009-02-11 14:35:35 +1100 | [diff] [blame] | 106 | inherit : 1, /* children inherit it */ |
| 107 | pinned : 1, /* must always be on PMU */ |
| 108 | exclusive : 1, /* only group on PMU */ |
| 109 | exclude_user : 1, /* don't count user */ |
| 110 | exclude_kernel : 1, /* ditto kernel */ |
| 111 | exclude_hv : 1, /* ditto hypervisor */ |
Paul Mackerras | 2743a5b | 2009-03-04 20:36:51 +1100 | [diff] [blame] | 112 | exclude_idle : 1, /* don't count when idle */ |
Paul Mackerras | 3b6f9e5 | 2009-01-14 21:00:30 +1100 | [diff] [blame] | 113 | |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 114 | __reserved_1 : 55; |
Paul Mackerras | 2743a5b | 2009-03-04 20:36:51 +1100 | [diff] [blame] | 115 | |
| 116 | __u32 extra_config_len; |
| 117 | __u32 __reserved_4; |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 118 | |
Paul Mackerras | f3dfd26 | 2009-02-26 22:43:46 +1100 | [diff] [blame] | 119 | __u64 __reserved_2; |
Paul Mackerras | 2743a5b | 2009-03-04 20:36:51 +1100 | [diff] [blame] | 120 | __u64 __reserved_3; |
Thomas Gleixner | eab656a | 2008-12-08 19:26:59 +0100 | [diff] [blame] | 121 | }; |
| 122 | |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 123 | /* |
Paul Mackerras | d859e29 | 2009-01-17 18:10:22 +1100 | [diff] [blame] | 124 | * Ioctls that can be done on a perf counter fd: |
| 125 | */ |
| 126 | #define PERF_COUNTER_IOC_ENABLE _IO('$', 0) |
| 127 | #define PERF_COUNTER_IOC_DISABLE _IO('$', 1) |
| 128 | |
Paul Mackerras | f3dfd26 | 2009-02-26 22:43:46 +1100 | [diff] [blame] | 129 | #ifdef __KERNEL__ |
Paul Mackerras | d859e29 | 2009-01-17 18:10:22 +1100 | [diff] [blame] | 130 | /* |
Paul Mackerras | f3dfd26 | 2009-02-26 22:43:46 +1100 | [diff] [blame] | 131 | * Kernel-internal data types and definitions: |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 132 | */ |
| 133 | |
Paul Mackerras | f3dfd26 | 2009-02-26 22:43:46 +1100 | [diff] [blame] | 134 | #ifdef CONFIG_PERF_COUNTERS |
| 135 | # include <asm/perf_counter.h> |
| 136 | #endif |
| 137 | |
| 138 | #include <linux/list.h> |
| 139 | #include <linux/mutex.h> |
| 140 | #include <linux/rculist.h> |
| 141 | #include <linux/rcupdate.h> |
| 142 | #include <linux/spinlock.h> |
Peter Zijlstra | d6d020e | 2009-03-13 12:21:35 +0100 | [diff] [blame] | 143 | #include <linux/hrtimer.h> |
Paul Mackerras | f3dfd26 | 2009-02-26 22:43:46 +1100 | [diff] [blame] | 144 | #include <asm/atomic.h> |
| 145 | |
| 146 | struct task_struct; |
| 147 | |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 148 | /** |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 149 | * struct hw_perf_counter - performance counter hardware details: |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 150 | */ |
| 151 | struct hw_perf_counter { |
Ingo Molnar | ee06094 | 2008-12-13 09:00:03 +0100 | [diff] [blame] | 152 | #ifdef CONFIG_PERF_COUNTERS |
Peter Zijlstra | d6d020e | 2009-03-13 12:21:35 +0100 | [diff] [blame] | 153 | union { |
| 154 | struct { /* hardware */ |
| 155 | u64 config; |
| 156 | unsigned long config_base; |
| 157 | unsigned long counter_base; |
| 158 | int nmi; |
| 159 | unsigned int idx; |
| 160 | }; |
| 161 | union { /* software */ |
| 162 | atomic64_t count; |
| 163 | struct hrtimer hrtimer; |
| 164 | }; |
| 165 | }; |
Ingo Molnar | ee06094 | 2008-12-13 09:00:03 +0100 | [diff] [blame] | 166 | atomic64_t prev_count; |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 167 | u64 irq_period; |
Ingo Molnar | ee06094 | 2008-12-13 09:00:03 +0100 | [diff] [blame] | 168 | atomic64_t period_left; |
| 169 | #endif |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | /* |
| 173 | * Hardcoded buffer length limit for now, for IRQ-fed events: |
| 174 | */ |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 175 | #define PERF_DATA_BUFLEN 2048 |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 176 | |
| 177 | /** |
| 178 | * struct perf_data - performance counter IRQ data sampling ... |
| 179 | */ |
| 180 | struct perf_data { |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 181 | int len; |
| 182 | int rd_idx; |
| 183 | int overrun; |
| 184 | u8 data[PERF_DATA_BUFLEN]; |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 185 | }; |
| 186 | |
Ingo Molnar | 621a01e | 2008-12-11 12:46:46 +0100 | [diff] [blame] | 187 | struct perf_counter; |
| 188 | |
| 189 | /** |
| 190 | * struct hw_perf_counter_ops - performance counter hw ops |
| 191 | */ |
| 192 | struct hw_perf_counter_ops { |
Ingo Molnar | 95cdd2e | 2008-12-21 13:50:42 +0100 | [diff] [blame] | 193 | int (*enable) (struct perf_counter *counter); |
Ingo Molnar | 7671581 | 2008-12-17 14:20:28 +0100 | [diff] [blame] | 194 | void (*disable) (struct perf_counter *counter); |
| 195 | void (*read) (struct perf_counter *counter); |
Ingo Molnar | 621a01e | 2008-12-11 12:46:46 +0100 | [diff] [blame] | 196 | }; |
| 197 | |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 198 | /** |
Ingo Molnar | 6a93070 | 2008-12-11 15:17:03 +0100 | [diff] [blame] | 199 | * enum perf_counter_active_state - the states of a counter |
| 200 | */ |
| 201 | enum perf_counter_active_state { |
Paul Mackerras | 3b6f9e5 | 2009-01-14 21:00:30 +1100 | [diff] [blame] | 202 | PERF_COUNTER_STATE_ERROR = -2, |
Ingo Molnar | 6a93070 | 2008-12-11 15:17:03 +0100 | [diff] [blame] | 203 | PERF_COUNTER_STATE_OFF = -1, |
| 204 | PERF_COUNTER_STATE_INACTIVE = 0, |
| 205 | PERF_COUNTER_STATE_ACTIVE = 1, |
| 206 | }; |
| 207 | |
Ingo Molnar | 9b51f66 | 2008-12-12 13:49:45 +0100 | [diff] [blame] | 208 | struct file; |
| 209 | |
Ingo Molnar | 6a93070 | 2008-12-11 15:17:03 +0100 | [diff] [blame] | 210 | /** |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 211 | * struct perf_counter - performance counter kernel representation: |
| 212 | */ |
| 213 | struct perf_counter { |
Ingo Molnar | ee06094 | 2008-12-13 09:00:03 +0100 | [diff] [blame] | 214 | #ifdef CONFIG_PERF_COUNTERS |
Ingo Molnar | 04289bb | 2008-12-11 08:38:42 +0100 | [diff] [blame] | 215 | struct list_head list_entry; |
Peter Zijlstra | 592903c | 2009-03-13 12:21:36 +0100 | [diff] [blame] | 216 | struct list_head event_entry; |
Ingo Molnar | 04289bb | 2008-12-11 08:38:42 +0100 | [diff] [blame] | 217 | struct list_head sibling_list; |
| 218 | struct perf_counter *group_leader; |
Ingo Molnar | 5c92d12 | 2008-12-11 13:21:10 +0100 | [diff] [blame] | 219 | const struct hw_perf_counter_ops *hw_ops; |
Ingo Molnar | 04289bb | 2008-12-11 08:38:42 +0100 | [diff] [blame] | 220 | |
Ingo Molnar | 6a93070 | 2008-12-11 15:17:03 +0100 | [diff] [blame] | 221 | enum perf_counter_active_state state; |
Paul Mackerras | c07c99b | 2009-02-13 22:10:34 +1100 | [diff] [blame] | 222 | enum perf_counter_active_state prev_state; |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 223 | atomic64_t count; |
Ingo Molnar | ee06094 | 2008-12-13 09:00:03 +0100 | [diff] [blame] | 224 | |
Ingo Molnar | 9f66a38 | 2008-12-10 12:33:23 +0100 | [diff] [blame] | 225 | struct perf_counter_hw_event hw_event; |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 226 | struct hw_perf_counter hw; |
| 227 | |
| 228 | struct perf_counter_context *ctx; |
| 229 | struct task_struct *task; |
Ingo Molnar | 9b51f66 | 2008-12-12 13:49:45 +0100 | [diff] [blame] | 230 | struct file *filp; |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 231 | |
Ingo Molnar | 9b51f66 | 2008-12-12 13:49:45 +0100 | [diff] [blame] | 232 | struct perf_counter *parent; |
Paul Mackerras | d859e29 | 2009-01-17 18:10:22 +1100 | [diff] [blame] | 233 | struct list_head child_list; |
| 234 | |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 235 | /* |
Paul Mackerras | d859e29 | 2009-01-17 18:10:22 +1100 | [diff] [blame] | 236 | * Protect attach/detach and child_list: |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 237 | */ |
| 238 | struct mutex mutex; |
| 239 | |
| 240 | int oncpu; |
| 241 | int cpu; |
| 242 | |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 243 | /* read() / irq related data */ |
| 244 | wait_queue_head_t waitq; |
| 245 | /* optional: for NMIs */ |
| 246 | int wakeup_pending; |
| 247 | struct perf_data *irqdata; |
| 248 | struct perf_data *usrdata; |
| 249 | struct perf_data data[2]; |
Peter Zijlstra | 592903c | 2009-03-13 12:21:36 +0100 | [diff] [blame] | 250 | |
Peter Zijlstra | e077df4 | 2009-03-19 20:26:17 +0100 | [diff] [blame] | 251 | void (*destroy)(struct perf_counter *); |
Peter Zijlstra | 592903c | 2009-03-13 12:21:36 +0100 | [diff] [blame] | 252 | struct rcu_head rcu_head; |
Ingo Molnar | ee06094 | 2008-12-13 09:00:03 +0100 | [diff] [blame] | 253 | #endif |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 254 | }; |
| 255 | |
| 256 | /** |
| 257 | * struct perf_counter_context - counter context structure |
| 258 | * |
| 259 | * Used as a container for task counters and CPU counters as well: |
| 260 | */ |
| 261 | struct perf_counter_context { |
| 262 | #ifdef CONFIG_PERF_COUNTERS |
| 263 | /* |
Paul Mackerras | d859e29 | 2009-01-17 18:10:22 +1100 | [diff] [blame] | 264 | * Protect the states of the counters in the list, |
| 265 | * nr_active, and the list: |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 266 | */ |
| 267 | spinlock_t lock; |
Paul Mackerras | d859e29 | 2009-01-17 18:10:22 +1100 | [diff] [blame] | 268 | /* |
| 269 | * Protect the list of counters. Locking either mutex or lock |
| 270 | * is sufficient to ensure the list doesn't change; to change |
| 271 | * the list you need to lock both the mutex and the spinlock. |
| 272 | */ |
| 273 | struct mutex mutex; |
Ingo Molnar | 04289bb | 2008-12-11 08:38:42 +0100 | [diff] [blame] | 274 | |
| 275 | struct list_head counter_list; |
Peter Zijlstra | 592903c | 2009-03-13 12:21:36 +0100 | [diff] [blame] | 276 | struct list_head event_list; |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 277 | int nr_counters; |
| 278 | int nr_active; |
Paul Mackerras | d859e29 | 2009-01-17 18:10:22 +1100 | [diff] [blame] | 279 | int is_active; |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 280 | struct task_struct *task; |
| 281 | #endif |
| 282 | }; |
| 283 | |
| 284 | /** |
| 285 | * struct perf_counter_cpu_context - per cpu counter context structure |
| 286 | */ |
| 287 | struct perf_cpu_context { |
| 288 | struct perf_counter_context ctx; |
| 289 | struct perf_counter_context *task_ctx; |
| 290 | int active_oncpu; |
| 291 | int max_pertask; |
Paul Mackerras | 3b6f9e5 | 2009-01-14 21:00:30 +1100 | [diff] [blame] | 292 | int exclusive; |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 293 | }; |
| 294 | |
| 295 | /* |
| 296 | * Set by architecture code: |
| 297 | */ |
| 298 | extern int perf_max_counters; |
| 299 | |
| 300 | #ifdef CONFIG_PERF_COUNTERS |
Ingo Molnar | 5c92d12 | 2008-12-11 13:21:10 +0100 | [diff] [blame] | 301 | extern const struct hw_perf_counter_ops * |
Ingo Molnar | 621a01e | 2008-12-11 12:46:46 +0100 | [diff] [blame] | 302 | hw_perf_counter_init(struct perf_counter *counter); |
| 303 | |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 304 | extern void perf_counter_task_sched_in(struct task_struct *task, int cpu); |
| 305 | extern void perf_counter_task_sched_out(struct task_struct *task, int cpu); |
| 306 | extern void perf_counter_task_tick(struct task_struct *task, int cpu); |
Ingo Molnar | 9b51f66 | 2008-12-12 13:49:45 +0100 | [diff] [blame] | 307 | extern void perf_counter_init_task(struct task_struct *child); |
| 308 | extern void perf_counter_exit_task(struct task_struct *child); |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 309 | extern void perf_counter_notify(struct pt_regs *regs); |
| 310 | extern void perf_counter_print_debug(void); |
Mike Galbraith | 1b023a9 | 2009-01-23 10:13:01 +0100 | [diff] [blame] | 311 | extern void perf_counter_unthrottle(void); |
Ingo Molnar | 01b2838 | 2008-12-11 13:45:51 +0100 | [diff] [blame] | 312 | extern u64 hw_perf_save_disable(void); |
| 313 | extern void hw_perf_restore(u64 ctrl); |
Ingo Molnar | 1d1c7dd | 2008-12-11 14:59:31 +0100 | [diff] [blame] | 314 | extern int perf_counter_task_disable(void); |
| 315 | extern int perf_counter_task_enable(void); |
Paul Mackerras | 3cbed42 | 2009-01-09 16:43:42 +1100 | [diff] [blame] | 316 | extern int hw_perf_group_sched_in(struct perf_counter *group_leader, |
| 317 | struct perf_cpu_context *cpuctx, |
| 318 | struct perf_counter_context *ctx, int cpu); |
Ingo Molnar | 5c92d12 | 2008-12-11 13:21:10 +0100 | [diff] [blame] | 319 | |
Peter Zijlstra | 0322cd6 | 2009-03-19 20:26:19 +0100 | [diff] [blame^] | 320 | extern void perf_counter_output(struct perf_counter *counter, |
| 321 | int nmi, struct pt_regs *regs); |
Paul Mackerras | 3b6f9e5 | 2009-01-14 21:00:30 +1100 | [diff] [blame] | 322 | /* |
| 323 | * Return 1 for a software counter, 0 for a hardware counter |
| 324 | */ |
| 325 | static inline int is_software_counter(struct perf_counter *counter) |
| 326 | { |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 327 | return !counter->hw_event.raw_type && |
| 328 | counter->hw_event.type != PERF_TYPE_HARDWARE; |
Paul Mackerras | 3b6f9e5 | 2009-01-14 21:00:30 +1100 | [diff] [blame] | 329 | } |
| 330 | |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 331 | extern void perf_swcounter_event(u32, u64, int, struct pt_regs *); |
Peter Zijlstra | 15dbf27 | 2009-03-13 12:21:32 +0100 | [diff] [blame] | 332 | |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 333 | #else |
| 334 | static inline void |
| 335 | perf_counter_task_sched_in(struct task_struct *task, int cpu) { } |
| 336 | static inline void |
| 337 | perf_counter_task_sched_out(struct task_struct *task, int cpu) { } |
| 338 | static inline void |
| 339 | perf_counter_task_tick(struct task_struct *task, int cpu) { } |
Ingo Molnar | 9b51f66 | 2008-12-12 13:49:45 +0100 | [diff] [blame] | 340 | static inline void perf_counter_init_task(struct task_struct *child) { } |
| 341 | static inline void perf_counter_exit_task(struct task_struct *child) { } |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 342 | static inline void perf_counter_notify(struct pt_regs *regs) { } |
| 343 | static inline void perf_counter_print_debug(void) { } |
Mike Galbraith | 1b023a9 | 2009-01-23 10:13:01 +0100 | [diff] [blame] | 344 | static inline void perf_counter_unthrottle(void) { } |
Peter Zijlstra | 15dbf27 | 2009-03-13 12:21:32 +0100 | [diff] [blame] | 345 | static inline void hw_perf_restore(u64 ctrl) { } |
Ingo Molnar | 01b2838 | 2008-12-11 13:45:51 +0100 | [diff] [blame] | 346 | static inline u64 hw_perf_save_disable(void) { return 0; } |
Ingo Molnar | 1d1c7dd | 2008-12-11 14:59:31 +0100 | [diff] [blame] | 347 | static inline int perf_counter_task_disable(void) { return -EINVAL; } |
| 348 | static inline int perf_counter_task_enable(void) { return -EINVAL; } |
Peter Zijlstra | 15dbf27 | 2009-03-13 12:21:32 +0100 | [diff] [blame] | 349 | |
Peter Zijlstra | b8e8351 | 2009-03-19 20:26:18 +0100 | [diff] [blame] | 350 | static inline void perf_swcounter_event(u32 event, u64 nr, |
Peter Zijlstra | 15dbf27 | 2009-03-13 12:21:32 +0100 | [diff] [blame] | 351 | int nmi, struct pt_regs *regs) { } |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 352 | #endif |
| 353 | |
Paul Mackerras | f3dfd26 | 2009-02-26 22:43:46 +1100 | [diff] [blame] | 354 | #endif /* __KERNEL__ */ |
Thomas Gleixner | 0793a61 | 2008-12-04 20:12:29 +0100 | [diff] [blame] | 355 | #endif /* _LINUX_PERF_COUNTER_H */ |