diff options
author | Alexey Budankov <[email protected]> | 2020-07-17 09:59:12 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2020-07-21 08:49:30 -0300 |
commit | 59b4412f27f1410a5b22f0244368c4d5ea00d316 (patch) | |
tree | f12829e1c6aa82e7c6b6f75bab0ff984a4441a35 /tools/lib/api/fd/array.c | |
parent | 070b3b5ad7bd077e673cad2c591a2ecf49c0b58a (diff) |
libperf: Avoid internal moving of fdarray fds
Avoid moving of fds by fdarray__filter() so fds indices returned by
fdarray__add() can be used for access and processing of objects at
struct pollfd *entries.
Signed-off-by: Alexey Budankov <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Acked-by: Namhyung Kim <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/lib/api/fd/array.c')
-rw-r--r-- | tools/lib/api/fd/array.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c index 58d44d5eee31..89f9a2193c2d 100644 --- a/tools/lib/api/fd/array.c +++ b/tools/lib/api/fd/array.c @@ -93,22 +93,21 @@ int fdarray__filter(struct fdarray *fda, short revents, return 0; for (fd = 0; fd < fda->nr; ++fd) { + if (!fda->entries[fd].events) + continue; + if (fda->entries[fd].revents & revents) { if (entry_destructor) entry_destructor(fda, fd, arg); + fda->entries[fd].revents = fda->entries[fd].events = 0; continue; } - if (fd != nr) { - fda->entries[nr] = fda->entries[fd]; - fda->priv[nr] = fda->priv[fd]; - } - ++nr; } - return fda->nr = nr; + return nr; } int fdarray__poll(struct fdarray *fda, int timeout) |