lkml.org 
[lkml]   [2016]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 36/46] perf record: Don't poll on overwrite channel
    Date
    There's no need to receive events from overwrite ring buffer. Instead,
    perf should make them run background until something happen. This patch
    makes events from overwrite ring buffer is ignored except POLLERR and
    POLLHUP.

    Signed-off-by: Wang Nan <wangnan0@huawei.com>
    Signed-off-by: He Kuang <hekuang@huawei.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Zefan Li <lizefan@huawei.com>
    Cc: pi3orama@163.com
    ---
    tools/perf/util/evlist.c | 23 +++++++++++++++++++----
    1 file changed, 19 insertions(+), 4 deletions(-)

    diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
    index 067c89d..c8112805 100644
    --- a/tools/perf/util/evlist.c
    +++ b/tools/perf/util/evlist.c
    @@ -461,9 +461,9 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
    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
    * close the associated evlist->mmap[] entry.
    @@ -479,7 +479,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)
    {
    - 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)
    @@ -1007,6 +1007,18 @@ perf_evlist__channel_complete(struct perf_evlist *evlist)
    return 0;
    }

    +static bool
    +perf_evlist__should_poll(struct perf_evlist *evlist,
    + struct perf_evsel *evsel,
    + int channel)
    +{
    + if (evsel->system_wide)
    + return false;
    + if (perf_evlist__channel_check(evlist, channel, RDONLY))
    + return false;
    + return true;
    +}
    +
    static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx,
    struct mmap_params *mp, int cpu,
    int thread, int *outputs)
    @@ -1015,6 +1027,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx,

    evlist__for_each(evlist, evsel) {
    int fd, channel, idx, err;
    + short revent = POLLIN;

    channel = perf_evlist__channel_find(evlist, evsel, false);
    if (channel < 0) {
    @@ -1044,6 +1057,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx,
    perf_evlist__mmap_get(evlist, idx);
    }

    + if (!perf_evlist__should_poll(evlist, evsel, channel))
    + revent = 0;
    /*
    * The system_wide flag causes a selected event to be opened
    * always without a pid. Consequently it will never get a
    @@ -1052,7 +1067,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx,
    * Therefore don't add it for polling.
    */
    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);
    return -1;
    }
    --
    1.8.3.4
    \
     
     \ /
      Last update: 2016-02-26 11:21    [W:3.191 / U:1.104 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site