perf fixes
Subsystems (4)
Linus,
Please pull the latest perf-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-for-linus
# HEAD: d785452c9972fac2808479eb561d5c426b6e7d3b Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Mostly tooling fixes, plus on the kernel side:
- a revert for a newly introduced PMU driver which isn't complete yet and where we ran out of time with fixes (to be tried again in v3.19) - this makes up for a large chunk of the diffstat.
- compilation warning fixes
- a printk message fix
- event_idx usage fixes/cleanups.
Thanks,
Ingo
------------------>
Andy Lutomirski (1):
perf: Fix typos in sample code in the perf_event.h header
Ingo Molnar (1):
perf/x86/intel: Revert incomplete and undocumented Broadwell client support
Jiri Olsa (7):
perf tools: Fix report -F abort for data without branch info perf tools: Fix report -F in_tx for data without branch info perf tools: Fix report -F mispredict for data without branch info perf tools: Fix report -F symbol_to for data without branch info perf tools: Fix report -F symbol_from for data without branch info perf tools: Fix report -F dso_to for data without branch info perf tools: Fix report -F dso_from for data without branch info
Kan Liang (1):
perf diff: Add missing hists__init() call at tool start
Masami Hiramatsu (1):
perf probe: Trivial typo fix for --demangle
Namhyung Kim (1):
perf callchain: Use global caching provided by libunwind
Peter Zijlstra (2):
perf: Fix and clean up initialization of pmu::event_idx perf/x86: Fix compile warnings for intel_uncore
Peter Zijlstra (Intel) (1):
perf: Fix bogus kernel printk
Wang Nan (1):
perf tools: Make CPUINFO_PROC an array to support different kernel versions
arch/powerpc/perf/hv-24x7.c | 6 -- arch/powerpc/perf/hv-gpci.c | 6 -- arch/s390/kernel/perf_cpum_sf.c | 6 -- arch/x86/Kconfig | 4 + arch/x86/kernel/cpu/Makefile | 7 +- arch/x86/kernel/cpu/perf_event.c | 14 +-- arch/x86/kernel/cpu/perf_event.h | 1 - arch/x86/kernel/cpu/perf_event_intel.c | 173 +-------------------------------- include/uapi/linux/perf_event.h | 14 +-- kernel/events/core.c | 15 +-- kernel/events/hw_breakpoint.c | 7 -- tools/perf/builtin-diff.c | 5 + tools/perf/builtin-probe.c | 2 +- tools/perf/perf-sys.h | 30 +++--- tools/perf/util/header.c | 27 +++-- tools/perf/util/sort.c | 102 ++++++++++++++----- tools/perf/util/thread.c | 3 + tools/perf/util/unwind-libunwind.c | 12 +++ tools/perf/util/unwind.h | 3 + 19 files changed, 158 insertions(+), 279 deletions(-)
arch/powerpc/perf/hv-24x7.c +0 -6
@@ -417,11 +417,6 @@ static int h_24x7_event_add(struct perf_event *event, int flags)return 0 ; } -static int h_24x7_event_idx (struct perf_event *event) -{ -return 0 ; -} -static struct pmu h_24x7_pmu = { .task_ctx_nr = perf_invalid_context,
@@ -433,7 +428,6 @@ static struct pmu h_24x7_pmu = { .start = h_24x7_event_start, .stop = h_24x7_event_stop, .read = h_24x7_event_update, - .event_idx = h_24x7_event_idx, };static int hv_24x7_init (void )
arch/powerpc/perf/hv-gpci.c +0 -6
@@ -246,11 +246,6 @@ static int h_gpci_event_init(struct perf_event *event)return 0 ; } -static int h_gpci_event_idx (struct perf_event *event) -{ -return 0 ; -} -static struct pmu h_gpci_pmu = { .task_ctx_nr = perf_invalid_context,
@@ -262,7 +257,6 @@ static struct pmu h_gpci_pmu = { .start = h_gpci_event_start, .stop = h_gpci_event_stop, .read = h_gpci_event_update, - .event_idx = h_gpci_event_idx, };static int hv_gpci_init (void )
arch/s390/kernel/perf_cpum_sf.c +0 -6
@@ -1411,11 +1411,6 @@ static void cpumsf_pmu_del(struct perf_event *event, int flags)perf_pmu_enable (event->pmu); } -static int cpumsf_pmu_event_idx (struct perf_event *event) -{ -return event->hw.idx; -} -CPUMF_EVENT_ATTR (SF ,SF_CYCLES_BASIC ,PERF_EVENT_CPUM_SF );CPUMF_EVENT_ATTR (SF ,SF_CYCLES_BASIC_DIAG ,PERF_EVENT_CPUM_SF_DIAG );
@@ -1458,7 +1453,6 @@ static struct pmu cpumf_sampling = { .stop = cpumsf_pmu_stop, .read = cpumsf_pmu_read, - .event_idx = cpumsf_pmu_event_idx, .attr_groups = cpumsf_pmu_attr_groups, };
arch/x86/Kconfig +4 -0
@@ -142,6 +142,10 @@ config INSTRUCTION_DECODER def_bool y depends on KPROBES || PERF_EVENTS || UPROBES +config PERF_EVENTS_INTEL_UNCORE + def_bool y + depends on PERF_EVENTS && SUP_SUP_INTEL && PCI + config OUTPUT_FORMAT string default "elf32-i386" if X86_32
arch/x86/kernel/cpu/Makefile +5 -2
@@ -39,9 +39,12 @@ obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd_iommu.o endif obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_knc.o perf_event_p4.o obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o -obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_uncore.o perf_event_intel_uncore_snb.o -obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_uncore_snbep.o perf_event_intel_uncore_nhmex.o obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_rapl.o + +obj-$(CONFIG_PERF_EVENTS_INTEL_UNCORE) += perf_event_intel_uncore.o \ + perf_event_intel_uncore_snb.o \ + perf_event_intel_uncore_snbep.o \ + perf_event_intel_uncore_nhmex.o endif
arch/x86/kernel/cpu/perf_event.c +3 -11
@@ -243,8 +243,9 @@ static bool check_hw_exists(void) msr_fail:printk (KERN_CONT "Broken PMU hardware detected, using software events only.\n" ); -printk (boot_cpu_has (X86_FEATURE_HYPERVISOR ) ?KERN_INFO :KERN_ERR -"Failed to access perfctr msr (MSR %x is %Lx)\n" , reg, val_new); +printk ("%sFailed to access perfctr msr (MSR %x is %Lx)\n" , +boot_cpu_has (X86_FEATURE_HYPERVISOR ) ?KERN_INFO :KERN_ERR , + reg, val_new);return false; }
@@ -444,12 +445,6 @@ int x86_pmu_hw_config(struct perf_event *event)if (event->attr.type ==PERF_TYPE_RAW ) event->hw.config |= event->attr.config &X86_RAW_EVENT_MASK ; -if (event->attr.sample_period && x86_pmu.limit_period) { -if (x86_pmu.limit_period (event, event->attr.sample_period) > - event->attr.sample_period) -return -EINVAL ; - } -return x86_setup_perfctr (event); }
@@ -987,9 +982,6 @@ int x86_perf_event_set_period(struct perf_event *event)if (left > x86_pmu.max_period) left = x86_pmu.max_period; -if (x86_pmu.limit_period) - left = x86_pmu.limit_period (event, left); -per_cpu (pmc_prev_left[idx],smp_processor_id ()) = left;/*
arch/x86/kernel/cpu/perf_event.h +0 -1
@@ -445,7 +445,6 @@ struct x86_pmu {struct x86_pmu_quirk *quirks;int perfctr_second_write;bool late_ack; -unsigned (*limit_period)(struct perf_event *event,unsigned l);/* * sysfs attrs
arch/x86/kernel/cpu/perf_event_intel.c +2 -171
203 lines not on this page · raw message
include/uapi/linux/perf_event.h +7 -7
@@ -364,7 +364,7 @@ struct perf_event_mmap_page {/* * Bits needed to read the hw events in user-space. * -* u32 seq, time_mult, time_shift, idx, width; +* u32 seq, time_mult, time_shift, index, width; * u64 count, enabled, running; * u64 cyc, time_offset; * s64 pmc = 0;
@@ -383,11 +383,11 @@ struct perf_event_mmap_page {* time_shift = pc->time_shift; * } * -* idx = pc->index; +* index = pc->index; * count = pc->offset; -* if (pc->cap_usr_rdpmc && idx) { +* if (pc->cap_user_rdpmc && index) { * width = pc->pmc_width; -* pmc = rdpmc(idx - 1); +* pmc = rdpmc(index - 1); * } * * barrier();
@@ -415,7 +415,7 @@ struct perf_event_mmap_page { };/* -* If cap_usr_rdpmc this field provides the bit-width of the value +* If cap_user_rdpmc this field provides the bit-width of the value * read using the rdpmc() or equivalent instruction. This can be used * to sign extend the result like: *
@@ -439,10 +439,10 @@ struct perf_event_mmap_page {* * Where time_offset,time_mult,time_shift and cyc are read in the * seqcount loop described above. This delta can then be added to -* enabled and possible running (if idx), improving the scaling: +* enabled and possible running (if index), improving the scaling: * * enabled += delta; -* if (idx) +* if (index) * running += delta; * * quot = count / running;
kernel/events/core.c +1 -14
@@ -6071,11 +6071,6 @@ static int perf_swevent_init(struct perf_event *event)return 0 ; } -static int perf_swevent_event_idx (struct perf_event *event) -{ -return 0 ; -} -static struct pmu perf_swevent = { .task_ctx_nr = perf_sw_context,
@@ -6085,8 +6080,6 @@ static struct pmu perf_swevent = { .start = perf_swevent_start, .stop = perf_swevent_stop, .read = perf_swevent_read, - - .event_idx = perf_swevent_event_idx, };#ifdef CONFIG_EVENT_TRACING
@@ -6204,8 +6197,6 @@ static struct pmu perf_tracepoint = { .start = perf_swevent_start, .stop = perf_swevent_stop, .read = perf_swevent_read, - - .event_idx = perf_swevent_event_idx, };static inline void perf_tp_register (void )
@@ -6431,8 +6422,6 @@ static struct pmu perf_cpu_clock = { .start = cpu_clock_event_start, .stop = cpu_clock_event_stop, .read = cpu_clock_event_read, - - .event_idx = perf_swevent_event_idx, };/*
@@ -6511,8 +6500,6 @@ static struct pmu perf_task_clock = { .start = task_clock_event_start, .stop = task_clock_event_stop, .read = task_clock_event_read, - - .event_idx = perf_swevent_event_idx, };static void perf_pmu_nop_void (struct pmu *pmu)
@@ -6542,7 +6529,7 @@ static void perf_pmu_cancel_txn(struct pmu *pmu)static int perf_event_idx_default (struct perf_event *event) { -return event->hw.idx +1 ; +return 0 ; }/*
kernel/events/hw_breakpoint.c +0 -7
@@ -605,11 +605,6 @@ static void hw_breakpoint_stop(struct perf_event *bp, int flags) bp->hw.state =PERF_HES_STOPPED ; } -static int hw_breakpoint_event_idx (struct perf_event *bp) -{ -return 0 ; -} -static struct pmu perf_breakpoint = { .task_ctx_nr = perf_sw_context,/* could eventually get its own */
@@ -619,8 +614,6 @@ static struct pmu perf_breakpoint = { .start = hw_breakpoint_start, .stop = hw_breakpoint_stop, .read = hw_breakpoint_pmu_read, - - .event_idx = hw_breakpoint_event_idx, };int __init init_hw_breakpoint (void )
tools/perf/builtin-diff.c +5 -0
@@ -1142,6 +1142,11 @@ static int data_init(int argc, const char **argv)int cmd_diff (int argc,const char **argv,const char *prefix__maybe_unused ) { +int ret =hists__init (); + +if (ret <0 ) +return ret; +perf_config (perf_default_config,NULL ); argc =parse_options (argc, argv, options, diff_usage,0 );
tools/perf/builtin-probe.c +1 -1
@@ -375,7 +375,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)OPT_CALLBACK ('x' ,"exec" ,NULL ,"executable|path" ,"target executable name or path" , opt_set_target),OPT_BOOLEAN (0 ,"demangle" , &symbol_conf.demangle, -"Disable symbol demangling" ), +"Enable symbol demangling" ),OPT_BOOLEAN (0 ,"demangle-kernel" , &symbol_conf.demangle_kernel,"Enable kernel symbol demangling" ),OPT_END ()
tools/perf/perf-sys.h +15 -15
@@ -13,7 +13,7 @@#define wmb () asm volatile("lock; addl $0,0(%%esp)" ::: "memory")#define rmb () asm volatile("lock; addl $0,0(%%esp)" ::: "memory")#define cpu_relax () asm volatile("rep; nop" ::: "memory"); -#define CPUINFO_PROC "model name" +#define CPUINFO_PROC {"model name"}#ifndef __NR_perf_event_open# define __NR_perf_event_open 336#endif
@@ -30,7 +30,7 @@#define wmb () asm volatile("sfence" ::: "memory")#define rmb () asm volatile("lfence" ::: "memory")#define cpu_relax () asm volatile("rep; nop" ::: "memory"); -#define CPUINFO_PROC "model name" +#define CPUINFO_PROC {"model name"}#ifndef __NR_perf_event_open# define __NR_perf_event_open 298#endif
@@ -47,14 +47,14 @@#define mb () asm volatile ("sync" ::: "memory")#define wmb () asm volatile ("sync" ::: "memory")#define rmb () asm volatile ("sync" ::: "memory") -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"}#endif #ifdef __s390__#define mb () asm volatile("bcr 15,0" ::: "memory")#define wmb () asm volatile("bcr 15,0" ::: "memory")#define rmb () asm volatile("bcr 15,0" ::: "memory") -#define CPUINFO_PROC "vendor_id" +#define CPUINFO_PROC {"vendor_id"}#endif #ifdef __sh__
@@ -67,14 +67,14 @@# define wmb () asm volatile("" ::: "memory")# define rmb () asm volatile("" ::: "memory")#endif -#define CPUINFO_PROC "cpu type" +#define CPUINFO_PROC {"cpu type"}#endif #ifdef __hppa__#define mb () asm volatile("" ::: "memory")#define wmb () asm volatile("" ::: "memory")#define rmb () asm volatile("" ::: "memory") -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"}#endif #ifdef __sparc__
@@ -87,14 +87,14 @@#endif #define wmb () asm volatile("":::"memory")#define rmb () asm volatile("":::"memory") -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"}#endif #ifdef __alpha__#define mb () asm volatile("mb" ::: "memory")#define wmb () asm volatile("wmb" ::: "memory")#define rmb () asm volatile("mb" ::: "memory") -#define CPUINFO_PROC "cpu model" +#define CPUINFO_PROC {"cpu model"}#endif #ifdef __ia64__
@@ -102,7 +102,7 @@#define wmb () asm volatile ("mf" ::: "memory")#define rmb () asm volatile ("mf" ::: "memory")#define cpu_relax () asm volatile ("hint @pause" ::: "memory") -#define CPUINFO_PROC "model name" +#define CPUINFO_PROC {"model name"}#endif #ifdef __arm__
@@ -113,7 +113,7 @@#define mb () ((void(*)(void))0xffff0fa0)()#define wmb () ((void(*)(void))0xffff0fa0)()#define rmb () ((void(*)(void))0xffff0fa0)() -#define CPUINFO_PROC "Processor" +#define CPUINFO_PROC {"model name", "Processor"}#endif #ifdef __aarch64__
@@ -133,28 +133,28 @@ : "memory")#define wmb () mb()#define rmb () mb() -#define CPUINFO_PROC "cpu model" +#define CPUINFO_PROC {"cpu model"}#endif #ifdef __arc__#define mb () asm volatile("" ::: "memory")#define wmb () asm volatile("" ::: "memory")#define rmb () asm volatile("" ::: "memory") -#define CPUINFO_PROC "Processor" +#define CPUINFO_PROC {"Processor"}#endif #ifdef __metag__#define mb () asm volatile("" ::: "memory")#define wmb () asm volatile("" ::: "memory")#define rmb () asm volatile("" ::: "memory") -#define CPUINFO_PROC "CPU" +#define CPUINFO_PROC {"CPU"}#endif #ifdef __xtensa__#define mb () asm volatile("memw" ::: "memory")#define wmb () asm volatile("memw" ::: "memory")#define rmb () asm volatile("" ::: "memory") -#define CPUINFO_PROC "core ID" +#define CPUINFO_PROC {"core ID"}#endif #ifdef __tile__
@@ -162,7 +162,7 @@#define wmb () asm volatile ("mf" ::: "memory")#define rmb () asm volatile ("mf" ::: "memory")#define cpu_relax () asm volatile ("mfspr zero, PASS" ::: "memory") -#define CPUINFO_PROC "model name" +#define CPUINFO_PROC {"model name"}#endif #define barrier () asm volatile ("" ::: "memory")
tools/perf/util/header.c +21 -6
@@ -579,16 +579,12 @@ static int write_version(int fd, struct perf_header *h __maybe_unused,return do_write_string (fd, perf_version_string); } -static int write_cpudesc (int fd,struct perf_header *h__maybe_unused , -struct perf_evlist *evlist__maybe_unused ) +static int __write_cpudesc (int fd,const char *cpuinfo_proc) { -#ifndef CPUINFO_PROC -#define CPUINFO_PROC NULL -#endif FILE *file;char *buf =NULL ;char *s, *p; -const char *search =CPUINFO_PROC ; +const char *search = cpuinfo_proc;size_t len =0 ;int ret =-1 ;
@@ -638,6 +634,25 @@ static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,return ret; } +static int write_cpudesc (int fd,struct perf_header *h__maybe_unused , +struct perf_evlist *evlist__maybe_unused ) +{ +#ifndef CPUINFO_PROC +#define CPUINFO_PROC {"model name", } +#endif +const char *cpuinfo_procs[] =CPUINFO_PROC ; +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (cpuinfo_procs); i++) { +int ret; + ret =__write_cpudesc (fd, cpuinfo_procs[i]); +if (ret >=0 ) +return ret; + } +return -1 ; +} + +static int write_nrcpus (int fd,struct perf_header *h__maybe_unused ,struct perf_evlist *evlist__maybe_unused ) {
tools/perf/util/sort.c +76 -26
189 lines not on this page · raw message
tools/perf/util/thread.c +3 -0
@@ -117,6 +117,9 @@ int __thread__set_comm(struct thread *thread, const char *str, u64 timestamp,if (!new)return -ENOMEM ;list_add (&new->list, &thread->comm_list); + +if (exec) +unwind__flush_access (thread); } thread->comm_set = true;
tools/perf/util/unwind-libunwind.c +12 -0
@@ -539,11 +539,23 @@ int unwind__prepare_access(struct thread *thread)return -ENOMEM ; } +unw_set_caching_policy (addr_space,UNW_CACHE_GLOBAL );thread__set_priv (thread, addr_space);return 0 ; } +void unwind__flush_access (struct thread *thread) +{ +unw_addr_space_t addr_space; + +if (callchain_param.record_mode !=CALLCHAIN_DWARF ) +return ; + + addr_space =thread__priv (thread); +unw_flush_cache (addr_space,0 ,0 ); +} +void unwind__finish_access (struct thread *thread) {unw_addr_space_t addr_space;
tools/perf/util/unwind.h +3 -0
@@ -23,6 +23,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,#ifdef HAVE_LIBUNWIND_SUPPORT int libunwind__arch_reg_id (int regnum);int unwind__prepare_access (struct thread *thread); +void unwind__flush_access (struct thread *thread);void unwind__finish_access (struct thread *thread);#else static inline int unwind__prepare_access (struct thread *thread__maybe_unused )
@@ -30,6 +31,7 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused) return 0; } +static inline void unwind__flush_access (struct thread *thread__maybe_unused ) {}static inline void unwind__finish_access (struct thread *thread__maybe_unused ) {}#endif #else
@@ -49,6 +51,7 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)return 0 ; } +static inline void unwind__flush_access (struct thread *thread__maybe_unused ) {}static inline void unwind__finish_access (struct thread *thread__maybe_unused ) {}#endif /* HAVE_DWARF_UNWIND_SUPPORT */ #endif /* __UNWIND_H */
Peter,
Quoted 11 lines · Ingo Molnar
Please pull the latest perf-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-for-linus # HEAD: d785452c9972fac2808479eb561d5c426b6e7d3b Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent[...]
Peter Zijlstra (2):
[...]
perf/x86: Fix compile warnings forintel_uncore
This was included in v3.18-rc3.
arch/x86/Kconfig config INSTRUCTION_DECODER · line 147
Quoted 11 lines
arch/x86/Kconfig +3
-0@@ -142,6 +142,10 @@ config INSTRUCTION_DECODER def_bool y depends on KPROBES || PERF_EVENTS || UPROBES +config PERF_EVENTS_INTEL_UNCORE + def_bool y + depends on PERF_EVENTS && SUP_SUP_INTEL && PCI
Andi spotted this typo (see https://lkml.org/lkml/2014/10/28/455 ). So did my local perl script when it hit next-20141029. But since this was already discussed I didn't bother to mention it too.
One expects this to be fixed by s/SUP_SUP_INTEL/CPU_SUP_INTEL/. Perhaps the fix is more complicated, but anyhow, the typo isn't fixed in next-20141103 or, as far as I can tell, in tip.git. So I decided to remind you to make sure this doesn't fall through the cracks.
arch/x86/Kconfig config INSTRUCTION_DECODER · line 151
Quoted 4 lines
arch/x86/Kconfig +1
-0+ config OUTPUT_FORMAT string default "elf32-i386" if X86_32
Paul Bolle
Peter Zijlstra
maintainerQuoted 5 lines · Paul Bolle
arch/x86/Kconfig config INSTRUCTION_DECODER · line 147
Quoted 3 lines
arch/x86/Kconfig +3
-0+config PERF_EVENTS_INTEL_UNCORE + def_bool y + depends on PERF_EVENTS && SUP_SUP_INTEL && PCIOne expects this to be fixed by s/SUP_SUP_INTEL/CPU_SUP_INTEL/.
Yeah, I have that fixed; lemme try and get it in tip.