* [GIT PULL 0/8] perf/core improvements and fixes
@ 2014-05-19 12:30 Jiri Olsa
2014-05-19 12:30 ` [PATCH 1/8] perf tools: Remove usage of trace_sched_wakeup(.success) Jiri Olsa
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Dongsheng Yang, Frederic Weisbecker, Jean Pihet,
Masanari Iida, Namhyung Kim, Paul Mackerras, Peter Zijlstra,
Peter Zijlstra, Will Deacon, Jiri Olsa
hi Ingo,
please consider pulling
thanks,
jirka
The following changes since commit 26f273802b6ed28e059f4359bc7711dffceda022:
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf into perf/core (2014-05-12 17:57:48 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git tags/perf-core-for-mingo
for you to fetch changes up to 97eac381b113932bd7bd4a5c3c68b18e9ff7a2a0:
perf tools: Add libdw DWARF post unwind support for ARM (2014-05-16 11:39:29 +0200)
----------------------------------------------------------------
perf/core improvements and fixes:
. Add libdw DWARF post unwind support for ARM (Jean Pihet)
. Consolidate types.h for ARM and ARM64 (Jean Pihet)
. Fix possible null pointer dereference in session.c (Masanari Iida)
. Cleanup, remove unused variables in map_switch_event() (Dongsheng Yang)
. Remove nr_state_machine_bugs in perf latency (Dongsheng Yang)
. Remove usage of trace_sched_wakeup(.success) (Peter Zijlstra)
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
----------------------------------------------------------------
Dongsheng Yang (2):
perf sched: Remove nr_state_machine_bugs in perf latency
perf sched: Cleanup, remove unused variables in map_switch_event()
Jean Pihet (4):
perf tools: Consolidate types.h for ARM and ARM64
perf tests: Introduce perf_regs_load function on ARM
perf tests: Add dwarf unwind test on ARM
perf tools: Add libdw DWARF post unwind support for ARM
Masanari Iida (1):
perf session: Fix possible null pointer dereference in session.c
Peter Zijlstra (1):
perf tools: Remove usage of trace_sched_wakeup(.success)
tools/perf/Makefile.perf | 2 +-
tools/perf/arch/arm/Makefile | 7 ++++
tools/perf/arch/arm/include/perf_regs.h | 7 +++-
tools/perf/arch/arm/tests/dwarf-unwind.c | 60 +++++++++++++++++++++++++++++++
tools/perf/arch/arm/tests/regs_load.S | 58 ++++++++++++++++++++++++++++++
tools/perf/arch/arm/util/unwind-libdw.c | 36 +++++++++++++++++++
tools/perf/arch/arm64/include/perf_regs.h | 2 +-
tools/perf/builtin-sched.c | 32 ++++++-----------
tools/perf/config/Makefile | 4 +--
tools/perf/tests/builtin-test.c | 2 +-
tools/perf/tests/evsel-tp-sched.c | 3 --
tools/perf/tests/tests.h | 2 +-
tools/perf/util/session.c | 5 +--
13 files changed, 187 insertions(+), 33 deletions(-)
create mode 100644 tools/perf/arch/arm/tests/dwarf-unwind.c
create mode 100644 tools/perf/arch/arm/tests/regs_load.S
create mode 100644 tools/perf/arch/arm/util/unwind-libdw.c
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/8] perf tools: Remove usage of trace_sched_wakeup(.success)
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
@ 2014-05-19 12:30 ` Jiri Olsa
2014-05-19 12:30 ` [PATCH 2/8] perf sched: Remove nr_state_machine_bugs in perf latency Jiri Olsa
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Peter Zijlstra, Jiri Olsa
From: Peter Zijlstra <peterz@infradead.org>
trace_sched_wakeup(.success) is a dead argument and has been for ages,
the only reason its still there is because of brain dead software, which
apparently includes perf tools
There's a few more instances in pearly snake shit, but that's not
supported as far as I care anyhow, so let that bitrot.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140512181946.GG13467@laptop.programming.kicks-ass.net
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-sched.c | 7 +------
tools/perf/tests/evsel-tp-sched.c | 3 ---
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 2579215..a3320f1 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1007,17 +1007,12 @@ static int latency_wakeup_event(struct perf_sched *sched,
struct perf_sample *sample,
struct machine *machine)
{
- const u32 pid = perf_evsel__intval(evsel, sample, "pid"),
- success = perf_evsel__intval(evsel, sample, "success");
+ const u32 pid = perf_evsel__intval(evsel, sample, "pid");
struct work_atoms *atoms;
struct work_atom *atom;
struct thread *wakee;
u64 timestamp = sample->time;
- /* Note for later, it may be interesting to observe the failing cases */
- if (!success)
- return 0;
-
wakee = machine__findnew_thread(machine, 0, pid);
atoms = thread_atoms_search(&sched->atom_root, wakee, &sched->cmp_pid);
if (!atoms) {
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 4774f7f..35d7fdb 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -74,9 +74,6 @@ int test__perf_evsel__tp_sched_test(void)
if (perf_evsel__test_field(evsel, "prio", 4, true))
ret = -1;
- if (perf_evsel__test_field(evsel, "success", 4, true))
- ret = -1;
-
if (perf_evsel__test_field(evsel, "target_cpu", 4, true))
ret = -1;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/8] perf sched: Remove nr_state_machine_bugs in perf latency
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
2014-05-19 12:30 ` [PATCH 1/8] perf tools: Remove usage of trace_sched_wakeup(.success) Jiri Olsa
@ 2014-05-19 12:30 ` Jiri Olsa
2014-05-19 12:30 ` [PATCH 3/8] perf sched: Cleanup, remove unused variables in map_switch_event() Jiri Olsa
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Dongsheng Yang, Jiri Olsa
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
As we do not use .success in sched_wakeup event any more, then
we can not guarantee that the task when wakeup event happen is
out of run queue. So the message of nr_state_machine_bugs is
not correct.
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Link: http://lkml.kernel.org/r/1399945101-21736-1-git-send-email-yangds.fnst@cn.fujitsu.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-sched.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index a3320f1..0b4fe53 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -149,7 +149,6 @@ struct perf_sched {
unsigned long nr_runs;
unsigned long nr_timestamps;
unsigned long nr_unordered_timestamps;
- unsigned long nr_state_machine_bugs;
unsigned long nr_context_switch_bugs;
unsigned long nr_events;
unsigned long nr_lost_chunks;
@@ -1032,12 +1031,18 @@ static int latency_wakeup_event(struct perf_sched *sched,
atom = list_entry(atoms->work_list.prev, struct work_atom, list);
/*
+ * As we do not guarantee the wakeup event happens when
+ * task is out of run queue, also may happen when task is
+ * on run queue and wakeup only change ->state to TASK_RUNNING,
+ * then we should not set the ->wake_up_time when wake up a
+ * task which is on run queue.
+ *
* You WILL be missing events if you've recorded only
* one CPU, or are only looking at only one, so don't
- * make useless noise.
+ * skip in this case.
*/
if (sched->profile_cpu == -1 && atom->state != THREAD_SLEEPING)
- sched->nr_state_machine_bugs++;
+ return 0;
sched->nr_timestamps++;
if (atom->sched_out_time > timestamp) {
@@ -1496,14 +1501,6 @@ static void print_bad_events(struct perf_sched *sched)
(double)sched->nr_lost_events/(double)sched->nr_events * 100.0,
sched->nr_lost_events, sched->nr_events, sched->nr_lost_chunks);
}
- if (sched->nr_state_machine_bugs && sched->nr_timestamps) {
- printf(" INFO: %.3f%% state machine bugs (%ld out of %ld)",
- (double)sched->nr_state_machine_bugs/(double)sched->nr_timestamps*100.0,
- sched->nr_state_machine_bugs, sched->nr_timestamps);
- if (sched->nr_lost_events)
- printf(" (due to lost events?)");
- printf("\n");
- }
if (sched->nr_context_switch_bugs && sched->nr_timestamps) {
printf(" INFO: %.3f%% context switch bugs (%ld out of %ld)",
(double)sched->nr_context_switch_bugs/(double)sched->nr_timestamps*100.0,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/8] perf sched: Cleanup, remove unused variables in map_switch_event()
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
2014-05-19 12:30 ` [PATCH 1/8] perf tools: Remove usage of trace_sched_wakeup(.success) Jiri Olsa
2014-05-19 12:30 ` [PATCH 2/8] perf sched: Remove nr_state_machine_bugs in perf latency Jiri Olsa
@ 2014-05-19 12:30 ` Jiri Olsa
2014-05-19 12:30 ` [PATCH 4/8] perf session: Fix possible null pointer dereference in session.c Jiri Olsa
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Dongsheng Yang, Jiri Olsa
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
In map_switch_event(), we don't care the previous process currently,
this patch remove the infomation we get but not used.
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Link: http://lkml.kernel.org/r/1400218625-14613-1-git-send-email-yangds.fnst@cn.fujitsu.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-sched.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0b4fe53..d717683 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1266,9 +1266,8 @@ static int process_sched_wakeup_event(struct perf_tool *tool,
static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
struct perf_sample *sample, struct machine *machine)
{
- const u32 prev_pid = perf_evsel__intval(evsel, sample, "prev_pid"),
- next_pid = perf_evsel__intval(evsel, sample, "next_pid");
- struct thread *sched_out __maybe_unused, *sched_in;
+ const u32 next_pid = perf_evsel__intval(evsel, sample, "next_pid");
+ struct thread *sched_in;
int new_shortname;
u64 timestamp0, timestamp = sample->time;
s64 delta;
@@ -1291,7 +1290,6 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
return -1;
}
- sched_out = machine__findnew_thread(machine, 0, prev_pid);
sched_in = machine__findnew_thread(machine, 0, next_pid);
sched->curr_thread[this_cpu] = sched_in;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/8] perf session: Fix possible null pointer dereference in session.c
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
` (2 preceding siblings ...)
2014-05-19 12:30 ` [PATCH 3/8] perf sched: Cleanup, remove unused variables in map_switch_event() Jiri Olsa
@ 2014-05-19 12:30 ` Jiri Olsa
2014-05-19 12:30 ` [PATCH 5/8] perf tools: Consolidate types.h for ARM and ARM64 Jiri Olsa
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Masanari Iida, Jiri Olsa
From: Masanari Iida <standby24x7@gmail.com>
cppcheck detected following warning:
[tools/perf/util/session.c:1628] -> [tools/perf/util/session.c:1632]:
(warning) Possible null pointer dereference: session - otherwise it
is redundant to check it against null.
In order to avoide null pointer, check the pointer before use.
Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Link: http://lkml.kernel.org/r/1400087618-13628-1-git-send-email-standby24x7@gmail.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/session.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 55960f2..64a186e 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1625,13 +1625,14 @@ out_delete_map:
void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
bool full)
{
- int fd = perf_data_file__fd(session->file);
struct stat st;
- int ret;
+ int fd, ret;
if (session == NULL || fp == NULL)
return;
+ fd = perf_data_file__fd(session->file);
+
ret = fstat(fd, &st);
if (ret == -1)
return;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/8] perf tools: Consolidate types.h for ARM and ARM64
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
` (3 preceding siblings ...)
2014-05-19 12:30 ` [PATCH 4/8] perf session: Fix possible null pointer dereference in session.c Jiri Olsa
@ 2014-05-19 12:30 ` Jiri Olsa
2014-05-19 12:30 ` [PATCH 6/8] perf tests: Introduce perf_regs_load function on ARM Jiri Olsa
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Jean Pihet, Jiri Olsa
From: Jean Pihet <jean.pihet@linaro.org>
Prevents a build breakage since commit d944c4eebcf4c0d5e5d9728fec110cbf0047ad7f
'tools: Consolidate types.h'
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
Link: http://lkml.kernel.org/r/1400229672-16104-1-git-send-email-jean.pihet@linaro.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/arch/arm/include/perf_regs.h | 2 +-
tools/perf/arch/arm64/include/perf_regs.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h
index 2a1cfde..bcca511 100644
--- a/tools/perf/arch/arm/include/perf_regs.h
+++ b/tools/perf/arch/arm/include/perf_regs.h
@@ -2,7 +2,7 @@
#define ARCH_PERF_REGS_H
#include <stdlib.h>
-#include "../../util/types.h"
+#include <linux/types.h>
#include <asm/perf_regs.h>
#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1)
diff --git a/tools/perf/arch/arm64/include/perf_regs.h b/tools/perf/arch/arm64/include/perf_regs.h
index 2359546..e9441b9 100644
--- a/tools/perf/arch/arm64/include/perf_regs.h
+++ b/tools/perf/arch/arm64/include/perf_regs.h
@@ -2,7 +2,7 @@
#define ARCH_PERF_REGS_H
#include <stdlib.h>
-#include "../../util/types.h"
+#include <linux/types.h>
#include <asm/perf_regs.h>
#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM64_MAX) - 1)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/8] perf tests: Introduce perf_regs_load function on ARM
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
` (4 preceding siblings ...)
2014-05-19 12:30 ` [PATCH 5/8] perf tools: Consolidate types.h for ARM and ARM64 Jiri Olsa
@ 2014-05-19 12:30 ` Jiri Olsa
2014-05-19 12:30 ` [PATCH 7/8] perf tests: Add dwarf unwind test " Jiri Olsa
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Jean Pihet, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Frederic Weisbecker, Namhyung Kim, Paul Mackerras,
Peter Zijlstra, Jiri Olsa
From: Jean Pihet <jean.pihet@linaro.org>
Introducing perf_regs_load function, which is going
to be used for dwarf unwind test in following patches.
It takes single argument as a pointer to the regs dump
buffer and populates it with current registers values.
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1400229672-16104-2-git-send-email-jean.pihet@linaro.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/arch/arm/Makefile | 1 +
tools/perf/arch/arm/include/perf_regs.h | 2 ++
tools/perf/arch/arm/tests/regs_load.S | 58 +++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+)
create mode 100644 tools/perf/arch/arm/tests/regs_load.S
diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile
index 67e9b3d..9b8f87e 100644
--- a/tools/perf/arch/arm/Makefile
+++ b/tools/perf/arch/arm/Makefile
@@ -4,4 +4,5 @@ LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
endif
ifndef NO_LIBUNWIND
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o
endif
diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h
index bcca511..33abcfa 100644
--- a/tools/perf/arch/arm/include/perf_regs.h
+++ b/tools/perf/arch/arm/include/perf_regs.h
@@ -5,6 +5,8 @@
#include <linux/types.h>
#include <asm/perf_regs.h>
+void perf_regs_load(u64 *regs);
+
#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1)
#define PERF_REG_IP PERF_REG_ARM_PC
#define PERF_REG_SP PERF_REG_ARM_SP
diff --git a/tools/perf/arch/arm/tests/regs_load.S b/tools/perf/arch/arm/tests/regs_load.S
new file mode 100644
index 0000000..e09e983
--- /dev/null
+++ b/tools/perf/arch/arm/tests/regs_load.S
@@ -0,0 +1,58 @@
+#include <linux/linkage.h>
+
+#define R0 0x00
+#define R1 0x08
+#define R2 0x10
+#define R3 0x18
+#define R4 0x20
+#define R5 0x28
+#define R6 0x30
+#define R7 0x38
+#define R8 0x40
+#define R9 0x48
+#define SL 0x50
+#define FP 0x58
+#define IP 0x60
+#define SP 0x68
+#define LR 0x70
+#define PC 0x78
+
+/*
+ * Implementation of void perf_regs_load(u64 *regs);
+ *
+ * This functions fills in the 'regs' buffer from the actual registers values,
+ * in the way the perf built-in unwinding test expects them:
+ * - the PC at the time at the call to this function. Since this function
+ * is called using a bl instruction, the PC value is taken from LR.
+ * The built-in unwinding test then unwinds the call stack from the dwarf
+ * information in unwind__get_entries.
+ *
+ * Notes:
+ * - the 8 bytes stride in the registers offsets comes from the fact
+ * that the registers are stored in an u64 array (u64 *regs),
+ * - the regs buffer needs to be zeroed before the call to this function,
+ * in this case using a calloc in dwarf-unwind.c.
+ */
+
+.text
+.type perf_regs_load,%function
+ENTRY(perf_regs_load)
+ str r0, [r0, #R0]
+ str r1, [r0, #R1]
+ str r2, [r0, #R2]
+ str r3, [r0, #R3]
+ str r4, [r0, #R4]
+ str r5, [r0, #R5]
+ str r6, [r0, #R6]
+ str r7, [r0, #R7]
+ str r8, [r0, #R8]
+ str r9, [r0, #R9]
+ str sl, [r0, #SL]
+ str fp, [r0, #FP]
+ str ip, [r0, #IP]
+ str sp, [r0, #SP]
+ str lr, [r0, #LR]
+ str lr, [r0, #PC] // store pc as lr in order to skip the call
+ // to this function
+ mov pc, lr
+ENDPROC(perf_regs_load)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/8] perf tests: Add dwarf unwind test on ARM
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
` (5 preceding siblings ...)
2014-05-19 12:30 ` [PATCH 6/8] perf tests: Introduce perf_regs_load function on ARM Jiri Olsa
@ 2014-05-19 12:30 ` Jiri Olsa
2014-05-19 12:30 ` [PATCH 8/8] perf tools: Add libdw DWARF post unwind support for ARM Jiri Olsa
2014-05-20 6:37 ` [GIT PULL 0/8] perf/core improvements and fixes Ingo Molnar
8 siblings, 0 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Jean Pihet, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Frederic Weisbecker, Namhyung Kim, Paul Mackerras,
Peter Zijlstra, Jiri Olsa
From: Jean Pihet <jean.pihet@linaro.org>
Adding dwarf unwind test, that setups live machine data over
the perf test thread and does the remote unwind.
Need to use -fno-optimize-sibling-calls for test compilation,
otherwise 'krava_*' function calls are optimized into jumps
and omitted from the stack unwind.
So far it was enabled only for x86.
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1400229672-16104-3-git-send-email-jean.pihet@linaro.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Makefile.perf | 2 +-
tools/perf/arch/arm/Makefile | 1 +
tools/perf/arch/arm/include/perf_regs.h | 3 ++
tools/perf/arch/arm/tests/dwarf-unwind.c | 60 ++++++++++++++++++++++++++++++++
tools/perf/config/Makefile | 4 +--
tools/perf/tests/builtin-test.c | 2 +-
tools/perf/tests/tests.h | 2 +-
7 files changed, 69 insertions(+), 5 deletions(-)
create mode 100644 tools/perf/arch/arm/tests/dwarf-unwind.c
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 2baf61c..dea2d633 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -411,7 +411,7 @@ LIB_OBJS += $(OUTPUT)tests/code-reading.o
LIB_OBJS += $(OUTPUT)tests/sample-parsing.o
LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o
ifndef NO_DWARF_UNWIND
-ifeq ($(ARCH),x86)
+ifeq ($(ARCH),$(filter $(ARCH),x86 arm))
LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o
endif
endif
diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile
index 9b8f87e..221f21d 100644
--- a/tools/perf/arch/arm/Makefile
+++ b/tools/perf/arch/arm/Makefile
@@ -5,4 +5,5 @@ endif
ifndef NO_LIBUNWIND
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/dwarf-unwind.o
endif
diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h
index 33abcfa..f619c9c 100644
--- a/tools/perf/arch/arm/include/perf_regs.h
+++ b/tools/perf/arch/arm/include/perf_regs.h
@@ -8,6 +8,9 @@
void perf_regs_load(u64 *regs);
#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1)
+#define PERF_REGS_MAX PERF_REG_ARM_MAX
+#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
+
#define PERF_REG_IP PERF_REG_ARM_PC
#define PERF_REG_SP PERF_REG_ARM_SP
diff --git a/tools/perf/arch/arm/tests/dwarf-unwind.c b/tools/perf/arch/arm/tests/dwarf-unwind.c
new file mode 100644
index 0000000..9f870d2
--- /dev/null
+++ b/tools/perf/arch/arm/tests/dwarf-unwind.c
@@ -0,0 +1,60 @@
+#include <string.h>
+#include "perf_regs.h"
+#include "thread.h"
+#include "map.h"
+#include "event.h"
+#include "tests/tests.h"
+
+#define STACK_SIZE 8192
+
+static int sample_ustack(struct perf_sample *sample,
+ struct thread *thread, u64 *regs)
+{
+ struct stack_dump *stack = &sample->user_stack;
+ struct map *map;
+ unsigned long sp;
+ u64 stack_size, *buf;
+
+ buf = malloc(STACK_SIZE);
+ if (!buf) {
+ pr_debug("failed to allocate sample uregs data\n");
+ return -1;
+ }
+
+ sp = (unsigned long) regs[PERF_REG_ARM_SP];
+
+ map = map_groups__find(thread->mg, MAP__VARIABLE, (u64) sp);
+ if (!map) {
+ pr_debug("failed to get stack map\n");
+ free(buf);
+ return -1;
+ }
+
+ stack_size = map->end - sp;
+ stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
+
+ memcpy(buf, (void *) sp, stack_size);
+ stack->data = (char *) buf;
+ stack->size = stack_size;
+ return 0;
+}
+
+int test__arch_unwind_sample(struct perf_sample *sample,
+ struct thread *thread)
+{
+ struct regs_dump *regs = &sample->user_regs;
+ u64 *buf;
+
+ buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
+ if (!buf) {
+ pr_debug("failed to allocate sample uregs data\n");
+ return -1;
+ }
+
+ perf_regs_load(buf);
+ regs->abi = PERF_SAMPLE_REGS_ABI;
+ regs->regs = buf;
+ regs->mask = PERF_REGS_MASK;
+
+ return sample_ustack(sample, thread, buf);
+}
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index f2edc59..729bbdf 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -40,11 +40,11 @@ ifeq ($(ARCH),arm64)
LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
endif
-# So far there's only x86 libdw unwind support merged in perf.
+# So far there's only x86 and arm libdw unwind support merged in perf.
# Disable it on all other architectures in case libdw unwind
# support is detected in system. Add supported architectures
# to the check.
-ifneq ($(ARCH),x86)
+ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
NO_LIBDW_DWARF_UNWIND := 1
endif
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 0d5afaf..5e0764b 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -115,7 +115,7 @@ static struct test {
.desc = "Test parsing with no sample_id_all bit set",
.func = test__parse_no_sample_id_all,
},
-#if defined(__x86_64__) || defined(__i386__)
+#if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT
{
.desc = "Test dwarf unwind",
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index a9d7cb0..8f91fb0 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -45,7 +45,7 @@ int test__hists_filter(void);
int test__mmap_thread_lookup(void);
int test__thread_mg_share(void);
-#if defined(__x86_64__) || defined(__i386__)
+#if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT
struct thread;
struct perf_sample;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 8/8] perf tools: Add libdw DWARF post unwind support for ARM
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
` (6 preceding siblings ...)
2014-05-19 12:30 ` [PATCH 7/8] perf tests: Add dwarf unwind test " Jiri Olsa
@ 2014-05-19 12:30 ` Jiri Olsa
2014-05-20 6:37 ` [GIT PULL 0/8] perf/core improvements and fixes Ingo Molnar
8 siblings, 0 replies; 10+ messages in thread
From: Jiri Olsa @ 2014-05-19 12:30 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Jean Pihet, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Frederic Weisbecker, Namhyung Kim, Paul Mackerras,
Peter Zijlstra, Jiri Olsa
From: Jean Pihet <jean.pihet@linaro.org>
Adding libdw DWARF post unwind support, which is part
of elfutils-devel/libdw-dev package from version 0.158.
The new code is contained in unwin-libdw.c object, and
implements unwind__get_entries unwind interface function.
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1400229672-16104-4-git-send-email-jean.pihet@linaro.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/arch/arm/Makefile | 5 +++++
tools/perf/arch/arm/util/unwind-libdw.c | 36 +++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
create mode 100644 tools/perf/arch/arm/util/unwind-libdw.c
diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile
index 221f21d..09d6215 100644
--- a/tools/perf/arch/arm/Makefile
+++ b/tools/perf/arch/arm/Makefile
@@ -4,6 +4,11 @@ LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
endif
ifndef NO_LIBUNWIND
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o
+endif
+ifndef NO_LIBDW_DWARF_UNWIND
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libdw.o
+endif
+ifndef NO_DWARF_UNWIND
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/dwarf-unwind.o
endif
diff --git a/tools/perf/arch/arm/util/unwind-libdw.c b/tools/perf/arch/arm/util/unwind-libdw.c
new file mode 100644
index 0000000..b4176c6
--- /dev/null
+++ b/tools/perf/arch/arm/util/unwind-libdw.c
@@ -0,0 +1,36 @@
+#include <elfutils/libdwfl.h>
+#include "../../util/unwind-libdw.h"
+#include "../../util/perf_regs.h"
+
+bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
+{
+ struct unwind_info *ui = arg;
+ struct regs_dump *user_regs = &ui->sample->user_regs;
+ Dwarf_Word dwarf_regs[PERF_REG_ARM_MAX];
+
+#define REG(r) ({ \
+ Dwarf_Word val = 0; \
+ perf_reg_value(&val, user_regs, PERF_REG_ARM_##r); \
+ val; \
+})
+
+ dwarf_regs[0] = REG(R0);
+ dwarf_regs[1] = REG(R1);
+ dwarf_regs[2] = REG(R2);
+ dwarf_regs[3] = REG(R3);
+ dwarf_regs[4] = REG(R4);
+ dwarf_regs[5] = REG(R5);
+ dwarf_regs[6] = REG(R6);
+ dwarf_regs[7] = REG(R7);
+ dwarf_regs[8] = REG(R8);
+ dwarf_regs[9] = REG(R9);
+ dwarf_regs[10] = REG(R10);
+ dwarf_regs[11] = REG(FP);
+ dwarf_regs[12] = REG(IP);
+ dwarf_regs[13] = REG(SP);
+ dwarf_regs[14] = REG(LR);
+ dwarf_regs[15] = REG(PC);
+
+ return dwfl_thread_state_registers(thread, 0, PERF_REG_ARM_MAX,
+ dwarf_regs);
+}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [GIT PULL 0/8] perf/core improvements and fixes
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
` (7 preceding siblings ...)
2014-05-19 12:30 ` [PATCH 8/8] perf tools: Add libdw DWARF post unwind support for ARM Jiri Olsa
@ 2014-05-20 6:37 ` Ingo Molnar
8 siblings, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2014-05-20 6:37 UTC (permalink / raw)
To: Jiri Olsa
Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Dongsheng Yang, Frederic Weisbecker, Jean Pihet,
Masanari Iida, Namhyung Kim, Paul Mackerras, Peter Zijlstra,
Peter Zijlstra, Will Deacon
* Jiri Olsa <jolsa@kernel.org> wrote:
> hi Ingo,
> please consider pulling
>
> thanks,
> jirka
>
>
> The following changes since commit 26f273802b6ed28e059f4359bc7711dffceda022:
>
> Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf into perf/core (2014-05-12 17:57:48 +0200)
>
> are available in the git repository at:
>
>
> git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git tags/perf-core-for-mingo
>
> for you to fetch changes up to 97eac381b113932bd7bd4a5c3c68b18e9ff7a2a0:
>
> perf tools: Add libdw DWARF post unwind support for ARM (2014-05-16 11:39:29 +0200)
>
> ----------------------------------------------------------------
> perf/core improvements and fixes:
>
> . Add libdw DWARF post unwind support for ARM (Jean Pihet)
>
> . Consolidate types.h for ARM and ARM64 (Jean Pihet)
>
> . Fix possible null pointer dereference in session.c (Masanari Iida)
>
> . Cleanup, remove unused variables in map_switch_event() (Dongsheng Yang)
>
> . Remove nr_state_machine_bugs in perf latency (Dongsheng Yang)
>
> . Remove usage of trace_sched_wakeup(.success) (Peter Zijlstra)
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>
> ----------------------------------------------------------------
> Dongsheng Yang (2):
> perf sched: Remove nr_state_machine_bugs in perf latency
> perf sched: Cleanup, remove unused variables in map_switch_event()
>
> Jean Pihet (4):
> perf tools: Consolidate types.h for ARM and ARM64
> perf tests: Introduce perf_regs_load function on ARM
> perf tests: Add dwarf unwind test on ARM
> perf tools: Add libdw DWARF post unwind support for ARM
>
> Masanari Iida (1):
> perf session: Fix possible null pointer dereference in session.c
>
> Peter Zijlstra (1):
> perf tools: Remove usage of trace_sched_wakeup(.success)
>
> tools/perf/Makefile.perf | 2 +-
> tools/perf/arch/arm/Makefile | 7 ++++
> tools/perf/arch/arm/include/perf_regs.h | 7 +++-
> tools/perf/arch/arm/tests/dwarf-unwind.c | 60 +++++++++++++++++++++++++++++++
> tools/perf/arch/arm/tests/regs_load.S | 58 ++++++++++++++++++++++++++++++
> tools/perf/arch/arm/util/unwind-libdw.c | 36 +++++++++++++++++++
> tools/perf/arch/arm64/include/perf_regs.h | 2 +-
> tools/perf/builtin-sched.c | 32 ++++++-----------
> tools/perf/config/Makefile | 4 +--
> tools/perf/tests/builtin-test.c | 2 +-
> tools/perf/tests/evsel-tp-sched.c | 3 --
> tools/perf/tests/tests.h | 2 +-
> tools/perf/util/session.c | 5 +--
> 13 files changed, 187 insertions(+), 33 deletions(-)
> create mode 100644 tools/perf/arch/arm/tests/dwarf-unwind.c
> create mode 100644 tools/perf/arch/arm/tests/regs_load.S
> create mode 100644 tools/perf/arch/arm/util/unwind-libdw.c
Pulled, thanks a lot Jiri!
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-05-20 6:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
2014-05-19 12:30 ` [PATCH 1/8] perf tools: Remove usage of trace_sched_wakeup(.success) Jiri Olsa
2014-05-19 12:30 ` [PATCH 2/8] perf sched: Remove nr_state_machine_bugs in perf latency Jiri Olsa
2014-05-19 12:30 ` [PATCH 3/8] perf sched: Cleanup, remove unused variables in map_switch_event() Jiri Olsa
2014-05-19 12:30 ` [PATCH 4/8] perf session: Fix possible null pointer dereference in session.c Jiri Olsa
2014-05-19 12:30 ` [PATCH 5/8] perf tools: Consolidate types.h for ARM and ARM64 Jiri Olsa
2014-05-19 12:30 ` [PATCH 6/8] perf tests: Introduce perf_regs_load function on ARM Jiri Olsa
2014-05-19 12:30 ` [PATCH 7/8] perf tests: Add dwarf unwind test " Jiri Olsa
2014-05-19 12:30 ` [PATCH 8/8] perf tools: Add libdw DWARF post unwind support for ARM Jiri Olsa
2014-05-20 6:37 ` [GIT PULL 0/8] perf/core improvements and 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).