Re: [PATCH 04/10] perf record: Filter out POLLHUP'ed file descriptors

From: Arnaldo Carvalho de Melo
Date: Mon Sep 08 2014 - 11:38:55 EST


Em Mon, Sep 08, 2014 at 05:10:17PM +0200, Jiri Olsa escreveu:
> On Mon, Sep 08, 2014 at 11:33:17AM -0300, Arnaldo Carvalho de Melo wrote:
> > > IMO it's more clear to poll pm all event FDs.. and now with the
> > > case Adrian described it seems necessary anyway

> > I would have to check why was that we were polling just the one where
> > the mmap is done, I don't recall being the one to do it, probably who
> > did it thought that since the ring buffer is there, it was enough (and
> > possibly scaled better, dunno) to do the polling in just one of them.

> for read notification it's ok to poll just for one event, because they
> all share same ringbuffer and perf_poll checks if there's ANY new data

> for the hup notification I think we need to poll all of them

Yeah, I'm convinced of this, I'm working on a patch to make it look at
all file descriptors at poll time.

I'm doing it on top of a patch that will close the mmap when it gets a
POLLHUP, as discussed recently on this thread, in a response I gave to
Adrian.

But since multiple fds share an mmap, we can only close that mmap when
all fds are HUPed, i.e. we need to reference count struct perf_mmap,
which is what I am doing.

I.e. the fist mmaps and sets perf_mmap.nfds to 1, the next one, just
after doing that PERF_EVENT_IOC_SET_OUTPUT will bump perf_mmap.nfds,
unmap gets replaced by mmap_put, that decs and calls munmap when it
hits zero, yadda, yadda.

- Arnaldo
--
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/