提交 f3058a1c 编写于 作者: W Wang Nan 提交者: Arnaldo Carvalho de Melo

perf evlist: Don't poll and mmap overwritable events

There's no need to receive events from overwritable ring buffer.
Instead, perf should make them run in background until some external
event of interest takes place.  This patch makes ignores normal events from
overwrite evlists.

Overwritable events must be mapped readonly and backward, so if evlist
and evsel doesn't match (evsel->overwrite is true but either evlist is
read/write or evlist is not backward, and vice versa), skip mapping it.
Signed-off-by: NWang Nan <wangnan0@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1464056944-166978-3-git-send-email-wangnan0@huawei.comSigned-off-by: NHe Kuang <hekuang@huawei.com>
[ Split from a larger patch ]
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 c45628b0
...@@ -462,9 +462,9 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) ...@@ -462,9 +462,9 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
return 0; return 0;
} }
static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx) static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx, short revent)
{ {
int pos = fdarray__add(&evlist->pollfd, fd, POLLIN | POLLERR | POLLHUP); int pos = fdarray__add(&evlist->pollfd, fd, revent | POLLERR | POLLHUP);
/* /*
* Save the idx so that when we filter out fds POLLHUP'ed we can * Save the idx so that when we filter out fds POLLHUP'ed we can
* close the associated evlist->mmap[] entry. * close the associated evlist->mmap[] entry.
...@@ -480,7 +480,7 @@ static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx ...@@ -480,7 +480,7 @@ static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx
int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd) int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd)
{ {
return __perf_evlist__add_pollfd(evlist, fd, -1); return __perf_evlist__add_pollfd(evlist, fd, -1, POLLIN);
} }
static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd) static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd)
...@@ -983,15 +983,28 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, ...@@ -983,15 +983,28 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
return 0; return 0;
} }
static bool
perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused,
struct perf_evsel *evsel)
{
if (evsel->overwrite)
return false;
return true;
}
static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
struct mmap_params *mp, int cpu, struct mmap_params *mp, int cpu,
int thread, int *output) int thread, int *output)
{ {
struct perf_evsel *evsel; struct perf_evsel *evsel;
int revent;
evlist__for_each(evlist, evsel) { evlist__for_each(evlist, evsel) {
int fd; int fd;
if (evsel->overwrite != (evlist->overwrite && evlist->backward))
continue;
if (evsel->system_wide && thread) if (evsel->system_wide && thread)
continue; continue;
...@@ -1008,6 +1021,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, ...@@ -1008,6 +1021,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
perf_evlist__mmap_get(evlist, idx); perf_evlist__mmap_get(evlist, idx);
} }
revent = perf_evlist__should_poll(evlist, evsel) ? POLLIN : 0;
/* /*
* The system_wide flag causes a selected event to be opened * The system_wide flag causes a selected event to be opened
* always without a pid. Consequently it will never get a * always without a pid. Consequently it will never get a
...@@ -1016,7 +1031,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, ...@@ -1016,7 +1031,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
* Therefore don't add it for polling. * Therefore don't add it for polling.
*/ */
if (!evsel->system_wide && if (!evsel->system_wide &&
__perf_evlist__add_pollfd(evlist, fd, idx) < 0) { __perf_evlist__add_pollfd(evlist, fd, idx, revent) < 0) {
perf_evlist__mmap_put(evlist, idx); perf_evlist__mmap_put(evlist, idx);
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册