perf fixes
Subsystems (4)
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
Thanks,
Ingo
------------------>
Borislav Petkov (1):
perf, probe-finder: Build fix on Debian
Frederic Weisbecker (4):
perf: Correctly align perf event tracing buffer
perf: Use hot regs with software sched switch/migrate events
perf: Always build the stub perf_arch_fetch_caller_regs version
perf: Always build the powerpc perf_arch_fetch_caller_regs version
Jason Wessel (1):
x86,kgdb: Always initialize the hw breakpoint attribute
Mike Galbraith (1):
perf: Fix 'perf sched record' deadlock
Peter Zijlstra (2):
x86: Move notify_cpu_starting() callback to a later stage perf, x86: Fix AMD hotplug & constraint initialization
Tom Zanussi (1):
perf/scripts: Tuple was set from long in both branches in python_process_event()
Torok Edwin (1):
perf, x86: Fix callgraphs of 32-bit processes on 64-bit kernels
arch/powerpc/kernel/misc.S | 2 - arch/x86/kernel/cpu/perf_event.c | 54 +++++++++++--- arch/x86/kernel/cpu/perf_event_amd.c | 80 ++++++++++++-------- arch/x86/kernel/dumpstack.h | 5 + arch/x86/kernel/kgdb.c | 2 +- arch/x86/kernel/smpboot.c | 4 +- include/linux/perf_event.h | 21 ++++-- kernel/perf_event.c | 22 ++++-- kernel/trace/trace_event_perf.c | 11 ++- tools/perf/Makefile | 10 +- .../util/scripting-engines/trace-event-python.c | 17 +++- 11 files changed, 153 insertions(+), 75 deletions(-)
arch/powerpc/kernel/misc.S +0 -2
@@ -128,7 +128,6 @@ _GLOBAL(__restore_cpu_power7) /* place holder */ blr -#ifdef CONFIG_EVENT_TRACING /* * Get a minimal set of registers for our caller's nth caller. * r3 = regs pointer, r5 = n.
@@ -154,4 +153,3 @@ _GLOBAL(perf_arch_fetch_caller_regs) PPC_STL r4,_NIP-STACK_FRAME_OVERHEAD(r3) PPC_STL r7,_LINK-STACK_FRAME_OVERHEAD(r3) blr -#endif /* CONFIG_EVENT_TRACING */
arch/x86/kernel/cpu/perf_event.c +44 -10
117 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_amd.c +47 -33
134 lines not on this page · raw message
arch/x86/kernel/dumpstack.h +5 -0
@@ -30,6 +30,11 @@ struct stack_frame {unsigned long return_address; }; +struct stack_frame_ia32 { +u32 next_frame; +u32 return_address; +}; +static inline unsigned long rewind_frame_pointer (int n) {struct stack_frame *frame;
arch/x86/kernel/kgdb.c +1 -1
@@ -618,8 +618,8 @@ int kgdb_arch_init(void)* portion of kgdb because this operation requires mutexs to * complete. */ +hw_breakpoint_init (&attr); attr.bp_addr = (unsigned long )kgdb_arch_init; - attr.type =PERF_TYPE_BREAKPOINT ; attr.bp_len =HW_BREAKPOINT_LEN_1 ; attr.bp_type =HW_BREAKPOINT_W ; attr.disabled =1 ;
arch/x86/kernel/smpboot.c +2 -2
@@ -242,8 +242,6 @@ static void __cpuinit smp_callin(void)end_local_APIC_setup ();map_cpu_to_logical_apicid (); -notify_cpu_starting (cpuid); -/* * Need to setup vector mappings before we enable interrupts. */
@@ -264,6 +262,8 @@ static void __cpuinit smp_callin(void)*/ smp_store_cpu_info (cpuid); +notify_cpu_starting (cpuid); +/* * Allow the master to continue. */
include/linux/perf_event.h +14 -7
@@ -842,13 +842,6 @@ extern atomic_t perf_swevent_enabled[PERF_COUNT_SW_MAX];extern void __perf_sw_event (u32 ,u64 ,int ,struct pt_regs *,u64 ); -static inline void -perf_sw_event (u32 event_id,u64 nr,int nmi,struct pt_regs *regs,u64 addr) -{ -if (atomic_read (&perf_swevent_enabled[event_id])) -__perf_sw_event (event_id, nr, nmi, regs, addr); -} -extern void perf_arch_fetch_caller_regs (struct pt_regs *regs,unsigned long ip,int skip);
@@ -887,6 +880,20 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs, int skip)return perf_arch_fetch_caller_regs (regs, ip, skip); } +static inline void +perf_sw_event (u32 event_id,u64 nr,int nmi,struct pt_regs *regs,u64 addr) +{ +if (atomic_read (&perf_swevent_enabled[event_id])) { +struct pt_regs hot_regs; + +if (!regs) { +perf_fetch_caller_regs (&hot_regs,1 ); + regs = &hot_regs; + } +__perf_sw_event (event_id, nr, nmi, regs, addr); + } +} +extern void __perf_event_mmap (struct vm_area_struct *vma);static inline void perf_event_mmap (struct vm_area_struct *vma)
kernel/perf_event.c +14 -8
@@ -1164,11 +1164,9 @@ void perf_event_task_sched_out(struct task_struct *task,struct perf_event_context *ctx = task->perf_event_ctxp;struct perf_event_context *next_ctx;struct perf_event_context *parent; -struct pt_regs *regs;int do_switch =1 ; - regs =task_pt_regs (task); -perf_sw_event (PERF_COUNT_SW_CONTEXT_SWITCHES ,1 ,1 , regs,0 ); +perf_sw_event (PERF_COUNT_SW_CONTEXT_SWITCHES ,1 ,1 ,NULL ,0 );if (likely (!ctx || !cpuctx->task_ctx))return ;
@@ -2786,12 +2784,11 @@ __weak struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)return NULL ; } -#ifdef CONFIG_EVENT_TRACING __weak void perf_arch_fetch_caller_regs (struct pt_regs *regs,unsigned long ip,int skip) { } -#endif +/* * Output
@@ -3378,15 +3375,23 @@ static void perf_event_task_output(struct perf_event *event, struct perf_task_event *task_event) {struct perf_output_handle handle; -int size;struct task_struct *task = task_event->task; -int ret; +unsigned long flags; +int size, ret; + +/* +* If this CPU attempts to acquire an rq lock held by a CPU spinning +* in perf_output_lock() from interrupt context, it's game over. +*/ +local_irq_save (flags); size = task_event->event_id.header.size; ret =perf_output_begin (&handle, event, size,0 ,0 ); -if (ret) +if (ret) { +local_irq_restore (flags);return ; + } task_event->event_id.pid =perf_event_pid (event, task); task_event->event_id.ppid =perf_event_pid (event, current);
@@ -3397,6 +3402,7 @@ static void perf_event_task_output(struct perf_event *event,perf_output_put (&handle, task_event->event_id);perf_output_end (&handle); +local_irq_restore (flags); }static int perf_event_task_match (struct perf_event *event)
kernel/trace/trace_event_perf.c +9 -2
@@ -17,7 +17,12 @@ EXPORT_SYMBOL_GPL(perf_arch_fetch_caller_regs);static char *perf_trace_buf;static char *perf_trace_buf_nmi; -typedef typeof (char [PERF_MAX_TRACE_SIZE ])perf_trace_t ; +/* +* Force it to be aligned to unsigned long to avoid misaligned accesses +* suprises +*/ +typedef typeof (unsigned long [PERF_MAX_TRACE_SIZE /sizeof (unsigned long )]) +perf_trace_t ;/* Count the events in use (per event id, not per instance) */ static int total_ref_count;
@@ -130,6 +135,8 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,char *trace_buf, *raw_data;int pc, cpu; +BUILD_BUG_ON (PERF_MAX_TRACE_SIZE %sizeof (unsigned long )); + pc =preempt_count ();/* Protect the per cpu buffer, begin the rcu read side */
@@ -152,7 +159,7 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type, raw_data =per_cpu_ptr (trace_buf, cpu);/* zero the dead bytes from align to not leak stack to user */ - *(u64 *)(&raw_data[size -sizeof (u64)]) =0ULL ; +memset (&raw_data[size -sizeof (u64)],0 ,sizeof (u64)); entry = (struct trace_entry *)raw_data;tracing_generic_entry_update (entry, *irq_flags, pc);
tools/perf/Makefile +5 -5
@@ -200,7 +200,7 @@ endif CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) EXTLIBS = -lpthread -lrt -lelf -lm -ALL_CFLAGS = $(CFLAGS) +ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ALL_LDFLAGS = $(LDFLAGS) STRIP ?= strip
@@ -492,19 +492,19 @@ ifeq ($(uname_S),Darwin) PTHREAD_LIBS = endif -ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) -ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) +ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) +ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); endif - ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) + ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) BASIC_CFLAGS += -DLIBELF_NO_MMAP endif else msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); endif -ifneq ($(shell sh -c "(echo '\#include <dwarf.h>'; echo '\#include <libdw.h>'; echo 'int main(void) { Dwarf *dbg; dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/elfutils -ldw -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) +ifneq ($(shell sh -c "(echo '\#include <dwarf.h>'; echo '\#include <libdw.h>'; echo 'int main(void) { Dwarf *dbg; dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -I/usr/include/elfutils -ldw -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) msg := $(warning No libdw.h found or old libdw.h found, disables dwarf support. Please install elfutils-devel/elfutils-dev); BASIC_CFLAGS += -DNO_DWARF_SUPPORT else
tools/perf/util/scripting-engines/trace-event-python.c +12 -5
@@ -208,7 +208,7 @@ static void python_process_event(int cpu, void *data, int size __unused, unsigned long long nsecs, char *comm) { - PyObject *handler, *retval, *context, *t; + PyObject *handler, *retval, *context, *t, *obj;static char handler_name[256 ];struct format_field *field;unsigned long long val;
@@ -256,16 +256,23 @@ static void python_process_event(int cpu, void *data, offset &=0xffff ; }else offset = field->offset; -PyTuple_SetItem (t, n++, -PyString_FromString ((char *)data + offset)); + obj =PyString_FromString ((char *)data + offset); }else {/* FIELD_IS_NUMERIC */ val =read_size (data + field->offset, field->size);if (field->flags &FIELD_IS_SIGNED ) { -PyTuple_SetItem (t, n++,PyInt_FromLong (val)); +if ((long long )val >=LONG_MIN && + (long long )val <=LONG_MAX ) + obj =PyInt_FromLong (val); +else + obj =PyLong_FromLongLong (val); }else { -PyTuple_SetItem (t, n++,PyInt_FromLong (val)); +if (val <=LONG_MAX ) + obj =PyInt_FromLong (val); +else + obj =PyLong_FromUnsignedLongLong (val); } } +PyTuple_SetItem (t, n++, obj); }if (_PyTuple_Resize (&t, n) ==-1 )