[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1389042095.13828.30.camel@localhost.localdomain>
Date: Mon, 06 Jan 2014 22:01:35 +0100
From: Yann Droneaud <ydroneaud@...eya.com>
To: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc: Peter Zijlstra <peterz@...radead.org>,
Paul Mackerras <paulus@...ba.org>,
Ingo Molnar <mingo@...hat.com>, Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Andi Kleen <ak@...ux.intel.com>,
David Ahern <dsahern@...il.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Mike Galbraith <efault@....de>,
Stephane Eranian <eranian@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Michael Ellerman <michael@...erman.id.au>,
linux-kernel@...r.kernel.org, Yann Droneaud <ydroneaud@...eya.com>
Subject: Re: [PATCH] perf tools: enable close-on-exec flag on perf file
descriptor
Hi,
Le lundi 06 janvier 2014 à 11:43 -0300, Arnaldo Carvalho de Melo a
écrit :
> Em Mon, Jan 06, 2014 at 12:24:36PM +0100, Peter Zijlstra escreveu:
> > acme, ACK? I was thinking I'd keep these two patches together so the
> > entire things lands in tip in one go?
>
> Nope, it should notice the EINVAL, drop the flag that doesn't work on
> older kernels, retry, so that new tools continue to work on older
> kernels, with yet another fallback.
>
But it may be difficult to distinguish the 'origin' of EINVAL: is it
from FD_CLOEXEC flag or from an unsupported parameter in the attributes.
> Please take a look at __perf_evsel__open(), probably it will be best to
> add a flag to perf_missing_features, like the one we have for the
> perf_event_attr.mmap2 flag, so that we fail just once, etc.
>
Unfortunately perf_event_open() is called in multiple places, not only
in __perf_evsel__open(). So a more generic solution should be designed.
Is something like the function proposed in message
<1389022310.13828.9.camel@...alhost.localdomain> [1]
ok to be added to its own module:
static int cloexec = PERF_FLAG_FD_CLOEXEC;
int perf_flag_fd_cloexec(void)
{
static int probed;
if (!probed) {
struct perf_event_attr attr = { 0 };
int fd = perf_event_open(&attr, 0, -1, -1,
PERF_FLAG_FD_CLOEXEC);
probed = 1;
if (fd >= 0)
close(fd);
else
cloexec = 0;
}
return cloexec;
}
This function should be used to build the flag passed to
perf_event_open().
Regards.
[1]
http://lkml.kernel.org/r/1389022310.13828.9.camel@localhost.localdomain
--
Yann Droneaud
OPTEYA
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists