Re: [PATCH] tools lib fd array: Do not set fd as non blocking evlist
From: Arnaldo Carvalho de Melo
Date: Thu Sep 11 2014 - 11:27:38 EST
Em Thu, Sep 11, 2014 at 05:09:43PM +0200, Jiri Olsa escreveu:
> On Wed, Sep 10, 2014 at 11:08:46AM -0300, Arnaldo Carvalho de Melo wrote:
>
> SNIP
>
> > +}
> > +
> > +void fdarray__exit(struct fdarray *fda)
> > +{
> > + free(fda->entries);
> > + fdarray__init(fda, 0);
> > +}
> > +
> > +void fdarray__delete(struct fdarray *fda)
> > +{
> > + fdarray__exit(fda);
> > + free(fda);
> > +}
> > +
> > +int fdarray__add(struct fdarray *fda, int fd, short revents)
> > +{
> > + if (fda->nr == fda->nr_alloc &&
> > + fdarray__grow(fda, fda->nr_autogrow) < 0)
> > + return -ENOMEM;
> > +
> > + fcntl(fd, F_SETFL, O_NONBLOCK);
>
> also I spot this one and couldn't think of reason for it, attached
> patch makes no behaviour difference for me..
Have to look why it is there, perhaps there is some changeset
specifically made for this, will do some research...
> I might be missing something, but I dont see any blocking operation
> in perf related data reads. The git log history says it was there
> since early days.
Oops, you did that research already, have you followed the history all
the way to when this code lived in Documentation/ ?
But yes, I agree with your comment that this is something up to the
users to do, not for a general purpose class as fdarray is set out to
be.
I think the way to do this is to not move this fcntl when introducing
the fdarray class, but instead leave it at the perf_evlist__add_pollfd()
function, then, in a later patch, if we determine that it is not needed
at all, nuke it, ok?
- Arnaldo
> jirka
>
>
> ---
> There's no reason for the current user of this API
> to have non blocking fds. Also it should be up to
> user to set this, not this object.
>
> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxx>
> Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
> Cc: David Ahern <dsahern@xxxxxxxxx>
> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Jean Pihet <jean.pihet@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: Paul Mackerras <paulus@xxxxxxxxx>
> Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> tools/lib/api/fd/array.c | 1 -
> 1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c
> index 3f6d1a0..0e636c4 100644
> --- a/tools/lib/api/fd/array.c
> +++ b/tools/lib/api/fd/array.c
> @@ -78,7 +78,6 @@ int fdarray__add(struct fdarray *fda, int fd, short revents)
> fdarray__grow(fda, fda->nr_autogrow) < 0)
> return -ENOMEM;
>
> - fcntl(fd, F_SETFL, O_NONBLOCK);
> fda->entries[fda->nr].fd = fd;
> fda->entries[fda->nr].events = revents;
> fda->nr++;
> --
> 1.7.7.6
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/