Em Mon, Jun 20, 2016 at 10:47:20AM +0000, Wang Nan escreveu:
Improve test backward
So, shouldn't this be done at perf_evlist__mmap_read_catchup()? I.e. you
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c
index d9ba991..76e34c0 100644
--- a/tools/perf/tests/backward-ring-buffer.c
+++ b/tools/perf/tests/backward-ring-buffer.c
@@ -31,16 +31,19 @@ static int count_samples(struct perf_evlist *evlist, int *sample_count,
for (i = 0; i < evlist->nr_mmaps; i++) {
union perf_event *event;
- perf_evlist__mmap_read_catchup(evlist, i);
- while ((event = perf_evlist__mmap_read_backward(evlist, i)) != NULL) {
+ if (evlist->backward)
+ perf_evlist__mmap_read_catchup(evlist, i);
will use this only when you know that one of the evlists count_samples()
will deal with can be a backwards one...
I.e. do with perf_evlist__mmap_read_catchup the same thing you did in
perf_evlist__mmap_read, checking there this evlist->backward.
This can be done on top, so I'll continue tentatively merging this.
+ while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {You could've avoided all this by passing some dummy integer pointer for
const u32 type = event->header.type;
switch (type) {
case PERF_RECORD_SAMPLE:
- (*sample_count)++;
+ if (sample_count)
+ (*sample_count)++;
break;
case PERF_RECORD_COMM:
- (*comm_count)++;
+ if (comm_count)
+ (*comm_count)++;
the enter_sample_count case. Making the patch smaller helps reviewing
:-)