linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/2] perf/urgent fixes
@ 2012-05-02 16:27 Arnaldo Carvalho de Melo
  2012-05-02 16:27 ` [PATCH 1/2] perf build-id: Fix filename size calculation Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-05-02 16:27 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Gleb Natapov,
	Joerg Roedel, Namhyung Kim, Paul Mackerras, Peter Zijlstra,
	Robert Richter, Stephane Eranian, arnaldo.melo,
	Arnaldo Carvalho de Melo

Hi Ingo,

	Please consider pulling,

- Arnaldo

The following changes since commit 33ff581eddf744ea91a50d46c2f0961b375a9595:

  perf symbols: Read plt symbols from proper symtab_type binary (2012-04-20 13:34:49 -0300)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-urgent-for-mingo

for you to fetch changes up to 5622c07b4741e0afd7607bce6e850b76eeb23210:

  perf stat: Fix case where guest/host monitoring is not supported by kernel (2012-05-01 14:20:00 -0300)

----------------------------------------------------------------
Fixes for perf/urgent:

. Add fallback in 'perf stat' for kernels that don't support
  perf_event_attr.exclude_guest, from Stephane Eranian.

. Fix build id cache add routine to take the size of the buffer and not of a
  pointer, from Namhyung Kim.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Namhyung Kim (1):
      perf build-id: Fix filename size calculation

Stephane Eranian (1):
      perf stat: Fix case where guest/host monitoring is not supported by kernel

 tools/perf/builtin-stat.c |   33 +++++++++++++++++++++++++++++----
 tools/perf/util/header.c  |    2 +-
 2 files changed, 30 insertions(+), 5 deletions(-)

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

* [PATCH 1/2] perf build-id: Fix filename size calculation
  2012-05-02 16:27 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
@ 2012-05-02 16:27 ` Arnaldo Carvalho de Melo
  2012-05-02 16:27 ` [PATCH 2/2] perf stat: Fix case where guest/host monitoring is not supported by kernel Arnaldo Carvalho de Melo
  2012-05-02 17:34 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-05-02 16:27 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Namhyung Kim, Ingo Molnar, Paul Mackerras,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Namhyung Kim <namhyung@gmail.com>

The filename is a pointer variable so the sizeof(filename) will return
length of a pointer. Fix it by using 'size'.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1335881976-3282-1-git-send-email-namhyung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/header.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 4c7c2d7..c0b70c6 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -296,7 +296,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
 	if (mkdir_p(filename, 0755))
 		goto out_free;
 
-	snprintf(filename + len, sizeof(filename) - len, "/%s", sbuild_id);
+	snprintf(filename + len, size - len, "/%s", sbuild_id);
 
 	if (access(filename, F_OK)) {
 		if (is_kallsyms) {
-- 
1.7.9.2.358.g22243


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

* [PATCH 2/2] perf stat: Fix case where guest/host monitoring is not supported by kernel
  2012-05-02 16:27 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
  2012-05-02 16:27 ` [PATCH 1/2] perf build-id: Fix filename size calculation Arnaldo Carvalho de Melo
@ 2012-05-02 16:27 ` Arnaldo Carvalho de Melo
  2012-05-02 17:34 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-05-02 16:27 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Stephane Eranian, Gleb Natapov, Ingo Molnar,
	Joerg Roedel, Peter Zijlstra, Robert Richter,
	Arnaldo Carvalho de Melo

From: Stephane Eranian <eranian@google.com>

By default, perf stat sets exclude_guest = 1. But when you run perf on a
kernel which does not support  host/guest filtering, then you get an
error saying the event in unsupported. This comes from the fact that
when the perf_event_attr struct passed by the user is larger than the
one known to the kernel there is safety check which ensures that all
unknown bits are zero. But here, exclude_guest is 1 (part of the unknown
bits) and thus the perf_event_open() syscall return EINVAL.

To my surprise, running perf record on the same kernel did not exhibit
the problem. The reason is that perf record handles the problem by
catching the error and retrying with guest/host excludes set to zero.
For some reason, this was not done with perf stat. This patch fixes this
problem.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <robert.richter@amd.com>
Link: http://lkml.kernel.org/r/20120427124538.GA7230@quad
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c |   33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index c941bb6..4532a78 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -283,6 +283,8 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
 {
 	struct perf_event_attr *attr = &evsel->attr;
 	struct xyarray *group_fd = NULL;
+	bool exclude_guest_missing = false;
+	int ret;
 
 	if (group && evsel != first)
 		group_fd = first->fd;
@@ -293,16 +295,39 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
 
 	attr->inherit = !no_inherit;
 
-	if (system_wide)
-		return perf_evsel__open_per_cpu(evsel, evsel_list->cpus,
+retry:
+	if (exclude_guest_missing)
+		evsel->attr.exclude_guest = evsel->attr.exclude_host = 0;
+
+	if (system_wide) {
+		ret = perf_evsel__open_per_cpu(evsel, evsel_list->cpus,
 						group, group_fd);
+		if (ret)
+			goto check_ret;
+		return 0;
+	}
+
 	if (!target_pid && !target_tid && (!group || evsel == first)) {
 		attr->disabled = 1;
 		attr->enable_on_exec = 1;
 	}
 
-	return perf_evsel__open_per_thread(evsel, evsel_list->threads,
-					   group, group_fd);
+	ret = perf_evsel__open_per_thread(evsel, evsel_list->threads,
+					  group, group_fd);
+	if (!ret)
+		return 0;
+	/* fall through */
+check_ret:
+	if (ret && errno == EINVAL) {
+		if (!exclude_guest_missing &&
+		    (evsel->attr.exclude_guest || evsel->attr.exclude_host)) {
+			pr_debug("Old kernel, cannot exclude "
+				 "guest or host samples.\n");
+			exclude_guest_missing = true;
+			goto retry;
+		}
+	}
+	return ret;
 }
 
 /*
-- 
1.7.9.2.358.g22243


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

* Re: [GIT PULL 0/2] perf/urgent fixes
  2012-05-02 16:27 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
  2012-05-02 16:27 ` [PATCH 1/2] perf build-id: Fix filename size calculation Arnaldo Carvalho de Melo
  2012-05-02 16:27 ` [PATCH 2/2] perf stat: Fix case where guest/host monitoring is not supported by kernel Arnaldo Carvalho de Melo
@ 2012-05-02 17:34 ` Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2012-05-02 17:34 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Gleb Natapov, Joerg Roedel, Namhyung Kim,
	Paul Mackerras, Peter Zijlstra, Robert Richter, Stephane Eranian,
	arnaldo.melo, Arnaldo Carvalho de Melo


* Arnaldo Carvalho de Melo <acme@infradead.org> wrote:

> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit 33ff581eddf744ea91a50d46c2f0961b375a9595:
> 
>   perf symbols: Read plt symbols from proper symtab_type binary (2012-04-20 13:34:49 -0300)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-urgent-for-mingo
> 
> for you to fetch changes up to 5622c07b4741e0afd7607bce6e850b76eeb23210:
> 
>   perf stat: Fix case where guest/host monitoring is not supported by kernel (2012-05-01 14:20:00 -0300)
> 
> ----------------------------------------------------------------
> Fixes for perf/urgent:
> 
> . Add fallback in 'perf stat' for kernels that don't support
>   perf_event_attr.exclude_guest, from Stephane Eranian.
> 
> . Fix build id cache add routine to take the size of the buffer and not of a
>   pointer, from Namhyung Kim.
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Namhyung Kim (1):
>       perf build-id: Fix filename size calculation
> 
> Stephane Eranian (1):
>       perf stat: Fix case where guest/host monitoring is not supported by kernel
> 
>  tools/perf/builtin-stat.c |   33 +++++++++++++++++++++++++++++----
>  tools/perf/util/header.c  |    2 +-
>  2 files changed, 30 insertions(+), 5 deletions(-)

Pulled, thanks Arnaldo!

	Ingo

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

end of thread, other threads:[~2012-05-02 17:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-02 16:27 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
2012-05-02 16:27 ` [PATCH 1/2] perf build-id: Fix filename size calculation Arnaldo Carvalho de Melo
2012-05-02 16:27 ` [PATCH 2/2] perf stat: Fix case where guest/host monitoring is not supported by kernel Arnaldo Carvalho de Melo
2012-05-02 17:34 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar

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).