1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/types.h>
3 #include <linux/string.h>
4 #include <linux/zalloc.h>
7 #include "../../../util/event.h"
8 #include "../../../util/synthetic-events.h"
9 #include "../../../util/machine.h"
10 #include "../../../util/tool.h"
11 #include "../../../util/map.h"
12 #include "../../../util/debug.h"
13 #include "util/sample.h"
15 #if defined(__x86_64__)
17 int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
18 perf_event__handler_t process,
19 struct machine *machine)
22 struct map_rb_node *pos;
23 struct maps *kmaps = machine__kernel_maps(machine);
24 union perf_event *event = zalloc(sizeof(event->mmap) +
25 machine->id_hdr_size);
28 pr_debug("Not enough memory synthesizing mmap event "
29 "for extra kernel maps\n");
33 maps__for_each_entry(kmaps, pos) {
36 struct map *map = pos->map;
38 if (!__map__is_extra_kernel_map(map))
41 kmap = map__kmap(map);
43 size = sizeof(event->mmap) - sizeof(event->mmap.filename) +
44 PERF_ALIGN(strlen(kmap->name) + 1, sizeof(u64)) +
47 memset(event, 0, size);
49 event->mmap.header.type = PERF_RECORD_MMAP;
52 * kernel uses 0 for user space maps, see kernel/perf_event.c
55 if (machine__is_host(machine))
56 event->header.misc = PERF_RECORD_MISC_KERNEL;
58 event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;
60 event->mmap.header.size = size;
62 event->mmap.start = map__start(map);
63 event->mmap.len = map__size(map);
64 event->mmap.pgoff = map__pgoff(map);
65 event->mmap.pid = machine->pid;
67 strlcpy(event->mmap.filename, kmap->name, PATH_MAX);
69 if (perf_tool__process_synth_event(tool, event, machine,
82 void arch_perf_parse_sample_weight(struct perf_sample *data,
83 const __u64 *array, u64 type)
85 union perf_sample_weight weight;
88 if (type & PERF_SAMPLE_WEIGHT)
89 data->weight = weight.full;
91 data->weight = weight.var1_dw;
92 data->ins_lat = weight.var2_w;
93 data->retire_lat = weight.var3_w;
97 void arch_perf_synthesize_sample_weight(const struct perf_sample *data,
98 __u64 *array, u64 type)
100 *array = data->weight;
102 if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
103 *array &= 0xffffffff;
104 *array |= ((u64)data->ins_lat << 32);
105 *array |= ((u64)data->retire_lat << 48);
109 const char *arch_perf_header_entry(const char *se_header)
111 if (!strcmp(se_header, "Local Pipeline Stage Cycle"))
112 return "Local Retire Latency";
113 else if (!strcmp(se_header, "Pipeline Stage Cycle"))
114 return "Retire Latency";
119 int arch_support_sort_key(const char *sort_key)
121 if (!strcmp(sort_key, "p_stage_cyc"))
123 if (!strcmp(sort_key, "local_p_stage_cyc"))