diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/evlist.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index d8f34e0afbfb..42ea4e947eb8 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -403,16 +403,20 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx) | |||
403 | return event; | 403 | return event; |
404 | } | 404 | } |
405 | 405 | ||
406 | static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx) | ||
407 | { | ||
408 | if (evlist->mmap[idx].base != NULL) { | ||
409 | munmap(evlist->mmap[idx].base, evlist->mmap_len); | ||
410 | evlist->mmap[idx].base = NULL; | ||
411 | } | ||
412 | } | ||
413 | |||
406 | void perf_evlist__munmap(struct perf_evlist *evlist) | 414 | void perf_evlist__munmap(struct perf_evlist *evlist) |
407 | { | 415 | { |
408 | int i; | 416 | int i; |
409 | 417 | ||
410 | for (i = 0; i < evlist->nr_mmaps; i++) { | 418 | for (i = 0; i < evlist->nr_mmaps; i++) |
411 | if (evlist->mmap[i].base != NULL) { | 419 | __perf_evlist__munmap(evlist, i); |
412 | munmap(evlist->mmap[i].base, evlist->mmap_len); | ||
413 | evlist->mmap[i].base = NULL; | ||
414 | } | ||
415 | } | ||
416 | 420 | ||
417 | free(evlist->mmap); | 421 | free(evlist->mmap); |
418 | evlist->mmap = NULL; | 422 | evlist->mmap = NULL; |
@@ -477,12 +481,8 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m | |||
477 | return 0; | 481 | return 0; |
478 | 482 | ||
479 | out_unmap: | 483 | out_unmap: |
480 | for (cpu = 0; cpu < nr_cpus; cpu++) { | 484 | for (cpu = 0; cpu < nr_cpus; cpu++) |
481 | if (evlist->mmap[cpu].base != NULL) { | 485 | __perf_evlist__munmap(evlist, cpu); |
482 | munmap(evlist->mmap[cpu].base, evlist->mmap_len); | ||
483 | evlist->mmap[cpu].base = NULL; | ||
484 | } | ||
485 | } | ||
486 | return -1; | 486 | return -1; |
487 | } | 487 | } |
488 | 488 | ||
@@ -517,12 +517,8 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, in | |||
517 | return 0; | 517 | return 0; |
518 | 518 | ||
519 | out_unmap: | 519 | out_unmap: |
520 | for (thread = 0; thread < nr_threads; thread++) { | 520 | for (thread = 0; thread < nr_threads; thread++) |
521 | if (evlist->mmap[thread].base != NULL) { | 521 | __perf_evlist__munmap(evlist, thread); |
522 | munmap(evlist->mmap[thread].base, evlist->mmap_len); | ||
523 | evlist->mmap[thread].base = NULL; | ||
524 | } | ||
525 | } | ||
526 | return -1; | 522 | return -1; |
527 | } | 523 | } |
528 | 524 | ||