aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/perf_event.h
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-08-07 09:20:37 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-10 10:31:26 -0400
commit4018994f3d8785275ef0e7391b75c3462c029e56 (patch)
tree661b5c488977c5150eb9d1ac4cec944309c83a16 /include/linux/perf_event.h
parentc5e63197db519bae1c33e41ea0342a50f39e7a93 (diff)
perf: Add ability to attach user level registers dump to sample
Introducing PERF_SAMPLE_REGS_USER sample type bit to trigger the dump of user level registers on sample. Registers we want to dump are specified by sample_regs_user bitmask. Only user level registers are dumped at the moment. Meaning the register values of the user space context as it was before the user entered the kernel for whatever reason (syscall, irq, exception, or a PMI happening in userspace). The layout of the sample_regs_user bitmap is described in asm/perf_regs.h for archs that support register dump. This is going to be useful to bring Dwarf CFI based stack unwinding on top of samples. Original-patch-by: Frederic Weisbecker <fweisbec@gmail.com> [ Dump registers ABI specification. ] Signed-off-by: Jiri Olsa <jolsa@redhat.com> Suggested-by: Stephane Eranian <eranian@google.com> Cc: "Frank Ch. Eigler" <fche@redhat.com> Cc: Arun Sharma <asharma@fb.com> Cc: Benjamin Redelings <benjamin.redelings@nescent.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Robert Richter <robert.richter@amd.com> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Ulrich Drepper <drepper@gmail.com> Link: http://lkml.kernel.org/r/1344345647-11536-3-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'include/linux/perf_event.h')
-rw-r--r--include/linux/perf_event.h35
1 files changed, 32 insertions, 3 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 7602ccb3f40e..3d4d84745f07 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -130,8 +130,9 @@ enum perf_event_sample_format {
130 PERF_SAMPLE_STREAM_ID = 1U << 9, 130 PERF_SAMPLE_STREAM_ID = 1U << 9,
131 PERF_SAMPLE_RAW = 1U << 10, 131 PERF_SAMPLE_RAW = 1U << 10,
132 PERF_SAMPLE_BRANCH_STACK = 1U << 11, 132 PERF_SAMPLE_BRANCH_STACK = 1U << 11,
133 PERF_SAMPLE_REGS_USER = 1U << 12,
133 134
134 PERF_SAMPLE_MAX = 1U << 12, /* non-ABI */ 135 PERF_SAMPLE_MAX = 1U << 13, /* non-ABI */
135}; 136};
136 137
137/* 138/*
@@ -163,6 +164,15 @@ enum perf_branch_sample_type {
163 PERF_SAMPLE_BRANCH_HV) 164 PERF_SAMPLE_BRANCH_HV)
164 165
165/* 166/*
167 * Values to determine ABI of the registers dump.
168 */
169enum perf_sample_regs_abi {
170 PERF_SAMPLE_REGS_ABI_NONE = 0,
171 PERF_SAMPLE_REGS_ABI_32 = 1,
172 PERF_SAMPLE_REGS_ABI_64 = 2,
173};
174
175/*
166 * The format of the data returned by read() on a perf event fd, 176 * The format of the data returned by read() on a perf event fd,
167 * as specified by attr.read_format: 177 * as specified by attr.read_format:
168 * 178 *
@@ -194,6 +204,7 @@ enum perf_event_read_format {
194#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */ 204#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
195#define PERF_ATTR_SIZE_VER1 72 /* add: config2 */ 205#define PERF_ATTR_SIZE_VER1 72 /* add: config2 */
196#define PERF_ATTR_SIZE_VER2 80 /* add: branch_sample_type */ 206#define PERF_ATTR_SIZE_VER2 80 /* add: branch_sample_type */
207#define PERF_ATTR_SIZE_VER3 88 /* add: sample_regs_user */
197 208
198/* 209/*
199 * Hardware event_id to monitor via a performance monitoring event: 210 * Hardware event_id to monitor via a performance monitoring event:
@@ -271,7 +282,13 @@ struct perf_event_attr {
271 __u64 bp_len; 282 __u64 bp_len;
272 __u64 config2; /* extension of config1 */ 283 __u64 config2; /* extension of config1 */
273 }; 284 };
274 __u64 branch_sample_type; /* enum branch_sample_type */ 285 __u64 branch_sample_type; /* enum perf_branch_sample_type */
286
287 /*
288 * Defines set of user regs to dump on samples.
289 * See asm/perf_regs.h for details.
290 */
291 __u64 sample_regs_user;
275}; 292};
276 293
277/* 294/*
@@ -548,6 +565,9 @@ enum perf_event_type {
548 * char data[size];}&& PERF_SAMPLE_RAW 565 * char data[size];}&& PERF_SAMPLE_RAW
549 * 566 *
550 * { u64 from, to, flags } lbr[nr];} && PERF_SAMPLE_BRANCH_STACK 567 * { u64 from, to, flags } lbr[nr];} && PERF_SAMPLE_BRANCH_STACK
568 *
569 * { u64 abi; # enum perf_sample_regs_abi
570 * u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER
551 * }; 571 * };
552 */ 572 */
553 PERF_RECORD_SAMPLE = 9, 573 PERF_RECORD_SAMPLE = 9,
@@ -609,6 +629,7 @@ struct perf_guest_info_callbacks {
609#include <linux/static_key.h> 629#include <linux/static_key.h>
610#include <linux/atomic.h> 630#include <linux/atomic.h>
611#include <linux/sysfs.h> 631#include <linux/sysfs.h>
632#include <linux/perf_regs.h>
612#include <asm/local.h> 633#include <asm/local.h>
613 634
614struct perf_callchain_entry { 635struct perf_callchain_entry {
@@ -654,6 +675,11 @@ struct perf_branch_stack {
654 struct perf_branch_entry entries[0]; 675 struct perf_branch_entry entries[0];
655}; 676};
656 677
678struct perf_regs_user {
679 __u64 abi;
680 struct pt_regs *regs;
681};
682
657struct task_struct; 683struct task_struct;
658 684
659/* 685/*
@@ -1133,6 +1159,7 @@ struct perf_sample_data {
1133 struct perf_callchain_entry *callchain; 1159 struct perf_callchain_entry *callchain;
1134 struct perf_raw_record *raw; 1160 struct perf_raw_record *raw;
1135 struct perf_branch_stack *br_stack; 1161 struct perf_branch_stack *br_stack;
1162 struct perf_regs_user regs_user;
1136}; 1163};
1137 1164
1138static inline void perf_sample_data_init(struct perf_sample_data *data, 1165static inline void perf_sample_data_init(struct perf_sample_data *data,
@@ -1142,7 +1169,9 @@ static inline void perf_sample_data_init(struct perf_sample_data *data,
1142 data->addr = addr; 1169 data->addr = addr;
1143 data->raw = NULL; 1170 data->raw = NULL;
1144 data->br_stack = NULL; 1171 data->br_stack = NULL;
1145 data->period = period; 1172 data->period = period;
1173 data->regs_user.abi = PERF_SAMPLE_REGS_ABI_NONE;
1174 data->regs_user.regs = NULL;
1146} 1175}
1147 1176
1148extern void perf_output_sample(struct perf_output_handle *handle, 1177extern void perf_output_sample(struct perf_output_handle *handle,