lkml.org 
[lkml]   [2020]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 01/10] tools/libperf: introduce static poll file descriptors
On Mon, May 25, 2020 at 05:17:31PM +0300, Alexey Budankov wrote:

SBIP

> +int fdarray__add_stat(struct fdarray *fda, int fd, short revents)
> +{
> + int pos = fda->nr_stat;
> +
> + if (pos >= FDARRAY__STAT_ENTRIES_MAX)
> + return -1;
> +
> + fda->stat_entries[pos].fd = fd;
> + fda->stat_entries[pos].events = revents;
> + fda->nr_stat++;
> +
> + return pos;
> +}
> +
> int fdarray__filter(struct fdarray *fda, short revents,
> void (*entry_destructor)(struct fdarray *fda, int fd, void *arg),
> void *arg)
> @@ -113,7 +133,27 @@ int fdarray__filter(struct fdarray *fda, short revents,
>
> int fdarray__poll(struct fdarray *fda, int timeout)
> {
> - return poll(fda->entries, fda->nr, timeout);
> + int nr, i, pos, res;
> +
> + nr = fda->nr;
> +
> + for (i = 0; i < fda->nr_stat; i++) {
> + if (fda->stat_entries[i].fd != -1) {
> + pos = fdarray__add(fda, fda->stat_entries[i].fd,
> + fda->stat_entries[i].events);
> + if (pos >= 0)
> + fda->priv[pos].idx = i;
> + }
> + }

hum, so every time we call evlist__poll we end up in here
adding more stuff to entries?

jirka

> +
> + res = poll(fda->entries, fda->nr, timeout);
> +
> + for (i = nr; i < fda->nr; i++)
> + fda->stat_entries[fda->priv[i].idx] = fda->entries[i];
> +
> + fda->nr = nr;
> +
> + return res;
> }

SNIP

\
 
 \ /
  Last update: 2020-05-31 20:19    [W:0.153 / U:0.780 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site