diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-test.c | 2 | ||||
-rw-r--r-- | tools/perf/util/event.c | 16 | ||||
-rw-r--r-- | tools/perf/util/event.h | 2 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 68 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 6 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 16 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 7 | ||||
-rw-r--r-- | tools/perf/util/python.c | 14 | ||||
-rw-r--r-- | tools/perf/util/session.c | 12 | ||||
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 8 | ||||
-rw-r--r-- | tools/virtio/virtio_test.c | 19 |
11 files changed, 104 insertions, 66 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index b67186228c89..2da9162262b0 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -474,7 +474,7 @@ static int test__basic_mmap(void) | |||
474 | unsigned int nr_events[nsyscalls], | 474 | unsigned int nr_events[nsyscalls], |
475 | expected_nr_events[nsyscalls], i, j; | 475 | expected_nr_events[nsyscalls], i, j; |
476 | struct perf_evsel *evsels[nsyscalls], *evsel; | 476 | struct perf_evsel *evsels[nsyscalls], *evsel; |
477 | int sample_size = perf_sample_size(attr.sample_type); | 477 | int sample_size = __perf_evsel__sample_size(attr.sample_type); |
478 | 478 | ||
479 | for (i = 0; i < nsyscalls; ++i) { | 479 | for (i = 0; i < nsyscalls; ++i) { |
480 | char name[64]; | 480 | char name[64]; |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 0fe9adf76379..3c1b8a632101 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -35,22 +35,6 @@ const char *perf_event__name(unsigned int id) | |||
35 | return perf_event__names[id]; | 35 | return perf_event__names[id]; |
36 | } | 36 | } |
37 | 37 | ||
38 | int perf_sample_size(u64 sample_type) | ||
39 | { | ||
40 | u64 mask = sample_type & PERF_SAMPLE_MASK; | ||
41 | int size = 0; | ||
42 | int i; | ||
43 | |||
44 | for (i = 0; i < 64; i++) { | ||
45 | if (mask & (1ULL << i)) | ||
46 | size++; | ||
47 | } | ||
48 | |||
49 | size *= sizeof(u64); | ||
50 | |||
51 | return size; | ||
52 | } | ||
53 | |||
54 | static struct perf_sample synth_sample = { | 38 | static struct perf_sample synth_sample = { |
55 | .pid = -1, | 39 | .pid = -1, |
56 | .tid = -1, | 40 | .tid = -1, |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index c08332871408..1d7f66488a88 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -82,8 +82,6 @@ struct perf_sample { | |||
82 | struct ip_callchain *callchain; | 82 | struct ip_callchain *callchain; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | int perf_sample_size(u64 sample_type); | ||
86 | |||
87 | #define BUILD_ID_SIZE 20 | 85 | #define BUILD_ID_SIZE 20 |
88 | 86 | ||
89 | struct build_id_event { | 87 | struct build_id_event { |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 50aa34879c33..b021ea9265c3 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include "evlist.h" | 12 | #include "evlist.h" |
13 | #include "evsel.h" | 13 | #include "evsel.h" |
14 | #include "util.h" | 14 | #include "util.h" |
15 | #include "debug.h" | ||
16 | 15 | ||
17 | #include <sys/mman.h> | 16 | #include <sys/mman.h> |
18 | 17 | ||
@@ -257,19 +256,15 @@ int perf_evlist__alloc_mmap(struct perf_evlist *evlist) | |||
257 | return evlist->mmap != NULL ? 0 : -ENOMEM; | 256 | return evlist->mmap != NULL ? 0 : -ENOMEM; |
258 | } | 257 | } |
259 | 258 | ||
260 | static int __perf_evlist__mmap(struct perf_evlist *evlist, struct perf_evsel *evsel, | 259 | static int __perf_evlist__mmap(struct perf_evlist *evlist, |
261 | int idx, int prot, int mask, int fd) | 260 | int idx, int prot, int mask, int fd) |
262 | { | 261 | { |
263 | evlist->mmap[idx].prev = 0; | 262 | evlist->mmap[idx].prev = 0; |
264 | evlist->mmap[idx].mask = mask; | 263 | evlist->mmap[idx].mask = mask; |
265 | evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot, | 264 | evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot, |
266 | MAP_SHARED, fd, 0); | 265 | MAP_SHARED, fd, 0); |
267 | if (evlist->mmap[idx].base == MAP_FAILED) { | 266 | if (evlist->mmap[idx].base == MAP_FAILED) |
268 | if (evlist->cpus->map[idx] == -1 && evsel->attr.inherit) | ||
269 | ui__warning("Inherit is not allowed on per-task " | ||
270 | "events using mmap.\n"); | ||
271 | return -1; | 267 | return -1; |
272 | } | ||
273 | 268 | ||
274 | perf_evlist__add_pollfd(evlist, fd); | 269 | perf_evlist__add_pollfd(evlist, fd); |
275 | return 0; | 270 | return 0; |
@@ -289,7 +284,7 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m | |||
289 | 284 | ||
290 | if (output == -1) { | 285 | if (output == -1) { |
291 | output = fd; | 286 | output = fd; |
292 | if (__perf_evlist__mmap(evlist, evsel, cpu, | 287 | if (__perf_evlist__mmap(evlist, cpu, |
293 | prot, mask, output) < 0) | 288 | prot, mask, output) < 0) |
294 | goto out_unmap; | 289 | goto out_unmap; |
295 | } else { | 290 | } else { |
@@ -329,7 +324,7 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, in | |||
329 | 324 | ||
330 | if (output == -1) { | 325 | if (output == -1) { |
331 | output = fd; | 326 | output = fd; |
332 | if (__perf_evlist__mmap(evlist, evsel, thread, | 327 | if (__perf_evlist__mmap(evlist, thread, |
333 | prot, mask, output) < 0) | 328 | prot, mask, output) < 0) |
334 | goto out_unmap; | 329 | goto out_unmap; |
335 | } else { | 330 | } else { |
@@ -460,33 +455,46 @@ int perf_evlist__set_filters(struct perf_evlist *evlist) | |||
460 | return 0; | 455 | return 0; |
461 | } | 456 | } |
462 | 457 | ||
463 | u64 perf_evlist__sample_type(struct perf_evlist *evlist) | 458 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist) |
464 | { | 459 | { |
465 | struct perf_evsel *pos; | 460 | struct perf_evsel *pos, *first; |
466 | u64 type = 0; | 461 | |
467 | 462 | pos = first = list_entry(evlist->entries.next, struct perf_evsel, node); | |
468 | list_for_each_entry(pos, &evlist->entries, node) { | 463 | |
469 | if (!type) | 464 | list_for_each_entry_continue(pos, &evlist->entries, node) { |
470 | type = pos->attr.sample_type; | 465 | if (first->attr.sample_type != pos->attr.sample_type) |
471 | else if (type != pos->attr.sample_type) | 466 | return false; |
472 | die("non matching sample_type"); | ||
473 | } | 467 | } |
474 | 468 | ||
475 | return type; | 469 | return true; |
476 | } | 470 | } |
477 | 471 | ||
478 | bool perf_evlist__sample_id_all(const struct perf_evlist *evlist) | 472 | u64 perf_evlist__sample_type(const struct perf_evlist *evlist) |
473 | { | ||
474 | struct perf_evsel *first; | ||
475 | |||
476 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
477 | return first->attr.sample_type; | ||
478 | } | ||
479 | |||
480 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist) | ||
479 | { | 481 | { |
480 | bool value = false, first = true; | 482 | struct perf_evsel *pos, *first; |
481 | struct perf_evsel *pos; | 483 | |
482 | 484 | pos = first = list_entry(evlist->entries.next, struct perf_evsel, node); | |
483 | list_for_each_entry(pos, &evlist->entries, node) { | 485 | |
484 | if (first) { | 486 | list_for_each_entry_continue(pos, &evlist->entries, node) { |
485 | value = pos->attr.sample_id_all; | 487 | if (first->attr.sample_id_all != pos->attr.sample_id_all) |
486 | first = false; | 488 | return false; |
487 | } else if (value != pos->attr.sample_id_all) | ||
488 | die("non matching sample_id_all"); | ||
489 | } | 489 | } |
490 | 490 | ||
491 | return value; | 491 | return true; |
492 | } | ||
493 | |||
494 | bool perf_evlist__sample_id_all(const struct perf_evlist *evlist) | ||
495 | { | ||
496 | struct perf_evsel *first; | ||
497 | |||
498 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
499 | return first->attr.sample_id_all; | ||
492 | } | 500 | } |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 0a1ef1f051f0..b2b862374f37 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -66,7 +66,9 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid, | |||
66 | void perf_evlist__delete_maps(struct perf_evlist *evlist); | 66 | void perf_evlist__delete_maps(struct perf_evlist *evlist); |
67 | int perf_evlist__set_filters(struct perf_evlist *evlist); | 67 | int perf_evlist__set_filters(struct perf_evlist *evlist); |
68 | 68 | ||
69 | u64 perf_evlist__sample_type(struct perf_evlist *evlist); | 69 | u64 perf_evlist__sample_type(const struct perf_evlist *evlist); |
70 | bool perf_evlist__sample_id_all(const struct perf_evlist *evlist); | 70 | bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist); |
71 | 71 | ||
72 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); | ||
73 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); | ||
72 | #endif /* __PERF_EVLIST_H */ | 74 | #endif /* __PERF_EVLIST_H */ |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index cca29ededb5b..0239eb87b232 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -15,6 +15,22 @@ | |||
15 | 15 | ||
16 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) | 16 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) |
17 | 17 | ||
18 | int __perf_evsel__sample_size(u64 sample_type) | ||
19 | { | ||
20 | u64 mask = sample_type & PERF_SAMPLE_MASK; | ||
21 | int size = 0; | ||
22 | int i; | ||
23 | |||
24 | for (i = 0; i < 64; i++) { | ||
25 | if (mask & (1ULL << i)) | ||
26 | size++; | ||
27 | } | ||
28 | |||
29 | size *= sizeof(u64); | ||
30 | |||
31 | return size; | ||
32 | } | ||
33 | |||
18 | void perf_evsel__init(struct perf_evsel *evsel, | 34 | void perf_evsel__init(struct perf_evsel *evsel, |
19 | struct perf_event_attr *attr, int idx) | 35 | struct perf_event_attr *attr, int idx) |
20 | { | 36 | { |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index f79bb2c09a6c..7e9366e4490b 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -149,4 +149,11 @@ static inline int perf_evsel__read_scaled(struct perf_evsel *evsel, | |||
149 | return __perf_evsel__read(evsel, ncpus, nthreads, true); | 149 | return __perf_evsel__read(evsel, ncpus, nthreads, true); |
150 | } | 150 | } |
151 | 151 | ||
152 | int __perf_evsel__sample_size(u64 sample_type); | ||
153 | |||
154 | static inline int perf_evsel__sample_size(struct perf_evsel *evsel) | ||
155 | { | ||
156 | return __perf_evsel__sample_size(evsel->attr.sample_type); | ||
157 | } | ||
158 | |||
152 | #endif /* __PERF_EVSEL_H */ | 159 | #endif /* __PERF_EVSEL_H */ |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 69436b3200a4..a9ac0504aabd 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -674,7 +674,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, | |||
674 | struct perf_evlist *evlist = &pevlist->evlist; | 674 | struct perf_evlist *evlist = &pevlist->evlist; |
675 | union perf_event *event; | 675 | union perf_event *event; |
676 | int sample_id_all = 1, cpu; | 676 | int sample_id_all = 1, cpu; |
677 | static char *kwlist[] = {"sample_id_all", NULL, NULL}; | 677 | static char *kwlist[] = {"cpu", "sample_id_all", NULL, NULL}; |
678 | int err; | 678 | int err; |
679 | 679 | ||
680 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist, | 680 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist, |
@@ -692,16 +692,14 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, | |||
692 | 692 | ||
693 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | 693 | first = list_entry(evlist->entries.next, struct perf_evsel, node); |
694 | err = perf_event__parse_sample(event, first->attr.sample_type, | 694 | err = perf_event__parse_sample(event, first->attr.sample_type, |
695 | perf_sample_size(first->attr.sample_type), | 695 | perf_evsel__sample_size(first), |
696 | sample_id_all, &pevent->sample); | 696 | sample_id_all, &pevent->sample); |
697 | if (err) { | 697 | if (err) |
698 | pr_err("Can't parse sample, err = %d\n", err); | 698 | return PyErr_Format(PyExc_OSError, |
699 | goto end; | 699 | "perf: can't parse sample, err=%d", err); |
700 | } | ||
701 | |||
702 | return pyevent; | 700 | return pyevent; |
703 | } | 701 | } |
704 | end: | 702 | |
705 | Py_INCREF(Py_None); | 703 | Py_INCREF(Py_None); |
706 | return Py_None; | 704 | return Py_None; |
707 | } | 705 | } |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 64500fc78799..f5a8fbdd3f76 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -58,6 +58,16 @@ static int perf_session__open(struct perf_session *self, bool force) | |||
58 | goto out_close; | 58 | goto out_close; |
59 | } | 59 | } |
60 | 60 | ||
61 | if (!perf_evlist__valid_sample_type(self->evlist)) { | ||
62 | pr_err("non matching sample_type"); | ||
63 | goto out_close; | ||
64 | } | ||
65 | |||
66 | if (!perf_evlist__valid_sample_id_all(self->evlist)) { | ||
67 | pr_err("non matching sample_id_all"); | ||
68 | goto out_close; | ||
69 | } | ||
70 | |||
61 | self->size = input_stat.st_size; | 71 | self->size = input_stat.st_size; |
62 | return 0; | 72 | return 0; |
63 | 73 | ||
@@ -97,7 +107,7 @@ out: | |||
97 | void perf_session__update_sample_type(struct perf_session *self) | 107 | void perf_session__update_sample_type(struct perf_session *self) |
98 | { | 108 | { |
99 | self->sample_type = perf_evlist__sample_type(self->evlist); | 109 | self->sample_type = perf_evlist__sample_type(self->evlist); |
100 | self->sample_size = perf_sample_size(self->sample_type); | 110 | self->sample_size = __perf_evsel__sample_size(self->sample_type); |
101 | self->sample_id_all = perf_evlist__sample_id_all(self->evlist); | 111 | self->sample_id_all = perf_evlist__sample_id_all(self->evlist); |
102 | perf_session__id_header_size(self); | 112 | perf_session__id_header_size(self); |
103 | } | 113 | } |
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 1fd29b2daa92..cef28e6632b9 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -788,7 +788,7 @@ sub wait_for_input | |||
788 | 788 | ||
789 | sub reboot_to { | 789 | sub reboot_to { |
790 | if ($reboot_type eq "grub") { | 790 | if ($reboot_type eq "grub") { |
791 | run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'"; | 791 | run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch && reboot)'"; |
792 | return; | 792 | return; |
793 | } | 793 | } |
794 | 794 | ||
@@ -1480,7 +1480,7 @@ sub process_config_ignore { | |||
1480 | or dodie "Failed to read $config"; | 1480 | or dodie "Failed to read $config"; |
1481 | 1481 | ||
1482 | while (<IN>) { | 1482 | while (<IN>) { |
1483 | if (/^(.*?(CONFIG\S*)(=.*| is not set))/) { | 1483 | if (/^((CONFIG\S*)=.*)/) { |
1484 | $config_ignore{$2} = $1; | 1484 | $config_ignore{$2} = $1; |
1485 | } | 1485 | } |
1486 | } | 1486 | } |
@@ -1638,7 +1638,7 @@ sub run_config_bisect { | |||
1638 | if (!$found) { | 1638 | if (!$found) { |
1639 | # try the other half | 1639 | # try the other half |
1640 | doprint "Top half produced no set configs, trying bottom half\n"; | 1640 | doprint "Top half produced no set configs, trying bottom half\n"; |
1641 | @tophalf = @start_list[$half .. $#start_list]; | 1641 | @tophalf = @start_list[$half + 1 .. $#start_list]; |
1642 | create_config @tophalf; | 1642 | create_config @tophalf; |
1643 | read_current_config \%current_config; | 1643 | read_current_config \%current_config; |
1644 | foreach my $config (@tophalf) { | 1644 | foreach my $config (@tophalf) { |
@@ -1690,7 +1690,7 @@ sub run_config_bisect { | |||
1690 | # remove half the configs we are looking at and see if | 1690 | # remove half the configs we are looking at and see if |
1691 | # they are good. | 1691 | # they are good. |
1692 | $half = int($#start_list / 2); | 1692 | $half = int($#start_list / 2); |
1693 | } while ($half > 0); | 1693 | } while ($#start_list > 0); |
1694 | 1694 | ||
1695 | # we found a single config, try it again unless we are running manually | 1695 | # we found a single config, try it again unless we are running manually |
1696 | 1696 | ||
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index df0c6d2c3860..74d3331bdaf9 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c | |||
@@ -198,6 +198,14 @@ const struct option longopts[] = { | |||
198 | .val = 'h', | 198 | .val = 'h', |
199 | }, | 199 | }, |
200 | { | 200 | { |
201 | .name = "event-idx", | ||
202 | .val = 'E', | ||
203 | }, | ||
204 | { | ||
205 | .name = "no-event-idx", | ||
206 | .val = 'e', | ||
207 | }, | ||
208 | { | ||
201 | .name = "indirect", | 209 | .name = "indirect", |
202 | .val = 'I', | 210 | .val = 'I', |
203 | }, | 211 | }, |
@@ -211,13 +219,17 @@ const struct option longopts[] = { | |||
211 | 219 | ||
212 | static void help() | 220 | static void help() |
213 | { | 221 | { |
214 | fprintf(stderr, "Usage: virtio_test [--help] [--no-indirect]\n"); | 222 | fprintf(stderr, "Usage: virtio_test [--help]" |
223 | " [--no-indirect]" | ||
224 | " [--no-event-idx]" | ||
225 | "\n"); | ||
215 | } | 226 | } |
216 | 227 | ||
217 | int main(int argc, char **argv) | 228 | int main(int argc, char **argv) |
218 | { | 229 | { |
219 | struct vdev_info dev; | 230 | struct vdev_info dev; |
220 | unsigned long long features = 1ULL << VIRTIO_RING_F_INDIRECT_DESC; | 231 | unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | |
232 | (1ULL << VIRTIO_RING_F_EVENT_IDX); | ||
221 | int o; | 233 | int o; |
222 | 234 | ||
223 | for (;;) { | 235 | for (;;) { |
@@ -228,6 +240,9 @@ int main(int argc, char **argv) | |||
228 | case '?': | 240 | case '?': |
229 | help(); | 241 | help(); |
230 | exit(2); | 242 | exit(2); |
243 | case 'e': | ||
244 | features &= ~(1ULL << VIRTIO_RING_F_EVENT_IDX); | ||
245 | break; | ||
231 | case 'h': | 246 | case 'h': |
232 | help(); | 247 | help(); |
233 | goto done; | 248 | goto done; |