perf fixes
Subsystems (8)
Linus,
Please pull the latest perf-fixes-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git perf-fixes-for-linus
Now that i look at the combo diff, it seems uncomfortably big to me :-/ A good chunk of that is due to three categories of fixes:
- the hotplug cpu notifier fixes (kernel side)
- the cpumap fix for hotplugged cpu enumeration (tools side)
- the multi-event displaying fixes for perf report (tools side)
In hindsight, i could/should have pushed the last one to .35 and we could have saved ~200 lines of diffs. If you think it's not acceptable i'll rebase these bits and provide a more compact tree. (The rest of the cycle should be pretty quiet, we dont have any other pending regressions at the moment.)
Thanks,
Ingo
------------------>
Arnaldo Carvalho de Melo (4):
perf tools: Don't trow away old map slices not overlapped by new maps perf probe: Add missing variable initialization
perf report: Print the map table just after samples for which no map was found perf record: Don't try to find buildids in a zero sized file
Eric B Munson (5):
perf record: Add ID and to recorded event data when recording multiple events perf session: Change add_hist_entry to take the tree root instead of session perf session: Add storage for seperating event types in report
perf session: Change perf_session post processing functions to take histogram tree perf report: Add multiple event support
Frederic Weisbecker (5):
lockdep: Move lock events under lockdep recursion protection perf/x86-64: Use frame pointer to walk on irq and process stacks
perf: Introduce new perf_fetch_caller_regs() for hot regs snapshot
perf: Take a hot regs snapshot for trace events
perf: Drop the obsolete profile naming for trace events
John Kacur (1):
perf: Make the install relative to DESTDIR if specified
Masami Hiramatsu (1):
kprobes: Calculate the index correctly when freeing the out-of-line execution slot
Paul Mackerras (2):
perf_event: Fix oops triggered by cpu offline/online perf tools: Fix sparse CPU numbering related bugs
Peter Zijlstra (15):
perf: Rework and fix the arch CPU-hotplug hooks
perf: Optimize perf_disable
perf, x86, Do not user perf_disable from NMI context
perf, x86: Remove superfluous arguments to x86_perf_event_set_period() perf, x86: Remove superfluous arguments to x86_perf_event_update() perf, x86: Change x86_pmu.{enable,disable} calling convention perf, x86: Use unlocked bitops
perf, x86: Fix x86_pmu_start
perf, x86: Avoid double disable on throttle vs ioctl(PERF_IOC_DISABLE) perf, x86: Properly account n_added
perf, x86: Fix double disable calls
perf, x86: Fix double enable calls
perf: Provide better condition for event rotation
perf, ppc: Fix compile error due to new cpu notifiers perf, x86: Fix hw_perf_enable() event assignment
Xiao Guangrong (1):
perf: export perf_trace_regs and perf_arch_fetch_caller_regs
arch/powerpc/kernel/perf_event.c | 21 ++-
arch/sh/kernel/perf_event.c | 20 ++-
arch/x86/kernel/cpu/perf_event.c | 182 +++++++++++---------
arch/x86/kernel/cpu/perf_event_amd.c | 62 +++----
arch/x86/kernel/cpu/perf_event_intel.c | 57 +++---
arch/x86/kernel/cpu/perf_event_p6.c | 10 +-
arch/x86/kernel/dumpstack.h | 15 ++
arch/x86/kernel/dumpstack_64.c | 4 +-
include/linux/ftrace_event.h | 23 ++-
include/linux/perf_event.h | 59 ++++++-
include/linux/syscalls.h | 24 ++--
include/trace/ftrace.h | 44 +++--
include/trace/syscall.h | 8 +-
kernel/kprobes.c | 3 +-
kernel/lockdep.c | 9 +-
kernel/perf_event.c | 82 ++++-----
kernel/trace/Makefile | 2 +-
.../{trace_event_profile.c => trace_event_perf.c} | 48 +++---
kernel/trace/trace_events.c | 2 +-
kernel/trace/trace_kprobe.c | 29 ++--
kernel/trace/trace_syscalls.c | 72 ++++----
tools/perf/Documentation/Makefile | 4 +-
tools/perf/Makefile | 6 +-
tools/perf/builtin-annotate.c | 6 +-
tools/perf/builtin-diff.c | 13 +-
tools/perf/builtin-record.c | 13 +-
tools/perf/builtin-report.c | 112 +++++++++++--
tools/perf/builtin-stat.c | 10 +-
tools/perf/builtin-top.c | 9 +-
tools/perf/util/cpumap.c | 59 +++++++
tools/perf/util/cpumap.h | 7 +
tools/perf/util/event.h | 9 +
tools/perf/util/hist.c | 50 +++---
tools/perf/util/hist.h | 12 +-
tools/perf/util/probe-finder.c | 2 +-
tools/perf/util/session.c | 1 +
tools/perf/util/session.h | 1 +
tools/perf/util/thread.c | 41 ++++-
tools/perf/util/thread.h | 3 +
39 files changed, 736 insertions(+), 398 deletions(-)
rename kernel/trace/{trace_event_profile.c => trace_event_perf.c} (69%)
create mode 100644 tools/perf/util/cpumap.c
create mode 100644 tools/perf/util/cpumap.harch/powerpc/kernel/perf_event.c +20 -1
@@ -1287,7 +1287,7 @@ static void perf_event_interrupt(struct pt_regs *regs)irq_exit (); } -void hw_perf_event_setup (int cpu) +static void power_pmu_setup (int cpu) {struct cpu_hw_events *cpuhw = &per_cpu (cpu_hw_events, cpu);
@@ -1297,6 +1297,23 @@ void hw_perf_event_setup(int cpu) cpuhw->mmcr[0 ] =MMCR0_FC ; } +static int __cpuinit +power_pmu_notifier (struct notifier_block *self,unsigned long action,void *hcpu) +{ +unsigned int cpu = (long )hcpu; + +switch (action & ~CPU_TASKS_FROZEN ) { +case CPU_UP_PREPARE : +power_pmu_setup (cpu); +break ; + +default : +break ; + } + +return NOTIFY_OK ; +} +int register_power_pmu (struct power_pmu *pmu) {if (ppmu)
@@ -1314,5 +1331,7 @@ int register_power_pmu(struct power_pmu *pmu) freeze_events_kernel =MMCR0_FCHV ;#endif /* CONFIG_PPC64 */ +perf_cpu_notifier (power_pmu_notifier); +return 0 ; }
arch/sh/kernel/perf_event.c +19 -1
@@ -275,13 +275,30 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)return &pmu; } -void hw_perf_event_setup (int cpu) +static void sh_pmu_setup (int cpu) {struct cpu_hw_events *cpuhw = &per_cpu (cpu_hw_events, cpu);memset (cpuhw,0 ,sizeof (struct cpu_hw_events )); } +static int __cpuinit +sh_pmu_notifier (struct notifier_block *self,unsigned long action,void *hcpu) +{ +unsigned int cpu = (long )hcpu; + +switch (action & ~CPU_TASKS_FROZEN ) { +case CPU_UP_PREPARE : +sh_pmu_setup (cpu); +break ; + +default : +break ; + } + +return NOTIFY_OK ; +} +void hw_perf_enable (void ) {if (!sh_pmu_initialized ())
@@ -308,5 +325,6 @@ int register_sh_pmu(struct sh_pmu *pmu)WARN_ON (pmu->num_events >MAX_HWEVENTS ); +perf_cpu_notifier (sh_pmu_notifier);return 0 ; }
arch/x86/kernel/cpu/perf_event.c +98 -84
368 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_amd.c +26 -36
90 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_intel.c +28 -29
145 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_p6.c +6 -4
@@ -77,27 +77,29 @@ static void p6_pmu_enable_all(void) }static inline void -p6_pmu_disable_event (struct hw_perf_event *hwc,int idx) +p6_pmu_disable_event (struct perf_event *event) {struct cpu_hw_events *cpuc = &__get_cpu_var (cpu_hw_events); +struct hw_perf_event *hwc = &event->hw;u64 val =P6_NOP_EVENT ;if (cpuc->enabled) val |=ARCH_PERFMON_EVENTSEL_ENABLE ; - (void )checking_wrmsrl (hwc->config_base + idx, val); + (void )checking_wrmsrl (hwc->config_base + hwc->idx, val); } -static void p6_pmu_enable_event (struct hw_perf_event *hwc,int idx) +static void p6_pmu_enable_event (struct perf_event *event) {struct cpu_hw_events *cpuc = &__get_cpu_var (cpu_hw_events); +struct hw_perf_event *hwc = &event->hw;u64 val; val = hwc->config;if (cpuc->enabled) val |=ARCH_PERFMON_EVENTSEL_ENABLE ; - (void )checking_wrmsrl (hwc->config_base + idx, val); + (void )checking_wrmsrl (hwc->config_base + hwc->idx, val); }static __initconst struct x86_pmu p6_pmu = {
arch/x86/kernel/dumpstack.h +15 -0
@@ -29,4 +29,19 @@ struct stack_frame {struct stack_frame *next_frame; unsigned long return_address; }; + +static inline unsigned long rewind_frame_pointer (int n) +{ +struct stack_frame *frame; + +get_bp (frame); + +#ifdef CONFIG_FRAME_POINTER +while (n--) + frame = frame->next_frame;#endif + +return (unsigned long )frame; +} + +#endif /* DUMPSTACK_H */
arch/x86/kernel/dumpstack_64.c +2 -2
@@ -208,7 +208,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,if (in_irq_stack (stack, irq_stack, irq_stack_end)) {if (ops->stack (data,"IRQ" ) <0 )break ; - bp =print_context_stack (tinfo, stack, bp, + bp = ops->walk_stack (tinfo, stack, bp, ops, data, irq_stack_end, &graph);/* * We link to the next stack (which would be
@@ -229,7 +229,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,/* * This handles the process stack: */ - bp =print_context_stack (tinfo, stack, bp, ops, data,NULL , &graph); + bp = ops->walk_stack (tinfo, stack, bp, ops, data,NULL , &graph);put_cpu (); }EXPORT_SYMBOL (dump_trace);
include/linux/ftrace_event.h +13 -10
@@ -131,12 +131,12 @@ struct ftrace_event_call {void *mod;void *data; -int profile_count; -int (*profile_enable)(struct ftrace_event_call *); -void (*profile_disable)(struct ftrace_event_call *); +int perf_refcount; +int (*perf_event_enable)(struct ftrace_event_call *); +void (*perf_event_disable)(struct ftrace_event_call *); }; -#define FTRACE_MAX_PROFILE_SIZE 2048 +#define PERF_MAX_TRACE_SIZE 2048#define MAX_FILTER_PRED 32#define MAX_FILTER_STR_VAL 256/* Should handle KSYM_SYMBOL_LEN */
@@ -187,22 +187,25 @@ do { \#ifdef CONFIG_PERF_EVENTS struct perf_event ; -extern int ftrace_profile_enable (int event_id); -extern void ftrace_profile_disable (int event_id); + +DECLARE_PER_CPU(struct pt_regs, perf_trace_regs); + +extern int perf_trace_enable (int event_id); +extern void perf_trace_disable (int event_id);extern int ftrace_profile_set_filter (struct perf_event *event,int event_id,char *filter_str);extern void ftrace_profile_free_filter (struct perf_event *event);extern void * -ftrace_perf_buf_prepare (int size,unsigned short type,int *rctxp, +perf_trace_buf_prepare (int size,unsigned short type,int *rctxp,unsigned long *irq_flags);static inline void -ftrace_perf_buf_submit (void *raw_data,int size,int rctx,u64 addr, -u64 count,unsigned long irq_flags) +perf_trace_buf_submit (void *raw_data,int size,int rctx,u64 addr, +u64 count,unsigned long irq_flags,struct pt_regs *regs) {struct trace_entry *entry = raw_data; -perf_tp_event (entry->type, addr, count, raw_data, size); +perf_tp_event (entry->type, addr, count, raw_data, size, regs);perf_swevent_put_recursion_context (rctx);local_irq_restore (irq_flags); }
include/linux/perf_event.h +58 -1
82 lines not on this page · raw message
include/linux/syscalls.h +12 -12
@@ -101,18 +101,18 @@ struct perf_event_attr;#ifdef CONFIG_PERF_EVENTS -#define TRACE_SYS_ENTER_PROFILE_INIT (sname) \ - .profile_enable = prof_sysenter_enable, \ - .profile_disable = prof_sysenter_disable, +#define TRACE_SYS_ENTER_PERF_INIT (sname) \ + .perf_event_enable = perf_sysenter_enable, \ + .perf_event_disable = perf_sysenter_disable, -#define TRACE_SYS_EXIT_PROFILE_INIT (sname) \ - .profile_enable = prof_sysexit_enable, \ - .profile_disable = prof_sysexit_disable, +#define TRACE_SYS_EXIT_PERF_INIT (sname) \ + .perf_event_enable = perf_sysexit_enable, \ + .perf_event_disable = perf_sysexit_disable,#else -#define TRACE_SYS_ENTER_PROFILE (sname) -#define TRACE_SYS_ENTER_PROFILE_INIT (sname) -#define TRACE_SYS_EXIT_PROFILE (sname) -#define TRACE_SYS_EXIT_PROFILE_INIT (sname) +#define TRACE_SYS_ENTER_PERF (sname) +#define TRACE_SYS_ENTER_PERF_INIT (sname) +#define TRACE_SYS_EXIT_PERF (sname) +#define TRACE_SYS_EXIT_PERF_INIT (sname)#endif /* CONFIG_PERF_EVENTS */ #ifdef CONFIG_FTRACE_SYSCALLS
@@ -149,7 +149,7 @@ struct perf_event_attr; .regfunc = reg_event_syscall_enter, \ .unregfunc = unreg_event_syscall_enter, \ .data = (void *)&__syscall_meta_##sname,\ - TRACE_SYS_ENTER_PROFILE_INIT(sname) \ + TRACE_SYS_ENTER_PERF_INIT(sname) \ }#define SYSCALL_TRACE_EXIT_EVENT (sname) \
@@ -171,7 +171,7 @@ struct perf_event_attr; .regfunc = reg_event_syscall_exit, \ .unregfunc = unreg_event_syscall_exit, \ .data = (void *)&__syscall_meta_##sname,\ - TRACE_SYS_EXIT_PROFILE_INIT(sname) \ + TRACE_SYS_EXIT_PERF_INIT(sname) \ }#define SYSCALL_METADATA (sname, nb) \
include/trace/ftrace.h +24 -20
119 lines not on this page · raw message
include/trace/syscall.h +4 -4
@@ -47,10 +47,10 @@ enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags);#endif #ifdef CONFIG_PERF_EVENTS -int prof_sysenter_enable (struct ftrace_event_call *call); -void prof_sysenter_disable (struct ftrace_event_call *call); -int prof_sysexit_enable (struct ftrace_event_call *call); -void prof_sysexit_disable (struct ftrace_event_call *call); +int perf_sysenter_enable (struct ftrace_event_call *call); +void perf_sysenter_disable (struct ftrace_event_call *call); +int perf_sysexit_enable (struct ftrace_event_call *call); +void perf_sysexit_disable (struct ftrace_event_call *call);#endif #endif /* _TRACE_SYSCALL_H */
kernel/kprobes.c +2 -1
@@ -259,7 +259,8 @@ static void __kprobes __free_insn_slot(struct kprobe_insn_cache *c,struct kprobe_insn_page *kip;list_for_each_entry (kip, &c->pages, list) { -long idx = ((long )slot - (long )kip->insns) / c->insn_size; +long idx = ((long )slot - (long )kip->insns) / + (c->insn_size *sizeof (kprobe_opcode_t));if (idx >=0 && idx <slots_per_page (c)) {WARN_ON (kip->slot_used[idx] !=SLOT_USED );if (dirty) {
kernel/lockdep.c +3 -6
@@ -3211,8 +3211,6 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass, {unsigned long flags; -trace_lock_acquire (lock, subclass, trylock, read, check, nest_lock, ip); -if (unlikely (current->lockdep_recursion))return ;
@@ -3220,6 +3218,7 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,check_flags (flags); current->lockdep_recursion =1 ; +trace_lock_acquire (lock, subclass, trylock, read, check, nest_lock, ip);__lock_acquire (lock, subclass, trylock, read, check,irqs_disabled_flags (flags), nest_lock, ip,0 ); current->lockdep_recursion =0 ;
@@ -3232,14 +3231,13 @@ void lock_release(struct lockdep_map *lock, int nested, {unsigned long flags; -trace_lock_release (lock, nested, ip); -if (unlikely (current->lockdep_recursion))return ;raw_local_irq_save (flags);check_flags (flags); current->lockdep_recursion =1 ; +trace_lock_release (lock, nested, ip);__lock_release (lock, nested, ip); current->lockdep_recursion =0 ;raw_local_irq_restore (flags);
@@ -3413,8 +3411,6 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip) {unsigned long flags; -trace_lock_contended (lock, ip); -if (unlikely (!lock_stat))return ;
@@ -3424,6 +3420,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)raw_local_irq_save (flags);check_flags (flags); current->lockdep_recursion =1 ; +trace_lock_contended (lock, ip);__lock_contended (lock, ip); current->lockdep_recursion =0 ;raw_local_irq_restore (flags);
kernel/perf_event.c +39 -43
212 lines not on this page · raw message
kernel/trace/Makefile +1 -1
@@ -52,7 +52,7 @@ obj-$(CONFIG_EVENT_TRACING) += trace_events.o obj-$(CONFIG_EVENT_TRACING) += trace_export.o obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o ifeq ($(CONFIG_PERF_EVENTS),y) -obj-$(CONFIG_EVENT_TRACING) += trace_event_profile.o +obj-$(CONFIG_EVENT_TRACING) += trace_event_perf.o endif obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o
kernel/trace/trace_event_perf.c renamed from kernel/trace/trace_event_profile.c +25 -23
134 lines not on this page · raw message
kernel/trace/trace_events.c +1 -1
@@ -938,7 +938,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,trace_create_file ("enable" ,0644 , call->dir, call, enable); -if (call->id && call->profile_enable) +if (call->id && call->perf_event_enable)trace_create_file ("id" ,0444 , call->dir, call, id);
kernel/trace/trace_kprobe.c +15 -14
@@ -1214,7 +1214,7 @@ static int set_print_fmt(struct trace_probe *tp)#ifdef CONFIG_PERF_EVENTS /* Kprobe profile handler */ -static __kprobes void kprobe_profile_func (struct kprobe *kp, +static __kprobes void kprobe_perf_func (struct kprobe *kp,struct pt_regs *regs) { struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
@@ -1227,11 +1227,11 @@ static __kprobes void kprobe_profile_func(struct kprobe *kp, __size =SIZEOF_KPROBE_TRACE_ENTRY (tp->nr_args); size =ALIGN (__size +sizeof (u32),sizeof (u64)); size -=sizeof (u32); -if (WARN_ONCE (size >FTRACE_MAX_PROFILE_SIZE , +if (WARN_ONCE (size >PERF_MAX_TRACE_SIZE ,"profile buffer not large enough" ))return ; - entry =ftrace_perf_buf_prepare (size, call->id, &rctx, &irq_flags); + entry =perf_trace_buf_prepare (size, call->id, &rctx, &irq_flags);if (!entry)return ;
@@ -1240,11 +1240,11 @@ static __kprobes void kprobe_profile_func(struct kprobe *kp,for (i =0 ; i < tp->nr_args; i++) entry->args[i] =call_fetch (&tp->args[i].fetch, regs); -ftrace_perf_buf_submit (entry, size, rctx, entry->ip,1 , irq_flags); +perf_trace_buf_submit (entry, size, rctx, entry->ip,1 , irq_flags, regs); }/* Kretprobe profile handler */ -static __kprobes void kretprobe_profile_func (struct kretprobe_instance *ri, +static __kprobes void kretprobe_perf_func (struct kretprobe_instance *ri,struct pt_regs *regs) { struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
@@ -1257,11 +1257,11 @@ static __kprobes void kretprobe_profile_func(struct kretprobe_instance *ri, __size =SIZEOF_KRETPROBE_TRACE_ENTRY (tp->nr_args); size =ALIGN (__size +sizeof (u32),sizeof (u64)); size -=sizeof (u32); -if (WARN_ONCE (size >FTRACE_MAX_PROFILE_SIZE , +if (WARN_ONCE (size >PERF_MAX_TRACE_SIZE ,"profile buffer not large enough" ))return ; - entry =ftrace_perf_buf_prepare (size, call->id, &rctx, &irq_flags); + entry =perf_trace_buf_prepare (size, call->id, &rctx, &irq_flags);if (!entry)return ;
@@ -1271,10 +1271,11 @@ static __kprobes void kretprobe_profile_func(struct kretprobe_instance *ri,for (i =0 ; i < tp->nr_args; i++) entry->args[i] =call_fetch (&tp->args[i].fetch, regs); -ftrace_perf_buf_submit (entry, size, rctx, entry->ret_ip,1 , irq_flags); +perf_trace_buf_submit (entry, size, rctx, entry->ret_ip,1 , + irq_flags, regs); } -static int probe_profile_enable (struct ftrace_event_call *call) +static int probe_perf_enable (struct ftrace_event_call *call) {struct trace_probe *tp = (struct trace_probe *)call->data;
@@ -1286,7 +1287,7 @@ static int probe_profile_enable(struct ftrace_event_call *call)return enable_kprobe (&tp->rp.kp); } -static void probe_profile_disable (struct ftrace_event_call *call) +static void probe_perf_disable (struct ftrace_event_call *call) {struct trace_probe *tp = (struct trace_probe *)call->data;
@@ -1311,7 +1312,7 @@ int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs)kprobe_trace_func (kp, regs);#ifdef CONFIG_PERF_EVENTS if (tp->flags &TP_FLAG_PROFILE ) -kprobe_profile_func (kp, regs); +kprobe_perf_func (kp, regs);#endif return 0 ;/* We don't tweek kernel, so just return 0 */ }
@@ -1325,7 +1326,7 @@ int kretprobe_dispatcher(struct kretprobe_instance *ri, struct pt_regs *regs)kretprobe_trace_func (ri, regs);#ifdef CONFIG_PERF_EVENTS if (tp->flags &TP_FLAG_PROFILE ) -kretprobe_profile_func (ri, regs); +kretprobe_perf_func (ri, regs);#endif return 0 ;/* We don't tweek kernel, so just return 0 */ }
@@ -1358,8 +1359,8 @@ static int register_probe_event(struct trace_probe *tp) call->unregfunc = probe_event_disable;#ifdef CONFIG_PERF_EVENTS - call->profile_enable = probe_profile_enable; - call->profile_disable = probe_profile_disable; + call->perf_event_enable = probe_perf_enable; + call->perf_event_disable = probe_perf_disable;#endif call->data = tp; ret =trace_add_event_call (call);
kernel/trace/trace_syscalls.c +36 -36
168 lines not on this page · raw message
tools/perf/Documentation/Makefile +3 -1
@@ -24,7 +24,10 @@ DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT)) DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) +# Make the path relative to DESTDIR, not prefix +ifndef DESTDIR prefix?=$(HOME) +endif bindir?=$(prefix)/bin htmldir?=$(prefix)/share/doc/perf-doc pdfdir?=$(prefix)/share/doc/perf-doc
@@ -32,7 +35,6 @@ mandir?=$(prefix)/share/man man1dir=$(mandir)/man1 man5dir=$(mandir)/man5 man7dir=$(mandir)/man7 -# DESTDIR= ASCIIDOC=asciidoc ASCIIDOC_EXTRA = --unsafe
tools/perf/Makefile +5 -1
@@ -216,7 +216,10 @@ STRIP ?= strip # runtime figures out where they are based on the path to the executable. # This can help installing the suite in a relocatable way. +# Make the path relative to DESTDIR, not to prefix +ifndef DESTDIR prefix = $(HOME) +endif bindir_relative = bin bindir = $(prefix)/$(bindir_relative) mandir = share/man
@@ -233,7 +236,6 @@ sysconfdir = $(prefix)/etc ETC_PERFCONFIG = etc/perfconfig endif lib = lib -# DESTDIR= export prefix bindir sharedir sysconfdir
@@ -387,6 +389,7 @@ LIB_H += util/thread.h LIB_H += util/trace-event.h LIB_H += util/probe-finder.h LIB_H += util/probe-event.h +LIB_H += util/cpumap.h LIB_OBJS += util/abspath.o LIB_OBJS += util/alias.o
@@ -433,6 +436,7 @@ LIB_OBJS += util/sort.o LIB_OBJS += util/hist.o LIB_OBJS += util/probe-event.o LIB_OBJS += util/util.o +LIB_OBJS += util/cpumap.o BUILTIN_OBJS += builtin-annotate.o
tools/perf/builtin-annotate.c +3 -3
@@ -116,7 +116,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,return 0 ; } - he =__perf_session__add_hist_entry (self, al,NULL , count, &hit); + he =__perf_session__add_hist_entry (&self->hists, al,NULL , count, &hit);if (he ==NULL )return -ENOMEM ;
@@ -564,8 +564,8 @@ static int __cmd_annotate(void)if (verbose >2 )dsos__fprintf (stdout); -perf_session__collapse_resort (session); -perf_session__output_resort (session, session->event_total[0 ]); +perf_session__collapse_resort (&session->hists); +perf_session__output_resort (&session->hists, session->event_total[0 ]);perf_session__find_annotations (session); out_delete:perf_session__delete (session);
tools/perf/builtin-diff.c +8 -5
@@ -26,7 +26,8 @@ static int perf_session__add_hist_entry(struct perf_session *self, struct addr_location *al, u64 count) { bool hit; -struct hist_entry *he =__perf_session__add_hist_entry (self, al,NULL , +struct hist_entry *he =__perf_session__add_hist_entry (&self->hists, + al,NULL , count, &hit);if (he ==NULL )return -ENOMEM ;
@@ -114,7 +115,7 @@ static void perf_session__resort_hist_entries(struct perf_session *self)static void perf_session__set_hist_entries_positions (struct perf_session *self) { -perf_session__output_resort (self, self->events_stats.total); +perf_session__output_resort (&self->hists, self->events_stats.total);perf_session__resort_hist_entries (self); }
@@ -166,13 +167,15 @@ static int __cmd_diff(void) goto out_delete; } -perf_session__output_resort (session[1 ], session[1 ]->events_stats.total); +perf_session__output_resort (&session[1 ]->hists, + session[1 ]->events_stats.total);if (show_displacement)perf_session__set_hist_entries_positions (session[0 ]);perf_session__match_hists (session[0 ], session[1 ]); -perf_session__fprintf_hists (session[1 ], session[0 ], - show_displacement, stdout); +perf_session__fprintf_hists (&session[1 ]->hists, session[0 ], + show_displacement, stdout, + session[1 ]->events_stats.total); out_delete:for (i =0 ; i <2 ; ++i)perf_session__delete (session[i]);
tools/perf/builtin-record.c +9 -4
@@ -22,6 +22,7 @@#include "util/debug.h" #include "util/session.h" #include "util/symbol.h" +#include "util/cpumap.h" #include <unistd.h> #include <sched.h>
@@ -244,6 +245,9 @@ static void create_counter(int counter, int cpu, pid_t pid) attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID ; +if (nr_counters >1 ) + attr->sample_type |=PERF_SAMPLE_ID ; +if (freq) { attr->sample_type |=PERF_SAMPLE_PERIOD ; attr->freq =1 ;
@@ -391,6 +395,9 @@ static int process_buildids(void) {u64 size =lseek (output,0 ,SEEK_CUR ); +if (size ==0 ) +return 0 ; + session->fd = output; return __perf_session__process_events(session, post_processing_offset, size - post_processing_offset,
@@ -418,9 +425,6 @@ static int __cmd_record(int argc, const char **argv)char buf; page_size =sysconf (_SC_PAGE_SIZE); - nr_cpus =sysconf (_SC_NPROCESSORS_ONLN); -assert (nr_cpus <=MAX_NR_CPUS ); -assert (nr_cpus >=0 );atexit (sig_atexit);signal (SIGCHLD , sig_handler);
@@ -544,8 +548,9 @@ static int __cmd_record(int argc, const char **argv)if ((!system_wide && !inherit) || profile_cpu !=-1 ) {open_counters (profile_cpu, target_pid); }else { + nr_cpus =read_cpu_map ();for (i =0 ; i < nr_cpus; i++) -open_counters (i, target_pid); +open_counters (cpumap[i], target_pid); }if (file_new) {
tools/perf/builtin-report.c +100 -12
166 lines not on this page · raw message
tools/perf/builtin-stat.c +6 -4
@@ -45,6 +45,7 @@#include "util/event.h" #include "util/debug.h" #include "util/header.h" +#include "util/cpumap.h" #include <sys/prctl.h> #include <math.h>
@@ -151,7 +152,7 @@ static void create_perf_stat_counter(int counter, int pid)unsigned int cpu;for (cpu =0 ; cpu < nr_cpus; cpu++) { - fd[cpu][counter] =sys_perf_event_open (attr,-1 , cpu,-1 ,0 ); + fd[cpu][counter] =sys_perf_event_open (attr,-1 , cpumap[cpu],-1 ,0 );if (fd[cpu][counter] <0 && verbose)fprintf (stderr,ERR_PERF_OPEN , counter, fd[cpu][counter],strerror (errno));
@@ -519,9 +520,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) nr_counters =ARRAY_SIZE (default_attrs); } - nr_cpus =sysconf (_SC_NPROCESSORS_ONLN); -assert (nr_cpus <=MAX_NR_CPUS ); -assert ((int )nr_cpus >=0 ); +if (system_wide) + nr_cpus =read_cpu_map (); +else + nr_cpus =1 ;/* * We dont want to block the signals - that would cause
tools/perf/builtin-top.c +4 -5
@@ -28,6 +28,7 @@#include <linux/rbtree.h> #include "util/parse-options.h" #include "util/parse-events.h" +#include "util/cpumap.h" #include "util/debug.h"
@@ -1123,7 +1124,7 @@ static void start_counter(int i, int counter) cpu = profile_cpu;if (target_pid ==-1 && profile_cpu ==-1 ) - cpu = i; + cpu = cpumap[i]; attr = attrs + counter;
@@ -1347,12 +1348,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) attrs[counter].sample_period = default_interval; } - nr_cpus =sysconf (_SC_NPROCESSORS_ONLN); -assert (nr_cpus <=MAX_NR_CPUS ); -assert (nr_cpus >=0 ); -if (target_pid !=-1 || profile_cpu !=-1 ) nr_cpus =1 ; +else + nr_cpus =read_cpu_map ();get_term_dimensions (&winsize);if (print_entries ==0 ) {
tools/perf/util/cpumap.c new file +59 -0
59 lines not on this page · raw message
tools/perf/util/cpumap.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __PERF_CPUMAP_H +#define __PERF_CPUMAP_H + +extern int read_cpu_map (void ); +extern int cpumap[]; + +#endif /* __PERF_CPUMAP_H */
tools/perf/util/event.h +9 -0
@@ -99,6 +99,15 @@ struct events_stats {u64 lost; }; +struct event_stat_id { +struct rb_node rb_node; +struct rb_root hists; +struct events_stats stats; +u64 config; +u64 event_stream; +u32 type; +}; +void event__print_totals (void );struct perf_session ;
tools/perf/util/hist.c +28 -22
152 lines not on this page · raw message
tools/perf/util/hist.h +7 -5
@@ -10,8 +10,9 @@ struct perf_session;struct hist_entry ;struct addr_location ;struct symbol ; +struct rb_root ; -struct hist_entry *__perf_session__add_hist_entry (struct perf_session *self, +struct hist_entry *__perf_session__add_hist_entry (struct rb_root *hists,struct addr_location *al,struct symbol *parent,u64 count,bool *hit);
@@ -19,9 +20,10 @@ extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);extern int64_t hist_entry__collapse (struct hist_entry *,struct hist_entry *);void hist_entry__free (struct hist_entry *); -void perf_session__output_resort (struct perf_session *self,u64 total_samples); -void perf_session__collapse_resort (struct perf_session *self); -size_t perf_session__fprintf_hists (struct perf_session *self, +void perf_session__output_resort (struct rb_root *hists,u64 total_samples); +void perf_session__collapse_resort (struct rb_root *hists); +size_t perf_session__fprintf_hists (struct rb_root *hists,struct perf_session *pair, -bool show_displacement,FILE *fp); +bool show_displacement,FILE *fp, +u64 session_total);#endif /* __PERF_HIST_H */
tools/perf/util/probe-finder.c +1 -1
@@ -169,7 +169,7 @@ static const char *cu_find_realpath(Dwarf_Die *cu_die, const char *fname) {Dwarf_Files *files;size_t nfiles, i; -const char *src; +const char *src =NULL ;int ret;if (!fname)
tools/perf/util/session.c +1 -0
@@ -70,6 +70,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forcmemcpy (self->filename, filename, len); self->threads =RB_ROOT ; + self->stats_by_id =RB_ROOT ; self->last_match =NULL ; self->mmap_window =32 ; self->cwd =NULL ;
tools/perf/util/session.h +1 -0
@@ -20,6 +20,7 @@ struct perf_session {struct thread *last_match;struct map *vmlinux_maps[MAP__NR_TYPES ];struct events_stats events_stats; +struct rb_root stats_by_id;unsigned long event_total[PERF_RECORD_MAX ];unsigned long unknown_events;struct rb_root hists;
tools/perf/util/thread.c +35 -6
72 lines not on this page · raw message
tools/perf/util/thread.h +3 -0
@@ -10,6 +10,9 @@ struct map_groups {struct list_head removed_maps[MAP__NR_TYPES ]; }; +size_t __map_groups__fprintf_maps (struct map_groups *self, +enum map_type type,FILE *fp); +struct thread {struct rb_node rb_node;struct map_groups mg;
Quoted 5 lines · Ingo Molnar
Linus,
Please pull the latest perf-fixes-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.gitperf-fixes-for-linus
I've updated the branch with one more fix that Frederic pointed out was missing:
perf: Fix unexported generic perf_arch_fetch_caller_regs
Below is the updated shortlog/diffstat.
Thanks,
Ingo
------------------>
Arnaldo Carvalho de Melo (4):
perf tools: Don't trow away old map slices not overlapped by new maps perf probe: Add missing variable initialization
perf report: Print the map table just after samples for which no map was found perf record: Don't try to find buildids in a zero sized file
Eric B Munson (5):
perf record: Add ID and to recorded event data when recording multiple events perf session: Change add_hist_entry to take the tree root instead of session perf session: Add storage for seperating event types in report
perf session: Change perf_session post processing functions to take histogram tree perf report: Add multiple event support
Frederic Weisbecker (6):
lockdep: Move lock events under lockdep recursion protection perf/x86-64: Use frame pointer to walk on irq and process stacks
perf: Introduce new perf_fetch_caller_regs() for hot regs snapshot
perf: Take a hot regs snapshot for trace events
perf: Drop the obsolete profile naming for trace events
perf: Fix unexported generic perf_arch_fetch_caller_regs
John Kacur (1):
perf: Make the install relative to DESTDIR if specified
Masami Hiramatsu (1):
kprobes: Calculate the index correctly when freeing the out-of-line execution slot
Paul Mackerras (2):
perf_event: Fix oops triggered by cpu offline/online perf tools: Fix sparse CPU numbering related bugs
Peter Zijlstra (15):
perf: Rework and fix the arch CPU-hotplug hooks
perf: Optimize perf_disable
perf, x86, Do not user perf_disable from NMI context
perf, x86: Remove superfluous arguments to x86_perf_event_set_period() perf, x86: Remove superfluous arguments to x86_perf_event_update() perf, x86: Change x86_pmu.{enable,disable} calling convention perf, x86: Use unlocked bitops
perf, x86: Fix x86_pmu_start
perf, x86: Avoid double disable on throttle vs ioctl(PERF_IOC_DISABLE) perf, x86: Properly account n_added
perf, x86: Fix double disable calls
perf, x86: Fix double enable calls
perf: Provide better condition for event rotation
perf, ppc: Fix compile error due to new cpu notifiers perf, x86: Fix hw_perf_enable() event assignment
Xiao Guangrong (1):
perf: export perf_trace_regs and perf_arch_fetch_caller_regs
arch/powerpc/kernel/perf_event.c | 21 ++-
arch/sh/kernel/perf_event.c | 20 ++-
arch/x86/kernel/cpu/perf_event.c | 183 +++++++++++---------
arch/x86/kernel/cpu/perf_event_amd.c | 62 +++----
arch/x86/kernel/cpu/perf_event_intel.c | 57 +++---
arch/x86/kernel/cpu/perf_event_p6.c | 10 +-
arch/x86/kernel/dumpstack.h | 15 ++
arch/x86/kernel/dumpstack_64.c | 4 +-
include/linux/ftrace_event.h | 23 ++-
include/linux/perf_event.h | 59 ++++++-
include/linux/syscalls.h | 24 ++--
include/trace/ftrace.h | 44 +++--
include/trace/syscall.h | 8 +-
kernel/kprobes.c | 3 +-
kernel/lockdep.c | 9 +-
kernel/perf_event.c | 84 +++++-----
kernel/trace/Makefile | 2 +-
.../{trace_event_profile.c => trace_event_perf.c} | 50 +++---
kernel/trace/trace_events.c | 2 +-
kernel/trace/trace_kprobe.c | 29 ++--
kernel/trace/trace_syscalls.c | 72 ++++----
tools/perf/Documentation/Makefile | 4 +-
tools/perf/Makefile | 6 +-
tools/perf/builtin-annotate.c | 6 +-
tools/perf/builtin-diff.c | 13 +-
tools/perf/builtin-record.c | 13 +-
tools/perf/builtin-report.c | 112 +++++++++++--
tools/perf/builtin-stat.c | 10 +-
tools/perf/builtin-top.c | 9 +-
tools/perf/util/cpumap.c | 59 +++++++
tools/perf/util/cpumap.h | 7 +
tools/perf/util/event.h | 9 +
tools/perf/util/hist.c | 50 +++---
tools/perf/util/hist.h | 12 +-
tools/perf/util/probe-finder.c | 2 +-
tools/perf/util/session.c | 1 +
tools/perf/util/session.h | 1 +
tools/perf/util/thread.c | 41 ++++-
tools/perf/util/thread.h | 3 +
39 files changed, 741 insertions(+), 398 deletions(-)
rename kernel/trace/{trace_event_profile.c => trace_event_perf.c} (68%)
create mode 100644 tools/perf/util/cpumap.c
create mode 100644 tools/perf/util/cpumap.harch/powerpc/kernel/perf_event.c +20 -1
@@ -1287,7 +1287,7 @@ static void perf_event_interrupt(struct pt_regs *regs)irq_exit (); } -void hw_perf_event_setup (int cpu) +static void power_pmu_setup (int cpu) {struct cpu_hw_events *cpuhw = &per_cpu (cpu_hw_events, cpu);
@@ -1297,6 +1297,23 @@ void hw_perf_event_setup(int cpu) cpuhw->mmcr[0 ] =MMCR0_FC ; } +static int __cpuinit +power_pmu_notifier (struct notifier_block *self,unsigned long action,void *hcpu) +{ +unsigned int cpu = (long )hcpu; + +switch (action & ~CPU_TASKS_FROZEN ) { +case CPU_UP_PREPARE : +power_pmu_setup (cpu); +break ; + +default : +break ; + } + +return NOTIFY_OK ; +} +int register_power_pmu (struct power_pmu *pmu) {if (ppmu)
@@ -1314,5 +1331,7 @@ int register_power_pmu(struct power_pmu *pmu) freeze_events_kernel =MMCR0_FCHV ;#endif /* CONFIG_PPC64 */ +perf_cpu_notifier (power_pmu_notifier); +return 0 ; }
arch/sh/kernel/perf_event.c +19 -1
@@ -275,13 +275,30 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)return &pmu; } -void hw_perf_event_setup (int cpu) +static void sh_pmu_setup (int cpu) {struct cpu_hw_events *cpuhw = &per_cpu (cpu_hw_events, cpu);memset (cpuhw,0 ,sizeof (struct cpu_hw_events )); } +static int __cpuinit +sh_pmu_notifier (struct notifier_block *self,unsigned long action,void *hcpu) +{ +unsigned int cpu = (long )hcpu; + +switch (action & ~CPU_TASKS_FROZEN ) { +case CPU_UP_PREPARE : +sh_pmu_setup (cpu); +break ; + +default : +break ; + } + +return NOTIFY_OK ; +} +void hw_perf_enable (void ) {if (!sh_pmu_initialized ())
@@ -308,5 +325,6 @@ int register_sh_pmu(struct sh_pmu *pmu)WARN_ON (pmu->num_events >MAX_HWEVENTS ); +perf_cpu_notifier (sh_pmu_notifier);return 0 ; }
arch/x86/kernel/cpu/perf_event.c +99 -84
369 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_amd.c +26 -36
90 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_intel.c +28 -29
145 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_p6.c +6 -4
@@ -77,27 +77,29 @@ static void p6_pmu_enable_all(void) }static inline void -p6_pmu_disable_event (struct hw_perf_event *hwc,int idx) +p6_pmu_disable_event (struct perf_event *event) {struct cpu_hw_events *cpuc = &__get_cpu_var (cpu_hw_events); +struct hw_perf_event *hwc = &event->hw;u64 val =P6_NOP_EVENT ;if (cpuc->enabled) val |=ARCH_PERFMON_EVENTSEL_ENABLE ; - (void )checking_wrmsrl (hwc->config_base + idx, val); + (void )checking_wrmsrl (hwc->config_base + hwc->idx, val); } -static void p6_pmu_enable_event (struct hw_perf_event *hwc,int idx) +static void p6_pmu_enable_event (struct perf_event *event) {struct cpu_hw_events *cpuc = &__get_cpu_var (cpu_hw_events); +struct hw_perf_event *hwc = &event->hw;u64 val; val = hwc->config;if (cpuc->enabled) val |=ARCH_PERFMON_EVENTSEL_ENABLE ; - (void )checking_wrmsrl (hwc->config_base + idx, val); + (void )checking_wrmsrl (hwc->config_base + hwc->idx, val); }static __initconst struct x86_pmu p6_pmu = {
arch/x86/kernel/dumpstack.h +15 -0
@@ -29,4 +29,19 @@ struct stack_frame {struct stack_frame *next_frame; unsigned long return_address; }; + +static inline unsigned long rewind_frame_pointer (int n) +{ +struct stack_frame *frame; + +get_bp (frame); + +#ifdef CONFIG_FRAME_POINTER +while (n--) + frame = frame->next_frame;#endif + +return (unsigned long )frame; +} + +#endif /* DUMPSTACK_H */
arch/x86/kernel/dumpstack_64.c +2 -2
@@ -208,7 +208,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,if (in_irq_stack (stack, irq_stack, irq_stack_end)) {if (ops->stack (data,"IRQ" ) <0 )break ; - bp =print_context_stack (tinfo, stack, bp, + bp = ops->walk_stack (tinfo, stack, bp, ops, data, irq_stack_end, &graph);/* * We link to the next stack (which would be
@@ -229,7 +229,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,/* * This handles the process stack: */ - bp =print_context_stack (tinfo, stack, bp, ops, data,NULL , &graph); + bp = ops->walk_stack (tinfo, stack, bp, ops, data,NULL , &graph);put_cpu (); }EXPORT_SYMBOL (dump_trace);
include/linux/ftrace_event.h +13 -10
@@ -131,12 +131,12 @@ struct ftrace_event_call {void *mod;void *data; -int profile_count; -int (*profile_enable)(struct ftrace_event_call *); -void (*profile_disable)(struct ftrace_event_call *); +int perf_refcount; +int (*perf_event_enable)(struct ftrace_event_call *); +void (*perf_event_disable)(struct ftrace_event_call *); }; -#define FTRACE_MAX_PROFILE_SIZE 2048 +#define PERF_MAX_TRACE_SIZE 2048#define MAX_FILTER_PRED 32#define MAX_FILTER_STR_VAL 256/* Should handle KSYM_SYMBOL_LEN */
@@ -187,22 +187,25 @@ do { \#ifdef CONFIG_PERF_EVENTS struct perf_event ; -extern int ftrace_profile_enable (int event_id); -extern void ftrace_profile_disable (int event_id); + +DECLARE_PER_CPU(struct pt_regs, perf_trace_regs); + +extern int perf_trace_enable (int event_id); +extern void perf_trace_disable (int event_id);extern int ftrace_profile_set_filter (struct perf_event *event,int event_id,char *filter_str);extern void ftrace_profile_free_filter (struct perf_event *event);extern void * -ftrace_perf_buf_prepare (int size,unsigned short type,int *rctxp, +perf_trace_buf_prepare (int size,unsigned short type,int *rctxp,unsigned long *irq_flags);static inline void -ftrace_perf_buf_submit (void *raw_data,int size,int rctx,u64 addr, -u64 count,unsigned long irq_flags) +perf_trace_buf_submit (void *raw_data,int size,int rctx,u64 addr, +u64 count,unsigned long irq_flags,struct pt_regs *regs) {struct trace_entry *entry = raw_data; -perf_tp_event (entry->type, addr, count, raw_data, size); +perf_tp_event (entry->type, addr, count, raw_data, size, regs);perf_swevent_put_recursion_context (rctx);local_irq_restore (irq_flags); }
include/linux/perf_event.h +58 -1
82 lines not on this page · raw message
include/linux/syscalls.h +12 -12
@@ -101,18 +101,18 @@ struct perf_event_attr;#ifdef CONFIG_PERF_EVENTS -#define TRACE_SYS_ENTER_PROFILE_INIT (sname) \ - .profile_enable = prof_sysenter_enable, \ - .profile_disable = prof_sysenter_disable, +#define TRACE_SYS_ENTER_PERF_INIT (sname) \ + .perf_event_enable = perf_sysenter_enable, \ + .perf_event_disable = perf_sysenter_disable, -#define TRACE_SYS_EXIT_PROFILE_INIT (sname) \ - .profile_enable = prof_sysexit_enable, \ - .profile_disable = prof_sysexit_disable, +#define TRACE_SYS_EXIT_PERF_INIT (sname) \ + .perf_event_enable = perf_sysexit_enable, \ + .perf_event_disable = perf_sysexit_disable,#else -#define TRACE_SYS_ENTER_PROFILE (sname) -#define TRACE_SYS_ENTER_PROFILE_INIT (sname) -#define TRACE_SYS_EXIT_PROFILE (sname) -#define TRACE_SYS_EXIT_PROFILE_INIT (sname) +#define TRACE_SYS_ENTER_PERF (sname) +#define TRACE_SYS_ENTER_PERF_INIT (sname) +#define TRACE_SYS_EXIT_PERF (sname) +#define TRACE_SYS_EXIT_PERF_INIT (sname)#endif /* CONFIG_PERF_EVENTS */ #ifdef CONFIG_FTRACE_SYSCALLS
@@ -149,7 +149,7 @@ struct perf_event_attr; .regfunc = reg_event_syscall_enter, \ .unregfunc = unreg_event_syscall_enter, \ .data = (void *)&__syscall_meta_##sname,\ - TRACE_SYS_ENTER_PROFILE_INIT(sname) \ + TRACE_SYS_ENTER_PERF_INIT(sname) \ }#define SYSCALL_TRACE_EXIT_EVENT (sname) \
@@ -171,7 +171,7 @@ struct perf_event_attr; .regfunc = reg_event_syscall_exit, \ .unregfunc = unreg_event_syscall_exit, \ .data = (void *)&__syscall_meta_##sname,\ - TRACE_SYS_EXIT_PROFILE_INIT(sname) \ + TRACE_SYS_EXIT_PERF_INIT(sname) \ }#define SYSCALL_METADATA (sname, nb) \
include/trace/ftrace.h +24 -20
119 lines not on this page · raw message
include/trace/syscall.h +4 -4
@@ -47,10 +47,10 @@ enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags);#endif #ifdef CONFIG_PERF_EVENTS -int prof_sysenter_enable (struct ftrace_event_call *call); -void prof_sysenter_disable (struct ftrace_event_call *call); -int prof_sysexit_enable (struct ftrace_event_call *call); -void prof_sysexit_disable (struct ftrace_event_call *call); +int perf_sysenter_enable (struct ftrace_event_call *call); +void perf_sysenter_disable (struct ftrace_event_call *call); +int perf_sysexit_enable (struct ftrace_event_call *call); +void perf_sysexit_disable (struct ftrace_event_call *call);#endif #endif /* _TRACE_SYSCALL_H */
kernel/kprobes.c +2 -1
@@ -259,7 +259,8 @@ static void __kprobes __free_insn_slot(struct kprobe_insn_cache *c,struct kprobe_insn_page *kip;list_for_each_entry (kip, &c->pages, list) { -long idx = ((long )slot - (long )kip->insns) / c->insn_size; +long idx = ((long )slot - (long )kip->insns) / + (c->insn_size *sizeof (kprobe_opcode_t));if (idx >=0 && idx <slots_per_page (c)) {WARN_ON (kip->slot_used[idx] !=SLOT_USED );if (dirty) {
kernel/lockdep.c +3 -6
@@ -3211,8 +3211,6 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass, {unsigned long flags; -trace_lock_acquire (lock, subclass, trylock, read, check, nest_lock, ip); -if (unlikely (current->lockdep_recursion))return ;
@@ -3220,6 +3218,7 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,check_flags (flags); current->lockdep_recursion =1 ; +trace_lock_acquire (lock, subclass, trylock, read, check, nest_lock, ip);__lock_acquire (lock, subclass, trylock, read, check,irqs_disabled_flags (flags), nest_lock, ip,0 ); current->lockdep_recursion =0 ;
@@ -3232,14 +3231,13 @@ void lock_release(struct lockdep_map *lock, int nested, {unsigned long flags; -trace_lock_release (lock, nested, ip); -if (unlikely (current->lockdep_recursion))return ;raw_local_irq_save (flags);check_flags (flags); current->lockdep_recursion =1 ; +trace_lock_release (lock, nested, ip);__lock_release (lock, nested, ip); current->lockdep_recursion =0 ;raw_local_irq_restore (flags);
@@ -3413,8 +3411,6 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip) {unsigned long flags; -trace_lock_contended (lock, ip); -if (unlikely (!lock_stat))return ;
@@ -3424,6 +3420,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)raw_local_irq_save (flags);check_flags (flags); current->lockdep_recursion =1 ; +trace_lock_contended (lock, ip);__lock_contended (lock, ip); current->lockdep_recursion =0 ;raw_local_irq_restore (flags);
kernel/perf_event.c +41 -43
214 lines not on this page · raw message
kernel/trace/Makefile +1 -1
@@ -52,7 +52,7 @@ obj-$(CONFIG_EVENT_TRACING) += trace_events.o obj-$(CONFIG_EVENT_TRACING) += trace_export.o obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o ifeq ($(CONFIG_PERF_EVENTS),y) -obj-$(CONFIG_EVENT_TRACING) += trace_event_profile.o +obj-$(CONFIG_EVENT_TRACING) += trace_event_perf.o endif obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o
kernel/trace/trace_event_perf.c renamed from kernel/trace/trace_event_profile.c +27 -23
136 lines not on this page · raw message
kernel/trace/trace_events.c +1 -1
@@ -938,7 +938,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,trace_create_file ("enable" ,0644 , call->dir, call, enable); -if (call->id && call->profile_enable) +if (call->id && call->perf_event_enable)trace_create_file ("id" ,0444 , call->dir, call, id);
kernel/trace/trace_kprobe.c +15 -14
@@ -1214,7 +1214,7 @@ static int set_print_fmt(struct trace_probe *tp)#ifdef CONFIG_PERF_EVENTS /* Kprobe profile handler */ -static __kprobes void kprobe_profile_func (struct kprobe *kp, +static __kprobes void kprobe_perf_func (struct kprobe *kp,struct pt_regs *regs) { struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
@@ -1227,11 +1227,11 @@ static __kprobes void kprobe_profile_func(struct kprobe *kp, __size =SIZEOF_KPROBE_TRACE_ENTRY (tp->nr_args); size =ALIGN (__size +sizeof (u32),sizeof (u64)); size -=sizeof (u32); -if (WARN_ONCE (size >FTRACE_MAX_PROFILE_SIZE , +if (WARN_ONCE (size >PERF_MAX_TRACE_SIZE ,"profile buffer not large enough" ))return ; - entry =ftrace_perf_buf_prepare (size, call->id, &rctx, &irq_flags); + entry =perf_trace_buf_prepare (size, call->id, &rctx, &irq_flags);if (!entry)return ;
@@ -1240,11 +1240,11 @@ static __kprobes void kprobe_profile_func(struct kprobe *kp,for (i =0 ; i < tp->nr_args; i++) entry->args[i] =call_fetch (&tp->args[i].fetch, regs); -ftrace_perf_buf_submit (entry, size, rctx, entry->ip,1 , irq_flags); +perf_trace_buf_submit (entry, size, rctx, entry->ip,1 , irq_flags, regs); }/* Kretprobe profile handler */ -static __kprobes void kretprobe_profile_func (struct kretprobe_instance *ri, +static __kprobes void kretprobe_perf_func (struct kretprobe_instance *ri,struct pt_regs *regs) { struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
@@ -1257,11 +1257,11 @@ static __kprobes void kretprobe_profile_func(struct kretprobe_instance *ri, __size =SIZEOF_KRETPROBE_TRACE_ENTRY (tp->nr_args); size =ALIGN (__size +sizeof (u32),sizeof (u64)); size -=sizeof (u32); -if (WARN_ONCE (size >FTRACE_MAX_PROFILE_SIZE , +if (WARN_ONCE (size >PERF_MAX_TRACE_SIZE ,"profile buffer not large enough" ))return ; - entry =ftrace_perf_buf_prepare (size, call->id, &rctx, &irq_flags); + entry =perf_trace_buf_prepare (size, call->id, &rctx, &irq_flags);if (!entry)return ;
@@ -1271,10 +1271,11 @@ static __kprobes void kretprobe_profile_func(struct kretprobe_instance *ri,for (i =0 ; i < tp->nr_args; i++) entry->args[i] =call_fetch (&tp->args[i].fetch, regs); -ftrace_perf_buf_submit (entry, size, rctx, entry->ret_ip,1 , irq_flags); +perf_trace_buf_submit (entry, size, rctx, entry->ret_ip,1 , + irq_flags, regs); } -static int probe_profile_enable (struct ftrace_event_call *call) +static int probe_perf_enable (struct ftrace_event_call *call) {struct trace_probe *tp = (struct trace_probe *)call->data;
@@ -1286,7 +1287,7 @@ static int probe_profile_enable(struct ftrace_event_call *call)return enable_kprobe (&tp->rp.kp); } -static void probe_profile_disable (struct ftrace_event_call *call) +static void probe_perf_disable (struct ftrace_event_call *call) {struct trace_probe *tp = (struct trace_probe *)call->data;
@@ -1311,7 +1312,7 @@ int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs)kprobe_trace_func (kp, regs);#ifdef CONFIG_PERF_EVENTS if (tp->flags &TP_FLAG_PROFILE ) -kprobe_profile_func (kp, regs); +kprobe_perf_func (kp, regs);#endif return 0 ;/* We don't tweek kernel, so just return 0 */ }
@@ -1325,7 +1326,7 @@ int kretprobe_dispatcher(struct kretprobe_instance *ri, struct pt_regs *regs)kretprobe_trace_func (ri, regs);#ifdef CONFIG_PERF_EVENTS if (tp->flags &TP_FLAG_PROFILE ) -kretprobe_profile_func (ri, regs); +kretprobe_perf_func (ri, regs);#endif return 0 ;/* We don't tweek kernel, so just return 0 */ }
@@ -1358,8 +1359,8 @@ static int register_probe_event(struct trace_probe *tp) call->unregfunc = probe_event_disable;#ifdef CONFIG_PERF_EVENTS - call->profile_enable = probe_profile_enable; - call->profile_disable = probe_profile_disable; + call->perf_event_enable = probe_perf_enable; + call->perf_event_disable = probe_perf_disable;#endif call->data = tp; ret =trace_add_event_call (call);
kernel/trace/trace_syscalls.c +36 -36
168 lines not on this page · raw message
tools/perf/Documentation/Makefile +3 -1
@@ -24,7 +24,10 @@ DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT)) DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) +# Make the path relative to DESTDIR, not prefix +ifndef DESTDIR prefix?=$(HOME) +endif bindir?=$(prefix)/bin htmldir?=$(prefix)/share/doc/perf-doc pdfdir?=$(prefix)/share/doc/perf-doc
@@ -32,7 +35,6 @@ mandir?=$(prefix)/share/man man1dir=$(mandir)/man1 man5dir=$(mandir)/man5 man7dir=$(mandir)/man7 -# DESTDIR= ASCIIDOC=asciidoc ASCIIDOC_EXTRA = --unsafe
tools/perf/Makefile +5 -1
@@ -216,7 +216,10 @@ STRIP ?= strip # runtime figures out where they are based on the path to the executable. # This can help installing the suite in a relocatable way. +# Make the path relative to DESTDIR, not to prefix +ifndef DESTDIR prefix = $(HOME) +endif bindir_relative = bin bindir = $(prefix)/$(bindir_relative) mandir = share/man
@@ -233,7 +236,6 @@ sysconfdir = $(prefix)/etc ETC_PERFCONFIG = etc/perfconfig endif lib = lib -# DESTDIR= export prefix bindir sharedir sysconfdir
@@ -387,6 +389,7 @@ LIB_H += util/thread.h LIB_H += util/trace-event.h LIB_H += util/probe-finder.h LIB_H += util/probe-event.h +LIB_H += util/cpumap.h LIB_OBJS += util/abspath.o LIB_OBJS += util/alias.o
@@ -433,6 +436,7 @@ LIB_OBJS += util/sort.o LIB_OBJS += util/hist.o LIB_OBJS += util/probe-event.o LIB_OBJS += util/util.o +LIB_OBJS += util/cpumap.o BUILTIN_OBJS += builtin-annotate.o
tools/perf/builtin-annotate.c +3 -3
@@ -116,7 +116,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,return 0 ; } - he =__perf_session__add_hist_entry (self, al,NULL , count, &hit); + he =__perf_session__add_hist_entry (&self->hists, al,NULL , count, &hit);if (he ==NULL )return -ENOMEM ;
@@ -564,8 +564,8 @@ static int __cmd_annotate(void)if (verbose >2 )dsos__fprintf (stdout); -perf_session__collapse_resort (session); -perf_session__output_resort (session, session->event_total[0 ]); +perf_session__collapse_resort (&session->hists); +perf_session__output_resort (&session->hists, session->event_total[0 ]);perf_session__find_annotations (session); out_delete:perf_session__delete (session);
tools/perf/builtin-diff.c +8 -5
@@ -26,7 +26,8 @@ static int perf_session__add_hist_entry(struct perf_session *self, struct addr_location *al, u64 count) { bool hit; -struct hist_entry *he =__perf_session__add_hist_entry (self, al,NULL , +struct hist_entry *he =__perf_session__add_hist_entry (&self->hists, + al,NULL , count, &hit);if (he ==NULL )return -ENOMEM ;
@@ -114,7 +115,7 @@ static void perf_session__resort_hist_entries(struct perf_session *self)static void perf_session__set_hist_entries_positions (struct perf_session *self) { -perf_session__output_resort (self, self->events_stats.total); +perf_session__output_resort (&self->hists, self->events_stats.total);perf_session__resort_hist_entries (self); }
@@ -166,13 +167,15 @@ static int __cmd_diff(void) goto out_delete; } -perf_session__output_resort (session[1 ], session[1 ]->events_stats.total); +perf_session__output_resort (&session[1 ]->hists, + session[1 ]->events_stats.total);if (show_displacement)perf_session__set_hist_entries_positions (session[0 ]);perf_session__match_hists (session[0 ], session[1 ]); -perf_session__fprintf_hists (session[1 ], session[0 ], - show_displacement, stdout); +perf_session__fprintf_hists (&session[1 ]->hists, session[0 ], + show_displacement, stdout, + session[1 ]->events_stats.total); out_delete:for (i =0 ; i <2 ; ++i)perf_session__delete (session[i]);
tools/perf/builtin-record.c +9 -4
@@ -22,6 +22,7 @@#include "util/debug.h" #include "util/session.h" #include "util/symbol.h" +#include "util/cpumap.h" #include <unistd.h> #include <sched.h>
@@ -244,6 +245,9 @@ static void create_counter(int counter, int cpu, pid_t pid) attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID ; +if (nr_counters >1 ) + attr->sample_type |=PERF_SAMPLE_ID ; +if (freq) { attr->sample_type |=PERF_SAMPLE_PERIOD ; attr->freq =1 ;
@@ -391,6 +395,9 @@ static int process_buildids(void) {u64 size =lseek (output,0 ,SEEK_CUR ); +if (size ==0 ) +return 0 ; + session->fd = output; return __perf_session__process_events(session, post_processing_offset, size - post_processing_offset,
@@ -418,9 +425,6 @@ static int __cmd_record(int argc, const char **argv)char buf; page_size =sysconf (_SC_PAGE_SIZE); - nr_cpus =sysconf (_SC_NPROCESSORS_ONLN); -assert (nr_cpus <=MAX_NR_CPUS ); -assert (nr_cpus >=0 );atexit (sig_atexit);signal (SIGCHLD , sig_handler);
@@ -544,8 +548,9 @@ static int __cmd_record(int argc, const char **argv)if ((!system_wide && !inherit) || profile_cpu !=-1 ) {open_counters (profile_cpu, target_pid); }else { + nr_cpus =read_cpu_map ();for (i =0 ; i < nr_cpus; i++) -open_counters (i, target_pid); +open_counters (cpumap[i], target_pid); }if (file_new) {
tools/perf/builtin-report.c +100 -12
166 lines not on this page · raw message
tools/perf/builtin-stat.c +6 -4
@@ -45,6 +45,7 @@#include "util/event.h" #include "util/debug.h" #include "util/header.h" +#include "util/cpumap.h" #include <sys/prctl.h> #include <math.h>
@@ -151,7 +152,7 @@ static void create_perf_stat_counter(int counter, int pid)unsigned int cpu;for (cpu =0 ; cpu < nr_cpus; cpu++) { - fd[cpu][counter] =sys_perf_event_open (attr,-1 , cpu,-1 ,0 ); + fd[cpu][counter] =sys_perf_event_open (attr,-1 , cpumap[cpu],-1 ,0 );if (fd[cpu][counter] <0 && verbose)fprintf (stderr,ERR_PERF_OPEN , counter, fd[cpu][counter],strerror (errno));
@@ -519,9 +520,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) nr_counters =ARRAY_SIZE (default_attrs); } - nr_cpus =sysconf (_SC_NPROCESSORS_ONLN); -assert (nr_cpus <=MAX_NR_CPUS ); -assert ((int )nr_cpus >=0 ); +if (system_wide) + nr_cpus =read_cpu_map (); +else + nr_cpus =1 ;/* * We dont want to block the signals - that would cause
tools/perf/builtin-top.c +4 -5
@@ -28,6 +28,7 @@#include <linux/rbtree.h> #include "util/parse-options.h" #include "util/parse-events.h" +#include "util/cpumap.h" #include "util/debug.h"
@@ -1123,7 +1124,7 @@ static void start_counter(int i, int counter) cpu = profile_cpu;if (target_pid ==-1 && profile_cpu ==-1 ) - cpu = i; + cpu = cpumap[i]; attr = attrs + counter;
@@ -1347,12 +1348,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) attrs[counter].sample_period = default_interval; } - nr_cpus =sysconf (_SC_NPROCESSORS_ONLN); -assert (nr_cpus <=MAX_NR_CPUS ); -assert (nr_cpus >=0 ); -if (target_pid !=-1 || profile_cpu !=-1 ) nr_cpus =1 ; +else + nr_cpus =read_cpu_map ();get_term_dimensions (&winsize);if (print_entries ==0 ) {
tools/perf/util/cpumap.c new file +59 -0
59 lines not on this page · raw message
tools/perf/util/cpumap.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __PERF_CPUMAP_H +#define __PERF_CPUMAP_H + +extern int read_cpu_map (void ); +extern int cpumap[]; + +#endif /* __PERF_CPUMAP_H */
tools/perf/util/event.h +9 -0
@@ -99,6 +99,15 @@ struct events_stats {u64 lost; }; +struct event_stat_id { +struct rb_node rb_node; +struct rb_root hists; +struct events_stats stats; +u64 config; +u64 event_stream; +u32 type; +}; +void event__print_totals (void );struct perf_session ;
tools/perf/util/hist.c +28 -22
152 lines not on this page · raw message
tools/perf/util/hist.h +7 -5
@@ -10,8 +10,9 @@ struct perf_session;struct hist_entry ;struct addr_location ;struct symbol ; +struct rb_root ; -struct hist_entry *__perf_session__add_hist_entry (struct perf_session *self, +struct hist_entry *__perf_session__add_hist_entry (struct rb_root *hists,struct addr_location *al,struct symbol *parent,u64 count,bool *hit);
@@ -19,9 +20,10 @@ extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);extern int64_t hist_entry__collapse (struct hist_entry *,struct hist_entry *);void hist_entry__free (struct hist_entry *); -void perf_session__output_resort (struct perf_session *self,u64 total_samples); -void perf_session__collapse_resort (struct perf_session *self); -size_t perf_session__fprintf_hists (struct perf_session *self, +void perf_session__output_resort (struct rb_root *hists,u64 total_samples); +void perf_session__collapse_resort (struct rb_root *hists); +size_t perf_session__fprintf_hists (struct rb_root *hists,struct perf_session *pair, -bool show_displacement,FILE *fp); +bool show_displacement,FILE *fp, +u64 session_total);#endif /* __PERF_HIST_H */
tools/perf/util/probe-finder.c +1 -1
@@ -169,7 +169,7 @@ static const char *cu_find_realpath(Dwarf_Die *cu_die, const char *fname) {Dwarf_Files *files;size_t nfiles, i; -const char *src; +const char *src =NULL ;int ret;if (!fname)
tools/perf/util/session.c +1 -0
@@ -70,6 +70,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forcmemcpy (self->filename, filename, len); self->threads =RB_ROOT ; + self->stats_by_id =RB_ROOT ; self->last_match =NULL ; self->mmap_window =32 ; self->cwd =NULL ;
tools/perf/util/session.h +1 -0
@@ -20,6 +20,7 @@ struct perf_session {struct thread *last_match;struct map *vmlinux_maps[MAP__NR_TYPES ];struct events_stats events_stats; +struct rb_root stats_by_id;unsigned long event_total[PERF_RECORD_MAX ];unsigned long unknown_events;struct rb_root hists;
tools/perf/util/thread.c +35 -6
72 lines not on this page · raw message
tools/perf/util/thread.h +3 -0
@@ -10,6 +10,9 @@ struct map_groups {struct list_head removed_maps[MAP__NR_TYPES ]; }; +size_t __map_groups__fprintf_maps (struct map_groups *self, +enum map_type type,FILE *fp); +struct thread {struct rb_node rb_node;struct map_groups mg;