2012-02-06 21:36:30

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [GIT PULL 0/3] perf/urgent fixes

The following changes since commit 84f2b9b2edc09595569c7397cc3c888764ffd78b:

perf: Remove deprecated WARN_ON_ONCE() (2012-02-03 08:24:40 +0100)

are available in the git repository at:

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

for you to fetch changes up to a4a03fc7ef89020baca4f19174e6a43767c6d78a:

perf evsel: Fix an issue where perf report fails to show the proper percentage (2012-02-06 18:59:38 -0200)

----------------------------------------------------------------
Fixes for some long standing problems.

----------------------------------------------------------------
Jiri Olsa (2):
perf tools: Fix perf stack to non executable on x86_64
perf tools: Fix prefix matching for kernel maps

Naveen N. Rao (1):
perf evsel: Fix an issue where perf report fails to show the proper percentage

tools/perf/bench/mem-memcpy-x86-64-asm.S | 6 ++++++
tools/perf/util/event.c | 2 +-
tools/perf/util/evsel.c | 1 +
3 files changed, 8 insertions(+), 1 deletions(-)


2012-02-06 21:36:32

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 1/3] perf tools: Fix perf stack to non executable on x86_64

From: Jiri Olsa <[email protected]>

By adding following objects:
bench/mem-memcpy-x86-64-asm.o
the x86_64 perf binary ended up with executable stack.

The reason was that above object are assembler sourced and is missing the
GNU-stack note section. In such case the linker assumes that the final binary
should not be restricted at all and mark the stack as RWX.

Adding section ".note.GNU-stack" definition to mentioned object, with all
flags disabled, thus omiting this object from linker stack flags decision.

Problem introduced in:

$ git describe ea7872b
v2.6.37-rc2-19-gea7872b

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=783570
Reported-by: Clark Williams <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
[ committer note: Backported fix to perf/urgent (3.3-rc2+) ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/bench/mem-memcpy-x86-64-asm.S | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/perf/bench/mem-memcpy-x86-64-asm.S b/tools/perf/bench/mem-memcpy-x86-64-asm.S
index a57b66e..185a96d 100644
--- a/tools/perf/bench/mem-memcpy-x86-64-asm.S
+++ b/tools/perf/bench/mem-memcpy-x86-64-asm.S
@@ -1,2 +1,8 @@

#include "../../../arch/x86/lib/memcpy_64.S"
+/*
+ * We need to provide note.GNU-stack section, saying that we want
+ * NOT executable stack. Otherwise the final linking will assume that
+ * the ELF stack should not be restricted at all and set it RWX.
+ */
+.section .note.GNU-stack,"",@progbits
--
1.7.9.rc2.1.g69204

2012-02-06 21:36:37

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 3/3] perf evsel: Fix an issue where perf report fails to show the proper percentage

From: "Naveen N. Rao" <[email protected]>

This patch fixes an issue where perf report shows nan% for certain
perf.data files. The below is from a report for a do_fork probe:

-nan% sshd [kernel.kallsyms] [k] do_fork
-nan% packagekitd [kernel.kallsyms] [k] do_fork
-nan% dbus-daemon [kernel.kallsyms] [k] do_fork
-nan% bash [kernel.kallsyms] [k] do_fork

A git bisect shows commit f3bda2c as the cause. However, looking back
through the git history, I saw commit 640c03c which seems to have
removed the required initialization for perf_sample->period. The problem
only started showing after commit f3bda2c. The below patch re-introduces
the initialization and it fixes the problem for me.

With the below patch, for the same perf.data:

73.08% bash [kernel.kallsyms] [k] do_fork
8.97% 11-dhclient [kernel.kallsyms] [k] do_fork
6.41% sshd [kernel.kallsyms] [k] do_fork
3.85% 20-chrony [kernel.kallsyms] [k] do_fork
2.56% sendmail [kernel.kallsyms] [k] do_fork

This patch applies over current linux-tip commit 9949284.

Problem introduced in:

$ git describe 640c03c
v2.6.37-rc3-83-g640c03c

Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Robert Richter <[email protected]>
Cc: Srikar Dronamraju <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Naveen N. Rao <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/evsel.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 667f3b7..7132ee8 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -463,6 +463,7 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
memset(data, 0, sizeof(*data));
data->cpu = data->pid = data->tid = -1;
data->stream_id = data->id = data->time = -1ULL;
+ data->period = 1;

if (event->header.type != PERF_RECORD_SAMPLE) {
if (!sample_id_all)
--
1.7.9.rc2.1.g69204

2012-02-06 21:37:28

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 2/3] perf tools: Fix prefix matching for kernel maps

From: Jiri Olsa <[email protected]>

In some perf ancient versions we used '[kernel.kallsyms._text]' as the
name for the kernel map.

This got changed with commit:
perf: 'perf kvm' tool for monitoring guest performance from host
commit a1645ce12adb6c9cc9e19d7695466204e3f017fe
Author: Zhang, Yanmin <[email protected]>

and we started to use following name '[kernel.kallsyms]_text'.

This name change is important for the report code dealing with ancient
perf data. When processing the kernel map event, we need to recognize
the old naming (dont match the last ']') and initialize the kernel map
correctly.

The subsequent call to maps__set_kallsyms_ref_reloc_sym deals with the
superfluous ']' to get correct symbol name.

Cc: Corey Ashford <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/event.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 73ddaf0..2044324 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -554,7 +554,7 @@ static int perf_event__process_kernel_mmap(struct perf_tool *tool __used,

is_kernel_mmap = memcmp(event->mmap.filename,
kmmap_prefix,
- strlen(kmmap_prefix)) == 0;
+ strlen(kmmap_prefix) - 1) == 0;
if (event->mmap.filename[0] == '/' ||
(!is_kernel_mmap && event->mmap.filename[0] == '[')) {

--
1.7.9.rc2.1.g69204

2012-02-07 08:47:17

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL 0/3] perf/urgent fixes


* Arnaldo Carvalho de Melo <[email protected]> wrote:

> The following changes since commit 84f2b9b2edc09595569c7397cc3c888764ffd78b:
>
> perf: Remove deprecated WARN_ON_ONCE() (2012-02-03 08:24:40 +0100)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf-urgent-for-mingo
>
> for you to fetch changes up to a4a03fc7ef89020baca4f19174e6a43767c6d78a:
>
> perf evsel: Fix an issue where perf report fails to show the proper percentage (2012-02-06 18:59:38 -0200)
>
> ----------------------------------------------------------------
> Fixes for some long standing problems.
>
> ----------------------------------------------------------------
> Jiri Olsa (2):
> perf tools: Fix perf stack to non executable on x86_64
> perf tools: Fix prefix matching for kernel maps
>
> Naveen N. Rao (1):
> perf evsel: Fix an issue where perf report fails to show the proper percentage
>
> tools/perf/bench/mem-memcpy-x86-64-asm.S | 6 ++++++
> tools/perf/util/event.c | 2 +-
> tools/perf/util/evsel.c | 1 +
> 3 files changed, 8 insertions(+), 1 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo