linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Yann Droneaud <ydroneaud@opteya.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
	linux-kernel@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>,
	William Cohen <wcohen@redhat.com>
Subject: [PATCH] perf tools: Fix PERF_FLAG_FD_CLOEXEC flag probing event type open counters due to EBUSY error
Date: Sun, 3 Aug 2014 14:10:36 +0200	[thread overview]
Message-ID: <20140803121036.GA1181@krava.brq.redhat.com> (raw)
In-Reply-To: <1407002305.3573.12.camel@dworkin>

On Sat, Aug 02, 2014 at 07:58:25PM +0200, Yann Droneaud wrote:
> Hi Jiri,

SNIP

> >  	err = errno;
> >  
> > -	if (WARN_ONCE(fd < 0,
> > +	if (WARN_ONCE(fd < 0 && err != EBUSY,
> >  		      "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n",
> >  		      err, strerror(err)))
> >  		return -1;
> 
> It's definitely possible to shortcut the function if EBUSY is returned
> by first call to perf_event_open().
> 
> diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
> index dc360ebde745..d5c626d5432a 100644
> --- a/tools/perf/util/cloexec.c
> +++ b/tools/perf/util/cloexec.c
> @@ -25,6 +25,9 @@ static int perf_flag_probe(void)
>  		return 1;
>  	}
>  
> +	if (err == EBUSY)
> +		return -1;
> +
>  	WARN_ONCE(err != EINVAL,
>  		  "perf_event_open(..., PERF_FLAG_FD_CLOEXEC) failed with unexpected error %d (%s)\n",
>  		  err, strerror(err));

heh, I haven't realized that your probing event was
PERF_COUNT_SW_CPU_CLOCK, which could never be busy
and found following bug ;-)

jirka


---
We were using PERF_COUNT_SW_CPU_CLOCK as an probing event type.
Using expected PERF_TYPE_SOFTWARE type instead.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: William Cohen <wcohen@redhat.com>
Cc: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/cloexec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
index dc360ebde745..0f7eb0a53d4b 100644
--- a/tools/perf/util/cloexec.c
+++ b/tools/perf/util/cloexec.c
@@ -9,7 +9,7 @@ static int perf_flag_probe(void)
 {
 	/* use 'safest' configuration as used in perf_evsel__fallback() */
 	struct perf_event_attr attr = {
-		.type = PERF_COUNT_SW_CPU_CLOCK,
+		.type = PERF_TYPE_SOFTWARE,
 		.config = PERF_COUNT_SW_CPU_CLOCK,
 	};
 	int fd;
-- 
1.8.3.1


  reply	other threads:[~2014-08-03 12:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01 15:46 [PATCH] perf tools: Show better error message in case we fail to open counters due to EBUSY error Jiri Olsa
2014-08-02 17:58 ` Yann Droneaud
2014-08-03 12:10   ` Jiri Olsa [this message]
2014-08-06 10:00     ` [PATCH] perf tools: Fix PERF_FLAG_FD_CLOEXEC flag probing event type " Yann Droneaud
2014-08-13  5:19     ` [tip:perf/core] " tip-bot for Jiri Olsa
2014-08-02 18:13 ` [PATCH] perf tools: report PERF_FLAG_FD_CLOEXEC probing error once Yann Droneaud
2014-08-03 12:12   ` Jiri Olsa
2014-08-13  5:17 ` [tip:perf/core] perf tools: Show better error message in case we fail to open counters due to EBUSY error tip-bot for Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140803121036.GA1181@krava.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=wcohen@redhat.com \
    --cc=ydroneaud@opteya.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).