.. | .. |
---|
3 | 3 | #include <stdio.h> |
---|
4 | 4 | #include "cpumap.h" |
---|
5 | 5 | #include "event.h" |
---|
| 6 | +#include "util/synthetic-events.h" |
---|
6 | 7 | #include <string.h> |
---|
7 | 8 | #include <linux/bitops.h> |
---|
| 9 | +#include <perf/cpumap.h> |
---|
8 | 10 | #include "debug.h" |
---|
9 | 11 | |
---|
10 | 12 | struct machine; |
---|
.. | .. |
---|
14 | 16 | struct perf_sample *sample __maybe_unused, |
---|
15 | 17 | struct machine *machine __maybe_unused) |
---|
16 | 18 | { |
---|
17 | | - struct cpu_map_event *map_event = &event->cpu_map; |
---|
18 | | - struct cpu_map_mask *mask; |
---|
19 | | - struct cpu_map_data *data; |
---|
20 | | - struct cpu_map *map; |
---|
| 19 | + struct perf_record_cpu_map *map_event = &event->cpu_map; |
---|
| 20 | + struct perf_record_record_cpu_map *mask; |
---|
| 21 | + struct perf_record_cpu_map_data *data; |
---|
| 22 | + struct perf_cpu_map *map; |
---|
21 | 23 | int i; |
---|
22 | 24 | |
---|
23 | 25 | data = &map_event->data; |
---|
24 | 26 | |
---|
25 | 27 | TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__MASK); |
---|
26 | 28 | |
---|
27 | | - mask = (struct cpu_map_mask *)data->data; |
---|
| 29 | + mask = (struct perf_record_record_cpu_map *)data->data; |
---|
28 | 30 | |
---|
29 | 31 | TEST_ASSERT_VAL("wrong nr", mask->nr == 1); |
---|
30 | 32 | |
---|
.. | .. |
---|
39 | 41 | TEST_ASSERT_VAL("wrong cpu", map->map[i] == i); |
---|
40 | 42 | } |
---|
41 | 43 | |
---|
42 | | - cpu_map__put(map); |
---|
| 44 | + perf_cpu_map__put(map); |
---|
43 | 45 | return 0; |
---|
44 | 46 | } |
---|
45 | 47 | |
---|
.. | .. |
---|
48 | 50 | struct perf_sample *sample __maybe_unused, |
---|
49 | 51 | struct machine *machine __maybe_unused) |
---|
50 | 52 | { |
---|
51 | | - struct cpu_map_event *map_event = &event->cpu_map; |
---|
| 53 | + struct perf_record_cpu_map *map_event = &event->cpu_map; |
---|
52 | 54 | struct cpu_map_entries *cpus; |
---|
53 | | - struct cpu_map_data *data; |
---|
54 | | - struct cpu_map *map; |
---|
| 55 | + struct perf_record_cpu_map_data *data; |
---|
| 56 | + struct perf_cpu_map *map; |
---|
55 | 57 | |
---|
56 | 58 | data = &map_event->data; |
---|
57 | 59 | |
---|
.. | .. |
---|
68 | 70 | TEST_ASSERT_VAL("wrong cpu", map->map[0] == 1); |
---|
69 | 71 | TEST_ASSERT_VAL("wrong cpu", map->map[1] == 256); |
---|
70 | 72 | TEST_ASSERT_VAL("wrong refcnt", refcount_read(&map->refcnt) == 1); |
---|
71 | | - cpu_map__put(map); |
---|
| 73 | + perf_cpu_map__put(map); |
---|
72 | 74 | return 0; |
---|
73 | 75 | } |
---|
74 | 76 | |
---|
75 | 77 | |
---|
76 | 78 | int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused) |
---|
77 | 79 | { |
---|
78 | | - struct cpu_map *cpus; |
---|
| 80 | + struct perf_cpu_map *cpus; |
---|
79 | 81 | |
---|
80 | 82 | /* This one is better stores in mask. */ |
---|
81 | | - cpus = cpu_map__new("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19"); |
---|
| 83 | + cpus = perf_cpu_map__new("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19"); |
---|
82 | 84 | |
---|
83 | 85 | TEST_ASSERT_VAL("failed to synthesize map", |
---|
84 | 86 | !perf_event__synthesize_cpu_map(NULL, cpus, process_event_mask, NULL)); |
---|
85 | 87 | |
---|
86 | | - cpu_map__put(cpus); |
---|
| 88 | + perf_cpu_map__put(cpus); |
---|
87 | 89 | |
---|
88 | 90 | /* This one is better stores in cpu values. */ |
---|
89 | | - cpus = cpu_map__new("1,256"); |
---|
| 91 | + cpus = perf_cpu_map__new("1,256"); |
---|
90 | 92 | |
---|
91 | 93 | TEST_ASSERT_VAL("failed to synthesize map", |
---|
92 | 94 | !perf_event__synthesize_cpu_map(NULL, cpus, process_event_cpus, NULL)); |
---|
93 | 95 | |
---|
94 | | - cpu_map__put(cpus); |
---|
| 96 | + perf_cpu_map__put(cpus); |
---|
95 | 97 | return 0; |
---|
96 | 98 | } |
---|
97 | 99 | |
---|
98 | 100 | static int cpu_map_print(const char *str) |
---|
99 | 101 | { |
---|
100 | | - struct cpu_map *map = cpu_map__new(str); |
---|
| 102 | + struct perf_cpu_map *map = perf_cpu_map__new(str); |
---|
101 | 103 | char buf[100]; |
---|
102 | 104 | |
---|
103 | 105 | if (!map) |
---|
.. | .. |
---|
118 | 120 | TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1-10,12-20,22-30,32-40")); |
---|
119 | 121 | return 0; |
---|
120 | 122 | } |
---|
| 123 | + |
---|
| 124 | +int test__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_unused) |
---|
| 125 | +{ |
---|
| 126 | + struct perf_cpu_map *a = perf_cpu_map__new("4,2,1"); |
---|
| 127 | + struct perf_cpu_map *b = perf_cpu_map__new("4,5,7"); |
---|
| 128 | + struct perf_cpu_map *c = perf_cpu_map__merge(a, b); |
---|
| 129 | + char buf[100]; |
---|
| 130 | + |
---|
| 131 | + TEST_ASSERT_VAL("failed to merge map: bad nr", c->nr == 5); |
---|
| 132 | + cpu_map__snprint(c, buf, sizeof(buf)); |
---|
| 133 | + TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7")); |
---|
| 134 | + perf_cpu_map__put(b); |
---|
| 135 | + perf_cpu_map__put(c); |
---|
| 136 | + return 0; |
---|
| 137 | +} |
---|