perf/core improvements and fixes
Subsystems (2)
Jiri Olsa
reviewerhi 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)
----------------------------------------------------------------
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
Jiri Olsa
reviewerPATCH 1/8 perf tools: Remove usage of trace_sched_wakeup(.success)
From: Peter Zijlstra <[email protected]>
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.
--- tools/perf/builtin-sched.c | 7 +------ tools/perf/tests/evsel-tp-sched.c | 3 --- 2 files changed, 1 insertion(+), 9 deletions(-)
tools/perf/builtin-sched.c +1 -6
@@ -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) {
tools/perf/tests/evsel-tp-sched.c +0 -3
@@ -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 ;
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 2/8 perf sched: Remove nr_state_machine_bugs in perf latency
In reply to Jiri OlsaFrom: Dongsheng Yang <[email protected]>
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.
--- tools/perf/builtin-sched.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
tools/perf/builtin-sched.c +8 -11
@@ -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,
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 3/8 perf sched: Cleanup, remove unused variables in map_switch_event()
In reply to Jiri OlsaFrom: Dongsheng Yang <[email protected]>
In map_switch_event(), we don't care the previous process currently, this patch remove the infomation we get but not used.
--- tools/perf/builtin-sched.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tools/perf/builtin-sched.c +2 -4
@@ -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;
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 4/8 perf session: Fix possible null pointer dereference in session.c
In reply to Jiri OlsaFrom: Masanari Iida <[email protected]>
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.
--- tools/perf/util/session.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/session.c +3 -2
@@ -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 ;
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 5/8 perf tools: Consolidate types.h for ARM and ARM64
In reply to Jiri OlsaFrom: Jean Pihet <[email protected]>
Prevents a build breakage since commit d944c4eebcf4c0d5e5d9728fec110cbf0047ad7f 'tools: Consolidate types.h'
--- 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(-)
tools/perf/arch/arm/include/perf_regs.h +1 -1
@@ -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)
tools/perf/arch/arm64/include/perf_regs.h +1 -1
@@ -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)
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 6/8 perf tests: Introduce perf_regs_load function on ARM
In reply to Jiri OlsaFrom: Jean Pihet <[email protected]>
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.
--- 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
tools/perf/arch/arm/Makefile +1 -0
@@ -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
tools/perf/arch/arm/include/perf_regs.h +2 -0
@@ -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
tools/perf/arch/arm/tests/regs_load.S new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 7/8 perf tests: Add dwarf unwind test on ARM
In reply to Jiri OlsaFrom: Jean Pihet <[email protected]>
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.
--- 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
tools/perf/Makefile.perf +1 -1
@@ -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
tools/perf/arch/arm/Makefile +1 -0
@@ -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
tools/perf/arch/arm/include/perf_regs.h +3 -0
@@ -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
tools/perf/arch/arm/tests/dwarf-unwind.c new file +60 -0
60 lines not on this page · raw message
tools/perf/config/Makefile +2 -2
@@ -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
tools/perf/tests/builtin-test.c +1 -1
@@ -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",
tools/perf/tests/tests.h +1 -1
@@ -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 ;
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 8/8 perf tools: Add libdw DWARF post unwind support for ARM
In reply to Jiri OlsaFrom: Jean Pihet <[email protected]>
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.
--- 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
tools/perf/arch/arm/Makefile +5 -0
@@ -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
tools/perf/arch/arm/util/unwind-libdw.c new file +36 -0
@@ -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); +}
Signature · 1 line
1.8.3.1
Quoted 63 lines · Jiri Olsa
hi Ingo,
please consider pullingthanks,
jirkaThe following changes since commit
26f273802b6ed28e059f4359bc7711dffceda022:Merge tag 'perf-core-for-mingo' of
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perfinto 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.gittags/perf-core-for-mingofor 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.hfor 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_bugsin perf latency (Dongsheng Yang). Remove usage of
trace_sched_wakeup(.success)(Peter Zijlstra)Signed-off-by Jiri Olsa <[email protected]>----------------------------------------------------------------
Dongsheng Yang (2):
perf sched: Removenr_state_machine_bugsin perf latency perf sched: Cleanup, remove unused variables inmap_switch_event()Jean Pihet (4):
perf tools: Consolidatetypes.hfor ARM and ARM64 perf tests: Introduceperf_regs_loadfunction on ARM perf tests: Add dwarf unwind test on ARM
perf tools: Add libdw DWARF post unwind support for ARMMasanari Iida (1):
perf session: Fix possible null pointer dereference insession.cPeter Zijlstra (1):
perf tools: Remove usage oftrace_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 +--
Quoted 8 lines
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