diff options
| -rw-r--r-- | tools/perf/util/header.c | 72 |
1 files changed, 44 insertions, 28 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 5e6d4d29a7a3..0fdbf7554ea3 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <linux/list.h> | 12 | #include <linux/list.h> |
| 13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/bitops.h> | 14 | #include <linux/bitops.h> |
| 15 | #include <linux/stringify.h> | ||
| 15 | #include <sys/stat.h> | 16 | #include <sys/stat.h> |
| 16 | #include <sys/types.h> | 17 | #include <sys/types.h> |
| 17 | #include <sys/utsname.h> | 18 | #include <sys/utsname.h> |
| @@ -2139,42 +2140,57 @@ struct feature_ops { | |||
| 2139 | int (*process)(struct feat_fd *ff, void *data); | 2140 | int (*process)(struct feat_fd *ff, void *data); |
| 2140 | const char *name; | 2141 | const char *name; |
| 2141 | bool full_only; | 2142 | bool full_only; |
| 2143 | bool synthesize; | ||
| 2142 | }; | 2144 | }; |
| 2143 | 2145 | ||
| 2144 | #define FEAT_OPA(n, func) \ | 2146 | #define FEAT_OPR(n, func, __full_only) \ |
| 2145 | [n] = { .name = #n, .write = write_##func, .print = print_##func } | 2147 | [HEADER_##n] = { \ |
| 2146 | #define FEAT_OPP(n, func) \ | 2148 | .name = __stringify(n), \ |
| 2147 | [n] = { .name = #n, .write = write_##func, .print = print_##func, \ | 2149 | .write = write_##func, \ |
| 2148 | .process = process_##func } | 2150 | .print = print_##func, \ |
| 2149 | #define FEAT_OPF(n, func) \ | 2151 | .full_only = __full_only, \ |
| 2150 | [n] = { .name = #n, .write = write_##func, .print = print_##func, \ | 2152 | .process = process_##func, \ |
| 2151 | .process = process_##func, .full_only = true } | 2153 | .synthesize = true \ |
| 2154 | } | ||
| 2155 | |||
| 2156 | #define FEAT_OPN(n, func, __full_only) \ | ||
| 2157 | [HEADER_##n] = { \ | ||
| 2158 | .name = __stringify(n), \ | ||
| 2159 | .write = write_##func, \ | ||
| 2160 | .print = print_##func, \ | ||
| 2161 | .full_only = __full_only, \ | ||
| 2162 | .process = process_##func \ | ||
| 2163 | } | ||
| 2152 | 2164 | ||
| 2153 | /* feature_ops not implemented: */ | 2165 | /* feature_ops not implemented: */ |
| 2154 | #define print_tracing_data NULL | 2166 | #define print_tracing_data NULL |
| 2155 | #define print_build_id NULL | 2167 | #define print_build_id NULL |
| 2156 | 2168 | ||
| 2169 | #define process_branch_stack NULL | ||
| 2170 | #define process_stat NULL | ||
| 2171 | |||
| 2172 | |||
| 2157 | static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { | 2173 | static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { |
| 2158 | FEAT_OPP(HEADER_TRACING_DATA, tracing_data), | 2174 | FEAT_OPN(TRACING_DATA, tracing_data, false), |
| 2159 | FEAT_OPP(HEADER_BUILD_ID, build_id), | 2175 | FEAT_OPN(BUILD_ID, build_id, false), |
| 2160 | FEAT_OPP(HEADER_HOSTNAME, hostname), | 2176 | FEAT_OPR(HOSTNAME, hostname, false), |
| 2161 | FEAT_OPP(HEADER_OSRELEASE, osrelease), | 2177 | FEAT_OPR(OSRELEASE, osrelease, false), |
| 2162 | FEAT_OPP(HEADER_VERSION, version), | 2178 | FEAT_OPR(VERSION, version, false), |
| 2163 | FEAT_OPP(HEADER_ARCH, arch), | 2179 | FEAT_OPR(ARCH, arch, false), |
| 2164 | FEAT_OPP(HEADER_NRCPUS, nrcpus), | 2180 | FEAT_OPR(NRCPUS, nrcpus, false), |
| 2165 | FEAT_OPP(HEADER_CPUDESC, cpudesc), | 2181 | FEAT_OPR(CPUDESC, cpudesc, false), |
| 2166 | FEAT_OPP(HEADER_CPUID, cpuid), | 2182 | FEAT_OPR(CPUID, cpuid, false), |
| 2167 | FEAT_OPP(HEADER_TOTAL_MEM, total_mem), | 2183 | FEAT_OPR(TOTAL_MEM, total_mem, false), |
| 2168 | FEAT_OPP(HEADER_EVENT_DESC, event_desc), | 2184 | FEAT_OPR(EVENT_DESC, event_desc, false), |
| 2169 | FEAT_OPP(HEADER_CMDLINE, cmdline), | 2185 | FEAT_OPR(CMDLINE, cmdline, false), |
| 2170 | FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology), | 2186 | FEAT_OPR(CPU_TOPOLOGY, cpu_topology, true), |
| 2171 | FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology), | 2187 | FEAT_OPR(NUMA_TOPOLOGY, numa_topology, true), |
| 2172 | FEAT_OPA(HEADER_BRANCH_STACK, branch_stack), | 2188 | FEAT_OPN(BRANCH_STACK, branch_stack, false), |
| 2173 | FEAT_OPP(HEADER_PMU_MAPPINGS, pmu_mappings), | 2189 | FEAT_OPR(PMU_MAPPINGS, pmu_mappings, false), |
| 2174 | FEAT_OPP(HEADER_GROUP_DESC, group_desc), | 2190 | FEAT_OPN(GROUP_DESC, group_desc, false), |
| 2175 | FEAT_OPP(HEADER_AUXTRACE, auxtrace), | 2191 | FEAT_OPN(AUXTRACE, auxtrace, false), |
| 2176 | FEAT_OPA(HEADER_STAT, stat), | 2192 | FEAT_OPN(STAT, stat, false), |
| 2177 | FEAT_OPF(HEADER_CACHE, cache), | 2193 | FEAT_OPN(CACHE, cache, true), |
| 2178 | }; | 2194 | }; |
| 2179 | 2195 | ||
| 2180 | struct header_print_data { | 2196 | struct header_print_data { |
