aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/perf_counter.h
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-06-12 06:46:55 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-12 08:28:52 -0400
commit974802eaa1afdc87e00821df7020a2b3c6fee623 (patch)
treeb5c38bece7f4948fe9d5cf9be02a0042e0fa39f6 /include/linux/perf_counter.h
parentbbd36e5e6aa6f1757c84cdb406b6eb81686d14af (diff)
perf_counter: Add forward/backward attribute ABI compatibility
Provide for means of extending the perf_counter_attr in a 'natural' way. We allow growing the structure by appending fields at the end by specifying the full structure size inside it. When a new kernel sees a smaller (old) structure, it will 0 pad the tail. When an old kernel sees a larger (new) structure, it will verify the tail consists of 0s, otherwise fail. If we fail due to a size-mismatch, we return -E2BIG and write the kernel's native attribe size back into the provided structure. Furthermore, add some attribute verification, so that we'll fail counter creation when unknown bits are present (PERF_SAMPLE, PERF_FORMAT, or in the __reserved fields). (This ABI detail is introduced while keeping the existing syscall ABI.) Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/perf_counter.h')
-rw-r--r--include/linux/perf_counter.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index 7c4f32f6ae1a..1b3118a1023a 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -120,6 +120,8 @@ enum perf_counter_sample_format {
120 PERF_SAMPLE_ID = 1U << 6, 120 PERF_SAMPLE_ID = 1U << 6,
121 PERF_SAMPLE_CPU = 1U << 7, 121 PERF_SAMPLE_CPU = 1U << 7,
122 PERF_SAMPLE_PERIOD = 1U << 8, 122 PERF_SAMPLE_PERIOD = 1U << 8,
123
124 PERF_SAMPLE_MAX = 1U << 9, /* non-ABI */
123}; 125};
124 126
125/* 127/*
@@ -131,17 +133,26 @@ enum perf_counter_read_format {
131 PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0, 133 PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0,
132 PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1, 134 PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
133 PERF_FORMAT_ID = 1U << 2, 135 PERF_FORMAT_ID = 1U << 2,
136
137 PERF_FORMAT_MAX = 1U << 3, /* non-ABI */
134}; 138};
135 139
140#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
141
136/* 142/*
137 * Hardware event to monitor via a performance monitoring counter: 143 * Hardware event to monitor via a performance monitoring counter:
138 */ 144 */
139struct perf_counter_attr { 145struct perf_counter_attr {
146
140 /* 147 /*
141 * Major type: hardware/software/tracepoint/etc. 148 * Major type: hardware/software/tracepoint/etc.
142 */ 149 */
143 __u32 type; 150 __u32 type;
144 __u32 __reserved_1; 151
152 /*
153 * Size of the attr structure, for fwd/bwd compat.
154 */
155 __u32 size;
145 156
146 /* 157 /*
147 * Type specific configuration information. 158 * Type specific configuration information.
@@ -168,12 +179,12 @@ struct perf_counter_attr {
168 comm : 1, /* include comm data */ 179 comm : 1, /* include comm data */
169 freq : 1, /* use freq, not period */ 180 freq : 1, /* use freq, not period */
170 181
171 __reserved_2 : 53; 182 __reserved_1 : 53;
172 183
173 __u32 wakeup_events; /* wakeup every n events */ 184 __u32 wakeup_events; /* wakeup every n events */
174 __u32 __reserved_3; 185 __u32 __reserved_2;
175 186
176 __u64 __reserved_4; 187 __u64 __reserved_3;
177}; 188};
178 189
179/* 190/*