[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d36ac0e2-3f79-6662-c3a8-03c06798f8d3@linux.intel.com>
Date: Mon, 1 Jun 2020 10:34:05 +0300
From: Alexey Budankov <alexey.budankov@...ux.intel.com>
To: Jiri Olsa <jolsa@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Andi Kleen <ak@...ux.intel.com>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 01/10] tools/libperf: introduce static poll file
descriptors
On 31.05.2020 21:19, Jiri Olsa wrote:
> 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?
It depends on whether static fds were added by perf_evlist__add_pollfd_stat() or not.
If they weren't then poll() checks only event fds added by perf_evlist__add_pollfd().
If static fds have been added and there are valid (!=-1) fds still then they are
appended to fds array. After return from poll() its result copied back to static fds
storage so fds state could be checked separately from event fds.
~Alexey
Powered by blists - more mailing lists