All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2 v2] Fix perf-tool crashes when kvm guest is running
@ 2012-02-10 17:05 Joerg Roedel
  2012-02-10 17:05 ` [PATCH 1/2] perf-tool: Don't process samples with no valid machine object Joerg Roedel
  2012-02-10 17:05 ` [PATCH 2/2] perf-tool: Change perf_guest default back to false Joerg Roedel
  0 siblings, 2 replies; 6+ messages in thread
From: Joerg Roedel @ 2012-02-10 17:05 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ingo Molnar, Paul Mackerras, Peter Zijlstra
  Cc: linux-kernel, David Ahern, Jason Wang

Hi,

here are the fixes I promised. These patches should fix the crashes
David and Jason have seen by making sure no sample is processed when
ther is no valid machine object for it. The second patch also changes
the perf_guest default back to false.

v1->v2:

* Introduced counter for unprocessable samples
* Added ui warnings when unprocessable samples are found

Regards,

        Joerg




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

* [PATCH 1/2] perf-tool: Don't process samples with no valid machine object
  2012-02-10 17:05 [PATCH 0/2 v2] Fix perf-tool crashes when kvm guest is running Joerg Roedel
@ 2012-02-10 17:05 ` Joerg Roedel
  2012-02-17  9:47   ` [tip:perf/core] perf top: Don' t " tip-bot for Joerg Roedel
  2012-02-10 17:05 ` [PATCH 2/2] perf-tool: Change perf_guest default back to false Joerg Roedel
  1 sibling, 1 reply; 6+ messages in thread
From: Joerg Roedel @ 2012-02-10 17:05 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ingo Molnar, Paul Mackerras, Peter Zijlstra
  Cc: linux-kernel, David Ahern, Jason Wang, Joerg Roedel

The perf sample processing code relies on a valid machine
object. Make sure that this path is only entered when such a
object exists.

A counter for samples where no machine object exits is also
introduced to give the user a message about these samples.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 tools/perf/builtin-top.c  |    6 ++++++
 tools/perf/util/hist.h    |    1 +
 tools/perf/util/session.c |   10 ++++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index dd162aa..48e0090 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -668,6 +668,12 @@ static void perf_event__process_sample(struct perf_tool *tool,
 		return;
 	}
 
+	if (!machine) {
+		pr_err("%u unprocessable samples recorded.",
+		       top->session->hists.stats.nr_unprocessable_samples++);
+		return;
+	}
+
 	if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
 		top->exact_samples++;
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f55f0a8d..8d5641f 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -32,6 +32,7 @@ struct events_stats {
 	u32 nr_unknown_events;
 	u32 nr_invalid_chains;
 	u32 nr_unknown_id;
+	u32 nr_unprocessable_samples;
 };
 
 enum hist_column {
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b5ca2558..a8d25d9 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -796,6 +796,10 @@ static int perf_session_deliver_event(struct perf_session *session,
 			++session->hists.stats.nr_unknown_id;
 			return -1;
 		}
+		if (machine == NULL) {
+			++session->hists.stats.nr_unprocessable_samples;
+			return -1;
+		}
 		return tool->sample(tool, event, sample, evsel, machine);
 	case PERF_RECORD_MMAP:
 		return tool->mmap(tool, event, sample, machine);
@@ -964,6 +968,12 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
  			    session->hists.stats.nr_invalid_chains,
  			    session->hists.stats.nr_events[PERF_RECORD_SAMPLE]);
  	}
+
+	if (session->hists.stats.nr_unprocessable_samples != 0) {
+		ui__warning("%u unprocessable samples recorded.\n"
+			    "Do you have a KVM guest running and not using 'perf kvm'?\n",
+			    session->hists.stats.nr_unprocessable_samples);
+	}
 }
 
 #define session_done()	(*(volatile int *)(&session_done))
-- 
1.7.5.4



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

* [PATCH 2/2] perf-tool: Change perf_guest default back to false
  2012-02-10 17:05 [PATCH 0/2 v2] Fix perf-tool crashes when kvm guest is running Joerg Roedel
  2012-02-10 17:05 ` [PATCH 1/2] perf-tool: Don't process samples with no valid machine object Joerg Roedel
@ 2012-02-10 17:05 ` Joerg Roedel
  2012-02-17  9:47   ` [tip:perf/core] perf tools: " tip-bot for Joerg Roedel
  2012-03-05  8:38   ` tip-bot for Joerg Roedel
  1 sibling, 2 replies; 6+ messages in thread
From: Joerg Roedel @ 2012-02-10 17:05 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ingo Molnar, Paul Mackerras, Peter Zijlstra
  Cc: linux-kernel, David Ahern, Jason Wang, Joerg Roedel

Setting perf_guest to true by default makes no sense because
the perf subcommands can not setup guest symbol information
and thus not process and guest samples. The only exception
is perf-kvm which changes the perf_guest value on its own.
So change the default for perf_guest back to false.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 tools/perf/util/util.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 8131410..fb25d13 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -6,7 +6,7 @@
  * XXX We need to find a better place for these things...
  */
 bool perf_host  = true;
-bool perf_guest = true;
+bool perf_guest = false;
 
 void event_attr_init(struct perf_event_attr *attr)
 {
-- 
1.7.5.4



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

* [tip:perf/core] perf top: Don' t process samples with no valid machine object
  2012-02-10 17:05 ` [PATCH 1/2] perf-tool: Don't process samples with no valid machine object Joerg Roedel
@ 2012-02-17  9:47   ` tip-bot for Joerg Roedel
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Joerg Roedel @ 2012-02-17  9:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, jasowang,
	joerg.roedel, dsahern, tglx, mingo

Commit-ID:  0c095715b388d19d7a0b7e8eaceeceb018f5b3d1
Gitweb:     http://git.kernel.org/tip/0c095715b388d19d7a0b7e8eaceeceb018f5b3d1
Author:     Joerg Roedel <joerg.roedel@amd.com>
AuthorDate: Fri, 10 Feb 2012 18:05:04 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 13 Feb 2012 22:55:58 -0200

perf top: Don't process samples with no valid machine object

The perf sample processing code relies on a valid machine object. Make
sure that this path is only entered when such a object exists.

A counter for samples where no machine object exits is also introduced
to give the user a message about these samples.

Reported-by: David Ahern <dsahern@gmail.com>
Reported-by: Jason Wang <jasowang@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1328893505-4115-2-git-send-email-joerg.roedel@amd.com
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-top.c  |    6 ++++++
 tools/perf/util/hist.h    |    1 +
 tools/perf/util/session.c |   10 ++++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 94d55cb..5a88c0d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -677,6 +677,12 @@ static void perf_event__process_sample(struct perf_tool *tool,
 		return;
 	}
 
+	if (!machine) {
+		pr_err("%u unprocessable samples recorded.",
+		       top->session->hists.stats.nr_unprocessable_samples++);
+		return;
+	}
+
 	if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
 		top->exact_samples++;
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 0d48613..48e5acd 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -32,6 +32,7 @@ struct events_stats {
 	u32 nr_unknown_events;
 	u32 nr_invalid_chains;
 	u32 nr_unknown_id;
+	u32 nr_unprocessable_samples;
 };
 
 enum hist_column {
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 552c1c5..9f833cf 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -796,6 +796,10 @@ static int perf_session_deliver_event(struct perf_session *session,
 			++session->hists.stats.nr_unknown_id;
 			return -1;
 		}
+		if (machine == NULL) {
+			++session->hists.stats.nr_unprocessable_samples;
+			return -1;
+		}
 		return tool->sample(tool, event, sample, evsel, machine);
 	case PERF_RECORD_MMAP:
 		return tool->mmap(tool, event, sample, machine);
@@ -964,6 +968,12 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
  			    session->hists.stats.nr_invalid_chains,
  			    session->hists.stats.nr_events[PERF_RECORD_SAMPLE]);
  	}
+
+	if (session->hists.stats.nr_unprocessable_samples != 0) {
+		ui__warning("%u unprocessable samples recorded.\n"
+			    "Do you have a KVM guest running and not using 'perf kvm'?\n",
+			    session->hists.stats.nr_unprocessable_samples);
+	}
 }
 
 #define session_done()	(*(volatile int *)(&session_done))

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

* [tip:perf/core] perf tools: Change perf_guest default back to false
  2012-02-10 17:05 ` [PATCH 2/2] perf-tool: Change perf_guest default back to false Joerg Roedel
@ 2012-02-17  9:47   ` tip-bot for Joerg Roedel
  2012-03-05  8:38   ` tip-bot for Joerg Roedel
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Joerg Roedel @ 2012-02-17  9:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, jasowang,
	joerg.roedel, dsahern, tglx, mingo

Commit-ID:  c4a7dca92bbb9881a5d678720f1d0c2153499749
Gitweb:     http://git.kernel.org/tip/c4a7dca92bbb9881a5d678720f1d0c2153499749
Author:     Joerg Roedel <joerg.roedel@amd.com>
AuthorDate: Fri, 10 Feb 2012 18:05:05 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 13 Feb 2012 23:14:44 -0200

perf tools: Change perf_guest default back to false

Setting perf_guest to true by default makes no sense because the perf
subcommands can not setup guest symbol information and thus not process
and guest samples. The only exception is perf-kvm which changes the
perf_guest value on its own.  So change the default for perf_guest back
to false.

Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1328893505-4115-3-git-send-email-joerg.roedel@amd.com
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/util.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 8131410..fb25d13 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -6,7 +6,7 @@
  * XXX We need to find a better place for these things...
  */
 bool perf_host  = true;
-bool perf_guest = true;
+bool perf_guest = false;
 
 void event_attr_init(struct perf_event_attr *attr)
 {

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

* [tip:perf/core] perf tools: Change perf_guest default back to false
  2012-02-10 17:05 ` [PATCH 2/2] perf-tool: Change perf_guest default back to false Joerg Roedel
  2012-02-17  9:47   ` [tip:perf/core] perf tools: " tip-bot for Joerg Roedel
@ 2012-03-05  8:38   ` tip-bot for Joerg Roedel
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Joerg Roedel @ 2012-03-05  8:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, jasowang,
	joerg.roedel, dsahern, tglx, mingo

Commit-ID:  8f54ed4a2d8cf001456d3779bdb33985a050bf03
Gitweb:     http://git.kernel.org/tip/8f54ed4a2d8cf001456d3779bdb33985a050bf03
Author:     Joerg Roedel <joerg.roedel@amd.com>
AuthorDate: Fri, 10 Feb 2012 18:05:05 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 3 Mar 2012 12:13:41 -0300

perf tools: Change perf_guest default back to false

Setting perf_guest to true by default makes no sense because the perf
subcommands can not setup guest symbol information and thus not process
and guest samples. The only exception is perf-kvm which changes the
perf_guest value on its own.  So change the default for perf_guest back
to false.

Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1328893505-4115-3-git-send-email-joerg.roedel@amd.com
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/util.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 8131410..fb25d13 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -6,7 +6,7 @@
  * XXX We need to find a better place for these things...
  */
 bool perf_host  = true;
-bool perf_guest = true;
+bool perf_guest = false;
 
 void event_attr_init(struct perf_event_attr *attr)
 {

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

end of thread, other threads:[~2012-03-05  8:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-10 17:05 [PATCH 0/2 v2] Fix perf-tool crashes when kvm guest is running Joerg Roedel
2012-02-10 17:05 ` [PATCH 1/2] perf-tool: Don't process samples with no valid machine object Joerg Roedel
2012-02-17  9:47   ` [tip:perf/core] perf top: Don' t " tip-bot for Joerg Roedel
2012-02-10 17:05 ` [PATCH 2/2] perf-tool: Change perf_guest default back to false Joerg Roedel
2012-02-17  9:47   ` [tip:perf/core] perf tools: " tip-bot for Joerg Roedel
2012-03-05  8:38   ` tip-bot for Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.