Commit 8ae87cd6 authored by Teng Qin's avatar Teng Qin

Disable perf event FD before free

parent d6827331
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
...@@ -63,8 +64,10 @@ void perf_reader_free(void *ptr) { ...@@ -63,8 +64,10 @@ void perf_reader_free(void *ptr) {
if (ptr) { if (ptr) {
struct perf_reader *reader = ptr; struct perf_reader *reader = ptr;
munmap(reader->base, reader->page_size * (reader->page_cnt + 1)); munmap(reader->base, reader->page_size * (reader->page_cnt + 1));
if (reader->fd >= 0) if (reader->fd >= 0) {
ioctl(reader->fd, PERF_EVENT_IOC_DISABLE, 0);
close(reader->fd); close(reader->fd);
}
free(reader->buf); free(reader->buf);
free(ptr); free(ptr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment