diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-12-10 06:33:23 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-11 09:45:48 -0500 |
commit | 9f66a3810fe0d4100972db84290f3ae4a4d77025 (patch) | |
tree | 2101d0d14aecf9d3e406544711e7336e3ea6b3af /include/linux/perf_counter.h | |
parent | dfa7c899b401d7dc5d85aca416aee64ac82812f2 (diff) |
perf counters: restructure the API
Impact: clean up new API
Thorough cleanup of the new perf counters API, we now get clean separation
of the various concepts:
- introduce perf_counter_hw_event to separate out the event source details
- move special type flags into separate attributes: PERF_COUNT_NMI,
PERF_COUNT_RAW
- extend the type to u64 and reserve it fully to the architecture in the
raw type case.
And make use of all these changes in the core and x86 perfcounters code.
Also change the syscall signature to:
asmlinkage int sys_perf_counter_open(
struct perf_counter_hw_event *hw_event_uptr __user,
pid_t pid,
int cpu,
int group_fd);
( Note that group_fd is unused for now - it's reserved for the counter
groups abstraction. )
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/perf_counter.h')
-rw-r--r-- | include/linux/perf_counter.h | 98 |
1 files changed, 62 insertions, 36 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h index 1f0017673e77..a2b4852e2d70 100644 --- a/include/linux/perf_counter.h +++ b/include/linux/perf_counter.h | |||
@@ -24,65 +24,93 @@ | |||
24 | struct task_struct; | 24 | struct task_struct; |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * Generalized hardware event types, used by the hw_event_type parameter | 27 | * User-space ABI bits: |
28 | * of the sys_perf_counter_open() syscall: | 28 | */ |
29 | |||
30 | /* | ||
31 | * Generalized performance counter event types, used by the hw_event.type | ||
32 | * parameter of the sys_perf_counter_open() syscall: | ||
29 | */ | 33 | */ |
30 | enum hw_event_types { | 34 | enum hw_event_types { |
31 | PERF_COUNT_CYCLES, | ||
32 | PERF_COUNT_INSTRUCTIONS, | ||
33 | PERF_COUNT_CACHE_REFERENCES, | ||
34 | PERF_COUNT_CACHE_MISSES, | ||
35 | PERF_COUNT_BRANCH_INSTRUCTIONS, | ||
36 | PERF_COUNT_BRANCH_MISSES, | ||
37 | /* | 35 | /* |
38 | * If this bit is set in the type, then trigger NMI sampling: | 36 | * Common hardware events, generalized by the kernel: |
39 | */ | 37 | */ |
40 | PERF_COUNT_NMI = (1 << 30), | 38 | PERF_COUNT_CYCLES = 0, |
41 | PERF_COUNT_RAW = (1 << 31), | 39 | PERF_COUNT_INSTRUCTIONS = 1, |
40 | PERF_COUNT_CACHE_REFERENCES = 2, | ||
41 | PERF_COUNT_CACHE_MISSES = 3, | ||
42 | PERF_COUNT_BRANCH_INSTRUCTIONS = 4, | ||
43 | PERF_COUNT_BRANCH_MISSES = 5, | ||
44 | |||
45 | /* | ||
46 | * Special "software" counters provided by the kernel, even if | ||
47 | * the hardware does not support performance counters. These | ||
48 | * counters measure various physical and sw events of the | ||
49 | * kernel (and allow the profiling of them as well): | ||
50 | */ | ||
51 | PERF_COUNT_CPU_CLOCK = -1, | ||
52 | PERF_COUNT_TASK_CLOCK = -2, | ||
53 | PERF_COUNT_PAGE_FAULTS = -3, | ||
54 | PERF_COUNT_CONTEXT_SWITCHES = -4, | ||
42 | }; | 55 | }; |
43 | 56 | ||
44 | /* | 57 | /* |
45 | * IRQ-notification data record type: | 58 | * IRQ-notification data record type: |
46 | */ | 59 | */ |
47 | enum perf_record_type { | 60 | enum perf_counter_record_type { |
48 | PERF_RECORD_SIMPLE, | 61 | PERF_RECORD_SIMPLE = 0, |
49 | PERF_RECORD_IRQ, | 62 | PERF_RECORD_IRQ = 1, |
50 | PERF_RECORD_GROUP, | 63 | PERF_RECORD_GROUP = 2, |
51 | }; | 64 | }; |
52 | 65 | ||
53 | struct perf_counter_event { | 66 | /* |
54 | u32 hw_event_type; | 67 | * Hardware event to monitor via a performance monitoring counter: |
55 | u32 hw_event_period; | 68 | */ |
56 | u64 hw_raw_ctrl; | 69 | struct perf_counter_hw_event { |
70 | u64 type; | ||
71 | |||
72 | u64 irq_period; | ||
73 | u32 record_type; | ||
74 | |||
75 | u32 disabled : 1, /* off by default */ | ||
76 | nmi : 1, /* NMI sampling */ | ||
77 | raw : 1, /* raw event type */ | ||
78 | __reserved_1 : 29; | ||
79 | |||
80 | u64 __reserved_2; | ||
57 | }; | 81 | }; |
58 | 82 | ||
83 | /* | ||
84 | * Kernel-internal data types: | ||
85 | */ | ||
86 | |||
59 | /** | 87 | /** |
60 | * struct hw_perf_counter - performance counter hardware details | 88 | * struct hw_perf_counter - performance counter hardware details: |
61 | */ | 89 | */ |
62 | struct hw_perf_counter { | 90 | struct hw_perf_counter { |
63 | u64 config; | 91 | u64 config; |
64 | unsigned long config_base; | 92 | unsigned long config_base; |
65 | unsigned long counter_base; | 93 | unsigned long counter_base; |
66 | int nmi; | 94 | int nmi; |
67 | unsigned int idx; | 95 | unsigned int idx; |
68 | u64 prev_count; | 96 | u64 prev_count; |
69 | s32 next_count; | 97 | u64 irq_period; |
70 | u64 irq_period; | 98 | s32 next_count; |
71 | }; | 99 | }; |
72 | 100 | ||
73 | /* | 101 | /* |
74 | * Hardcoded buffer length limit for now, for IRQ-fed events: | 102 | * Hardcoded buffer length limit for now, for IRQ-fed events: |
75 | */ | 103 | */ |
76 | #define PERF_DATA_BUFLEN 2048 | 104 | #define PERF_DATA_BUFLEN 2048 |
77 | 105 | ||
78 | /** | 106 | /** |
79 | * struct perf_data - performance counter IRQ data sampling ... | 107 | * struct perf_data - performance counter IRQ data sampling ... |
80 | */ | 108 | */ |
81 | struct perf_data { | 109 | struct perf_data { |
82 | int len; | 110 | int len; |
83 | int rd_idx; | 111 | int rd_idx; |
84 | int overrun; | 112 | int overrun; |
85 | u8 data[PERF_DATA_BUFLEN]; | 113 | u8 data[PERF_DATA_BUFLEN]; |
86 | }; | 114 | }; |
87 | 115 | ||
88 | /** | 116 | /** |
@@ -96,7 +124,7 @@ struct perf_counter { | |||
96 | #else | 124 | #else |
97 | atomic_t count32[2]; | 125 | atomic_t count32[2]; |
98 | #endif | 126 | #endif |
99 | struct perf_counter_event event; | 127 | struct perf_counter_hw_event hw_event; |
100 | struct hw_perf_counter hw; | 128 | struct hw_perf_counter hw; |
101 | 129 | ||
102 | struct perf_counter_context *ctx; | 130 | struct perf_counter_context *ctx; |
@@ -110,8 +138,6 @@ struct perf_counter { | |||
110 | int oncpu; | 138 | int oncpu; |
111 | int cpu; | 139 | int cpu; |
112 | 140 | ||
113 | enum perf_record_type record_type; | ||
114 | |||
115 | /* read() / irq related data */ | 141 | /* read() / irq related data */ |
116 | wait_queue_head_t waitq; | 142 | wait_queue_head_t waitq; |
117 | /* optional: for NMIs */ | 143 | /* optional: for NMIs */ |