mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch v2] perf tools: perf list broken on ARM
@ 2013-12-10 19:44 Vince Weaver
  2013-12-11  2:09 ` Namhyung Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Vince Weaver @ 2013-12-10 19:44 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: linux-kernel, Chad Paradis, David Ahern, Ingo Molnar, Jiri Olsa,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

Hello,

"perf list" listing of hardware events doesn't work on older ARM devices.
The change enabling event detection:

commit b41f1cec91c37eeea6fdb15effbfa24ea0a5536b
Author: Namhyung Kim <namhyung.kim@lge.com>
Date:   Tue Aug 27 11:41:53 2013 +0900

    perf list: Skip unsupported events


uses the following code in tools/perf/util/parse-events.c:

       struct perf_event_attr attr = {
               .type = type,
               .config = config,
               .disabled = 1,
               .exclude_kernel = 1,
       };

On ARM machines pre-dating the Cortex-A15 this doesn't work, as
these machines don't support .exclude_kernel.  So starting with 3.12
"perf list" does not report any hardware events at all on older
machines (seen on Rasp-Pi, Pandaboard, Beagleboard, etc).

This version of the patch makes changes suggested by Namhyung Kim 
to check for EACCESS and retry (instead of just dropping
the exclude_kernel) so we can properly handle machines where 
/proc/sys/kernel/perf_event_paranoid is set to 2.


Reported-by: Chad Paradis <chad.paradis@umit.maine.edu>
Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6de6f89..07b6e2d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1082,12 +1082,12 @@ int is_valid_tracepoint(const char *event_string)
 static bool is_event_supported(u8 type, unsigned config)
 {
 	bool ret = true;
+	int open_return;
 	struct perf_evsel *evsel;
 	struct perf_event_attr attr = {
 		.type = type,
 		.config = config,
 		.disabled = 1,
-		.exclude_kernel = 1,
 	};
 	struct {
 		struct thread_map map;
@@ -1099,8 +1099,24 @@ static bool is_event_supported(u8 type, unsigned config)
 
 	evsel = perf_evsel__new(&attr);
 	if (evsel) {
-		ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
+		open_return = perf_evsel__open(evsel, NULL, &tmap.map);
+		ret = open_return >= 0;
 		perf_evsel__delete(evsel);
+
+		if (open_return == -EACCES) {
+			/*
+			 * This happens if the paranoid value
+			 * /proc/sys/kernel/perf_event_paranoid is set to 2
+			 * Re-run with exclude_kernel set; we don't do that
+			 * by default as some ARM machines do not support it.
+			 *
+			 */
+			attr.exclude_kernel = 1;
+			evsel = perf_evsel__new(&attr);
+
+			ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
+			perf_evsel__delete(evsel);
+		}
 	}
 
 	return ret;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch v2] perf tools: perf list broken on ARM
  2013-12-10 19:44 [patch v2] perf tools: perf list broken on ARM Vince Weaver
@ 2013-12-11  2:09 ` Namhyung Kim
  2013-12-14 20:25   ` [patch v3] " Vince Weaver
  0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2013-12-11  2:09 UTC (permalink / raw)
  To: Vince Weaver
  Cc: linux-kernel, Chad Paradis, David Ahern, Ingo Molnar, Jiri Olsa,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

Hi Vince,

On Tue, 10 Dec 2013 14:44:52 -0500 (EST), Vince Weaver wrote:
> Hello,
>
> "perf list" listing of hardware events doesn't work on older ARM devices.
> The change enabling event detection:
>
> commit b41f1cec91c37eeea6fdb15effbfa24ea0a5536b
> Author: Namhyung Kim <namhyung.kim@lge.com>
> Date:   Tue Aug 27 11:41:53 2013 +0900
>
>     perf list: Skip unsupported events
>
>
> uses the following code in tools/perf/util/parse-events.c:
>
>        struct perf_event_attr attr = {
>                .type = type,
>                .config = config,
>                .disabled = 1,
>                .exclude_kernel = 1,
>        };
>
> On ARM machines pre-dating the Cortex-A15 this doesn't work, as
> these machines don't support .exclude_kernel.  So starting with 3.12
> "perf list" does not report any hardware events at all on older
> machines (seen on Rasp-Pi, Pandaboard, Beagleboard, etc).
>
> This version of the patch makes changes suggested by Namhyung Kim 
> to check for EACCESS and retry (instead of just dropping
> the exclude_kernel) so we can properly handle machines where 
> /proc/sys/kernel/perf_event_paranoid is set to 2.
>
>
> Reported-by: Chad Paradis <chad.paradis@umit.maine.edu>
> Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>
>
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 6de6f89..07b6e2d 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -1082,12 +1082,12 @@ int is_valid_tracepoint(const char *event_string)
>  static bool is_event_supported(u8 type, unsigned config)
>  {
>  	bool ret = true;
> +	int open_return;
>  	struct perf_evsel *evsel;
>  	struct perf_event_attr attr = {
>  		.type = type,
>  		.config = config,
>  		.disabled = 1,
> -		.exclude_kernel = 1,
>  	};
>  	struct {
>  		struct thread_map map;
> @@ -1099,8 +1099,24 @@ static bool is_event_supported(u8 type, unsigned config)
>  
>  	evsel = perf_evsel__new(&attr);
>  	if (evsel) {
> -		ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
> +		open_return = perf_evsel__open(evsel, NULL, &tmap.map);
> +		ret = open_return >= 0;
>  		perf_evsel__delete(evsel);
> +
> +		if (open_return == -EACCES) {
> +			/*
> +			 * This happens if the paranoid value
> +			 * /proc/sys/kernel/perf_event_paranoid is set to 2
> +			 * Re-run with exclude_kernel set; we don't do that
> +			 * by default as some ARM machines do not support it.
> +			 *
> +			 */
> +			attr.exclude_kernel = 1;
> +			evsel = perf_evsel__new(&attr);

It seems you need to check the return value.  But I'd rather suggest
re-using existing evsel then. :)

Other than that, it looks good to me.

Thanks,
Namhyung

> +
> +			ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
> +			perf_evsel__delete(evsel);
> +		}
>  	}
>  
>  	return ret;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch v3] perf tools: perf list broken on ARM
  2013-12-11  2:09 ` Namhyung Kim
@ 2013-12-14 20:25   ` Vince Weaver
  2013-12-16  5:14     ` Namhyung Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Vince Weaver @ 2013-12-14 20:25 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: linux-kernel, Chad Paradis, David Ahern, Ingo Molnar, Jiri Olsa,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian


OK, here's an updated version that reuses evsel and hopefully doesn't leak 
memory like the previous patch I posted.


"perf list" listing of hardware events doesn't work on older ARM devices.
The change enabling event detection:

 commit b41f1cec91c37eeea6fdb15effbfa24ea0a5536b
 Author: Namhyung Kim <namhyung.kim@lge.com>
 Date:   Tue Aug 27 11:41:53 2013 +0900

     perf list: Skip unsupported events


uses the following code in tools/perf/util/parse-events.c:

        struct perf_event_attr attr = {
                .type = type,
                .config = config,
                .disabled = 1,
                .exclude_kernel = 1,
        };

On ARM machines pre-dating the Cortex-A15 this doesn't work, as
these machines don't support .exclude_kernel.  So starting with 3.12
"perf list" does not report any hardware events at all on older
machines (seen on Rasp-Pi, Pandaboard, Beagleboard, etc).

This version of the patch makes changes suggested by Namhyung Kim
to check for EACCESS and retry (instead of just dropping
the exclude_kernel) so we can properly handle machines where 
/proc/sys/kernel/perf_event_paranoid is set to 2.

Reported-by: Chad Paradis <chad.paradis@umit.maine.edu>
Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6de6f89..1fa98b9 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1082,12 +1082,12 @@ int is_valid_tracepoint(const char *event_string)
 static bool is_event_supported(u8 type, unsigned config)
 {
 	bool ret = true;
+	int open_return;
 	struct perf_evsel *evsel;
 	struct perf_event_attr attr = {
 		.type = type,
 		.config = config,
 		.disabled = 1,
-		.exclude_kernel = 1,
 	};
 	struct {
 		struct thread_map map;
@@ -1099,7 +1099,20 @@ static bool is_event_supported(u8 type, unsigned config)
 
 	evsel = perf_evsel__new(&attr);
 	if (evsel) {
-		ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
+		open_return = perf_evsel__open(evsel, NULL, &tmap.map);
+		ret = open_return >= 0;
+
+		if (open_return == -EACCES) {
+			/*
+			 * This happens if the paranoid value
+			 * /proc/sys/kernel/perf_event_paranoid is set to 2
+			 * Re-run with exclude_kernel set; we don't do that
+			 * by default as some ARM machines do not support it.
+			 *
+			 */
+			evsel->attr.exclude_kernel = 1;
+			ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
+		}
 		perf_evsel__delete(evsel);
 	}
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch v3] perf tools: perf list broken on ARM
  2013-12-14 20:25   ` [patch v3] " Vince Weaver
@ 2013-12-16  5:14     ` Namhyung Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2013-12-16  5:14 UTC (permalink / raw)
  To: Vince Weaver
  Cc: linux-kernel, Chad Paradis, David Ahern, Ingo Molnar, Jiri Olsa,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

Hi Vince,

On Sat, 14 Dec 2013 15:25:18 -0500 (EST), Vince Weaver wrote:
> OK, here's an updated version that reuses evsel and hopefully doesn't leak 
> memory like the previous patch I posted.
>
>
> "perf list" listing of hardware events doesn't work on older ARM devices.
> The change enabling event detection:
>
>  commit b41f1cec91c37eeea6fdb15effbfa24ea0a5536b
>  Author: Namhyung Kim <namhyung.kim@lge.com>
>  Date:   Tue Aug 27 11:41:53 2013 +0900
>
>      perf list: Skip unsupported events
>
>
> uses the following code in tools/perf/util/parse-events.c:
>
>         struct perf_event_attr attr = {
>                 .type = type,
>                 .config = config,
>                 .disabled = 1,
>                 .exclude_kernel = 1,
>         };
>
> On ARM machines pre-dating the Cortex-A15 this doesn't work, as
> these machines don't support .exclude_kernel.  So starting with 3.12
> "perf list" does not report any hardware events at all on older
> machines (seen on Rasp-Pi, Pandaboard, Beagleboard, etc).
>
> This version of the patch makes changes suggested by Namhyung Kim
> to check for EACCESS and retry (instead of just dropping
> the exclude_kernel) so we can properly handle machines where 
> /proc/sys/kernel/perf_event_paranoid is set to 2.
>
> Reported-by: Chad Paradis <chad.paradis@umit.maine.edu>
> Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-16  5:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-10 19:44 [patch v2] perf tools: perf list broken on ARM Vince Weaver
2013-12-11  2:09 ` Namhyung Kim
2013-12-14 20:25   ` [patch v3] " Vince Weaver
2013-12-16  5:14     ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®