John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 1 | #ifndef __PERF_HEADER_H |
| 2 | #define __PERF_HEADER_H |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 3 | |
David Howells | d2709c7 | 2012-11-19 22:21:03 +0000 | [diff] [blame] | 4 | #include <linux/perf_event.h> |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 5 | #include <sys/types.h> |
Arnaldo Carvalho de Melo | 8d06367 | 2009-11-04 18:50:43 -0200 | [diff] [blame] | 6 | #include <stdbool.h> |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 7 | #include "types.h" |
Arnaldo Carvalho de Melo | ef12a14 | 2010-01-20 15:28:45 -0200 | [diff] [blame] | 8 | #include "event.h" |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 9 | |
Frederic Weisbecker | db9f11e | 2009-10-17 17:57:18 +0200 | [diff] [blame] | 10 | #include <linux/bitmap.h> |
| 11 | |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 12 | enum { |
Robert Richter | b1e5a9b | 2011-12-07 10:02:57 +0100 | [diff] [blame] | 13 | HEADER_RESERVED = 0, /* always cleared */ |
Robert Richter | 781ba9d | 2011-12-15 17:32:40 +0100 | [diff] [blame] | 14 | HEADER_FIRST_FEATURE = 1, |
Stephane Eranian | 2eeaaa0 | 2012-05-15 13:28:13 +0200 | [diff] [blame] | 15 | HEADER_TRACING_DATA = 1, |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 16 | HEADER_BUILD_ID, |
Stephane Eranian | fbe96f2 | 2011-09-30 15:40:40 +0200 | [diff] [blame] | 17 | |
| 18 | HEADER_HOSTNAME, |
| 19 | HEADER_OSRELEASE, |
| 20 | HEADER_VERSION, |
| 21 | HEADER_ARCH, |
| 22 | HEADER_NRCPUS, |
| 23 | HEADER_CPUDESC, |
| 24 | HEADER_CPUID, |
| 25 | HEADER_TOTAL_MEM, |
| 26 | HEADER_CMDLINE, |
| 27 | HEADER_EVENT_DESC, |
| 28 | HEADER_CPU_TOPOLOGY, |
| 29 | HEADER_NUMA_TOPOLOGY, |
Stephane Eranian | 330aa67 | 2012-03-08 23:47:46 +0100 | [diff] [blame] | 30 | HEADER_BRANCH_STACK, |
Robert Richter | 50a9667 | 2012-08-16 21:10:24 +0200 | [diff] [blame] | 31 | HEADER_PMU_MAPPINGS, |
Namhyung Kim | a8bb559 | 2013-01-22 18:09:31 +0900 | [diff] [blame] | 32 | HEADER_GROUP_DESC, |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 33 | HEADER_LAST_FEATURE, |
Robert Richter | b1e5a9b | 2011-12-07 10:02:57 +0100 | [diff] [blame] | 34 | HEADER_FEAT_BITS = 256, |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 35 | }; |
Frederic Weisbecker | 2ba0825 | 2009-10-17 17:12:34 +0200 | [diff] [blame] | 36 | |
Jiri Olsa | 2a08c3e | 2013-07-17 19:49:47 +0200 | [diff] [blame^] | 37 | enum perf_header_version { |
| 38 | PERF_HEADER_VERSION_1, |
| 39 | PERF_HEADER_VERSION_2, |
| 40 | }; |
| 41 | |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 42 | struct perf_file_section { |
| 43 | u64 offset; |
| 44 | u64 size; |
| 45 | }; |
| 46 | |
| 47 | struct perf_file_header { |
| 48 | u64 magic; |
| 49 | u64 size; |
| 50 | u64 attr_size; |
| 51 | struct perf_file_section attrs; |
| 52 | struct perf_file_section data; |
Jiri Olsa | 44b3c57 | 2013-07-11 17:28:31 +0200 | [diff] [blame] | 53 | /* event_types is ignored */ |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 54 | struct perf_file_section event_types; |
| 55 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); |
| 56 | }; |
| 57 | |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 58 | struct perf_pipe_file_header { |
| 59 | u64 magic; |
| 60 | u64 size; |
| 61 | }; |
| 62 | |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 63 | struct perf_header; |
| 64 | |
Arnaldo Carvalho de Melo | 1c0b04d | 2011-03-09 08:13:19 -0300 | [diff] [blame] | 65 | int perf_file_header__read(struct perf_file_header *header, |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 66 | struct perf_header *ph, int fd); |
| 67 | |
Namhyung Kim | e93699b | 2012-09-24 17:14:58 +0900 | [diff] [blame] | 68 | struct perf_session_env { |
| 69 | char *hostname; |
| 70 | char *os_release; |
| 71 | char *version; |
| 72 | char *arch; |
| 73 | int nr_cpus_online; |
| 74 | int nr_cpus_avail; |
| 75 | char *cpu_desc; |
| 76 | char *cpuid; |
| 77 | unsigned long long total_mem; |
| 78 | |
| 79 | int nr_cmdline; |
| 80 | char *cmdline; |
| 81 | int nr_sibling_cores; |
| 82 | char *sibling_cores; |
| 83 | int nr_sibling_threads; |
| 84 | char *sibling_threads; |
| 85 | int nr_numa_nodes; |
| 86 | char *numa_nodes; |
| 87 | int nr_pmu_mappings; |
| 88 | char *pmu_mappings; |
Namhyung Kim | a8bb559 | 2013-01-22 18:09:31 +0900 | [diff] [blame] | 89 | int nr_groups; |
Namhyung Kim | e93699b | 2012-09-24 17:14:58 +0900 | [diff] [blame] | 90 | }; |
| 91 | |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 92 | struct perf_header { |
Jiri Olsa | 2a08c3e | 2013-07-17 19:49:47 +0200 | [diff] [blame^] | 93 | enum perf_header_version version; |
| 94 | bool needs_swap; |
| 95 | u64 data_offset; |
| 96 | u64 data_size; |
| 97 | u64 feat_offset; |
Frederic Weisbecker | db9f11e | 2009-10-17 17:57:18 +0200 | [diff] [blame] | 98 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); |
Jiri Olsa | 2a08c3e | 2013-07-17 19:49:47 +0200 | [diff] [blame^] | 99 | struct perf_session_env env; |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 100 | }; |
| 101 | |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 102 | struct perf_evlist; |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 103 | struct perf_session; |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 104 | |
Jiri Olsa | d433956 | 2013-07-17 19:49:41 +0200 | [diff] [blame] | 105 | int perf_session__read_header(struct perf_session *session); |
Arnaldo Carvalho de Melo | a91e543 | 2011-03-10 11:15:54 -0300 | [diff] [blame] | 106 | int perf_session__write_header(struct perf_session *session, |
| 107 | struct perf_evlist *evlist, |
| 108 | int fd, bool at_exit); |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 109 | int perf_header__write_pipe(int fd); |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 110 | |
Arnaldo Carvalho de Melo | 1c0b04d | 2011-03-09 08:13:19 -0300 | [diff] [blame] | 111 | void perf_header__set_feat(struct perf_header *header, int feat); |
| 112 | void perf_header__clear_feat(struct perf_header *header, int feat); |
| 113 | bool perf_header__has_feat(const struct perf_header *header, int feat); |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 114 | |
Stephane Eranian | fbe96f2 | 2011-09-30 15:40:40 +0200 | [diff] [blame] | 115 | int perf_header__set_cmdline(int argc, const char **argv); |
| 116 | |
Arnaldo Carvalho de Melo | 1c0b04d | 2011-03-09 08:13:19 -0300 | [diff] [blame] | 117 | int perf_header__process_sections(struct perf_header *header, int fd, |
Stephane Eranian | fbe96f2 | 2011-09-30 15:40:40 +0200 | [diff] [blame] | 118 | void *data, |
Arnaldo Carvalho de Melo | 1c0b04d | 2011-03-09 08:13:19 -0300 | [diff] [blame] | 119 | int (*process)(struct perf_file_section *section, |
Stephane Eranian | fbe96f2 | 2011-09-30 15:40:40 +0200 | [diff] [blame] | 120 | struct perf_header *ph, |
| 121 | int feat, int fd, void *data)); |
| 122 | |
| 123 | int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full); |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 124 | |
Arnaldo Carvalho de Melo | ef12a14 | 2010-01-20 15:28:45 -0200 | [diff] [blame] | 125 | int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, |
Jiri Olsa | 7dbf4dc | 2012-09-10 18:50:19 +0200 | [diff] [blame] | 126 | const char *name, bool is_kallsyms, bool is_vdso); |
Arnaldo Carvalho de Melo | ef12a14 | 2010-01-20 15:28:45 -0200 | [diff] [blame] | 127 | int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); |
| 128 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 129 | int perf_event__synthesize_attr(struct perf_tool *tool, |
Robert Richter | f4d8343 | 2012-08-16 21:10:17 +0200 | [diff] [blame] | 130 | struct perf_event_attr *attr, u32 ids, u64 *id, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 131 | perf_event__handler_t process); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 132 | int perf_event__synthesize_attrs(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 133 | struct perf_session *session, |
| 134 | perf_event__handler_t process); |
Adrian Hunter | 47c3d10 | 2013-07-04 16:20:21 +0300 | [diff] [blame] | 135 | int perf_event__process_attr(struct perf_tool *tool, union perf_event *event, |
| 136 | struct perf_evlist **pevlist); |
Tom Zanussi | cd19a03 | 2010-04-01 23:59:20 -0500 | [diff] [blame] | 137 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 138 | int perf_event__synthesize_tracing_data(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 139 | int fd, struct perf_evlist *evlist, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 140 | perf_event__handler_t process); |
Adrian Hunter | 47c3d10 | 2013-07-04 16:20:21 +0300 | [diff] [blame] | 141 | int perf_event__process_tracing_data(struct perf_tool *tool, |
| 142 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 143 | struct perf_session *session); |
| 144 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 145 | int perf_event__synthesize_build_id(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 146 | struct dso *pos, u16 misc, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 147 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 148 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 149 | int perf_event__process_build_id(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 150 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 151 | struct perf_session *session); |
Feng Tang | e84ba4e | 2012-10-30 11:56:07 +0800 | [diff] [blame] | 152 | bool is_perf_magic(u64 magic); |
Stephane Eranian | fbe96f2 | 2011-09-30 15:40:40 +0200 | [diff] [blame] | 153 | |
| 154 | /* |
| 155 | * arch specific callback |
| 156 | */ |
| 157 | int get_cpuid(char *buffer, size_t sz); |
| 158 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 159 | #endif /* __PERF_HEADER_H */ |