perf fixes and updates
Subsystems (2)
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: 05f5ece76a88a2cd4859bc93f90379733dd8b4a3 Merge tag 'perf-core-for-mingo-20160323' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
[ Note: this pull request depends on the previous x86/urgent pull request I just
sent - if you have not pulled x86/urgent then please disregard this one. ]
This tree contains various perf fixes on the kernel side, plus 3 hw/event-enablement late additions:
- Intel Memory Bandwidth Monitoring events and handling
- the AMD Accumulated Power Mechanism reporting facility
- more IOMMU events
... and a final round of perf tooling updates/fixes.
Thanks,
Ingo
------------------>
Andi Kleen (1):
perf list: Fix documentation of :ppp
Arnaldo Carvalho de Melo (18):
tools: Move utilities.mak from perf to tools/scripts/
perf tools: Remove misplaced __maybe_unused
perf tests: Forward the perf_sample in the dwarf unwind test perf tools: Add cpumode to struct perf_sample
perf machine: Rename perf_event__preprocess_sample to machine__resolve perf thread: Rename perf_event__preprocess_sample_addr to thread__resolve perf script: Remove lots of unused arguments
perf tools: Remove unused DIE_IF macro
perf tools: Simplify die() mechanism
perf tools: Remove needless 'extern' from function prototypes tools include: Copy linux/stringify.h from the kernel
perf tools: Do not include stringify.h from the kernel sources perf tools: Remove unused perf_pathdup, xstrdup functions perf help: Use asprintf instead of adhoc equivalents
perf probe: No need to use formatting strbuf method
perf tools: Unexport some methods unused outside strbuf.c perf llvm: Use realpath to canonicalize paths
perf llvm: Use strerror_r instead of the thread unsafe strerror one
Huang Rui (3):
perf/x86/amd: Move nodes_per_socket into bsp_init_amd() x86/cpufeature, perf/x86: Add AMD Accumulated Power Mechanism feature flag perf/x86/amd/power: Add AMD accumulated power reporting mechanism
Jakub Jelen (1):
perf bench numa: Fix assertion for nodes bitfield
Kan Liang (1):
perf/x86/intel/uncore: Remove ev_sel_ext bit support for PCU
Peter Zijlstra (9):
perf/core: Fix the unthrottle logic perf/x86/ibs: Fix IBS throttle
perf/x86/ibs: Fix race with IBS_STARTING state perf/x86/ibs: Add IBS interrupt to the dynamic throttle perf/core: Fix dynamic interrupt throttle perf/x86/BTS: Fix RCU usage
perf/core: Fix Undefined behaviour in rb_alloc() perf/x86/cqm: Factor out some common code perf/core: Document some hotplug bits
Srinivas Pandruvada (1):
perf/x86/intel/rapl: Add missing Broadwell models
Steven Rostedt (1):
tools lib traceevent: Remove redundant CPU output
Sukadev Bhattiprolu (1):
perf test: Remove 'core_id' check in topo test
Suravee Suthikulpanit (1):
perf/x86/amd: Add support for new IOMMU performance events
Tony Luck (1):
perf/x86/mbm: Add memory bandwidth monitoring event management
Vikas Shivappa (5):
perf/x86/cqm: Fix CQM handling of grouping events into a cache_group perf/x86/cqm: Fix CQM memory leak and notifier leak perf/x86/mbm: Add Intel Memory B/W Monitoring enumeration and init perf/x86/mbm: Implement RMID recycling
perf/x86/mbm: Add support for MBM counter overflow handling
Wang Nan (1):
perf symbols: Record text offset in dso to calculate objdump address
arch/x86/Kconfig | 9 +
arch/x86/events/Makefile | 1 +
arch/x86/events/amd/ibs.c | 37 ++-
arch/x86/events/amd/iommu.c | 5 +
arch/x86/events/amd/power.c | 353 +++++++++++++++++++++
arch/x86/events/core.c | 4 +-
arch/x86/events/intel/cqm.c | 454 +++++++++++++++++++++++++--
arch/x86/events/intel/ds.c | 5 +-
arch/x86/events/intel/rapl.c | 2 +
arch/x86/events/intel/uncore_snbep.c | 7 +-
arch/x86/include/asm/cpufeatures.h | 4 +-
arch/x86/kernel/cpu/amd.c | 18 +-
arch/x86/kernel/cpu/common.c | 4 +-
include/linux/perf_event.h | 5 +
kernel/events/core.c | 114 ++++---
kernel/events/ring_buffer.c | 6 +-
tools/include/linux/stringify.h | 12 +
tools/lib/api/Makefile | 2 +-
tools/lib/subcmd/Makefile | 2 +-
tools/lib/traceevent/event-parse.c | 4 +-
tools/perf/Documentation/Makefile | 2 +-
tools/perf/Documentation/perf-list.txt | 6 +-
tools/perf/Makefile.perf | 2 +-
tools/perf/arch/powerpc/util/header.c | 4 +-
tools/perf/bench/bench.h | 22 +-
tools/perf/bench/mem-memcpy-arch.h | 2 +-
tools/perf/bench/mem-memset-arch.h | 2 +-
tools/perf/bench/numa.c | 2 +-
tools/perf/builtin-annotate.c | 2 +-
tools/perf/builtin-diff.c | 2 +-
tools/perf/builtin-help.c | 69 ++--
tools/perf/builtin-inject.c | 8 +-
tools/perf/builtin-mem.c | 2 +-
tools/perf/builtin-report.c | 3 +-
tools/perf/builtin-script.c | 46 ++-
tools/perf/builtin-timechart.c | 2 +-
tools/perf/builtin-top.c | 8 +-
tools/perf/builtin-trace.c | 9 +-
tools/perf/builtin.h | 64 ++--
tools/perf/config/Makefile | 2 +-
tools/perf/tests/code-reading.c | 5 +-
tools/perf/tests/dwarf-unwind.c | 4 +-
tools/perf/tests/hists_common.c | 6 +-
tools/perf/tests/hists_cumulate.c | 9 +-
tools/perf/tests/hists_filter.c | 9 +-
tools/perf/tests/hists_link.c | 20 +-
tools/perf/tests/hists_output.c | 9 +-
tools/perf/ui/gtk/hists.c | 2 +-
tools/perf/util/Build | 1 -
tools/perf/util/abspath.c | 37 ---
tools/perf/util/annotate.h | 2 +-
tools/perf/util/auxtrace.h | 2 +-
tools/perf/util/build-id.c | 3 +-
tools/perf/util/cache.h | 24 +-
tools/perf/util/callchain.h | 4 +-
tools/perf/util/cgroup.h | 4 +-
tools/perf/util/cloexec.h | 2 +-
tools/perf/util/data-convert-bt.c | 2 +-
tools/perf/util/db-export.c | 2 +-
tools/perf/util/dso.h | 3 +-
tools/perf/util/dwarf-aux.c | 10 +-
tools/perf/util/dwarf-aux.h | 72 +++--
tools/perf/util/event.c | 23 +-
tools/perf/util/event.h | 13 +-
tools/perf/util/evsel.c | 1 +
tools/perf/util/genelf.h | 8 +-
tools/perf/util/header.c | 5 -
tools/perf/util/header.h | 2 +-
tools/perf/util/hist.c | 2 +-
tools/perf/util/hist.h | 3 +-
tools/perf/util/intel-bts.c | 2 +-
tools/perf/util/jit.h | 12 +-
tools/perf/util/llvm-utils.c | 24 +-
tools/perf/util/llvm-utils.h | 7 +-
tools/perf/util/machine.c | 14 +-
tools/perf/util/machine.h | 2 +-
tools/perf/util/parse-events.h | 21 +-
tools/perf/util/path.c | 30 --
tools/perf/util/probe-event.c | 2 +-
tools/perf/util/probe-event.h | 57 ++--
tools/perf/util/probe-finder.c | 8 +-
tools/perf/util/probe-finder.h | 24 +-
tools/perf/util/quote.h | 2 +-
tools/perf/util/session.c | 5 +-
tools/perf/util/sort.c | 2 +-
tools/perf/util/stat-shadow.c | 18 +-
tools/perf/util/strbuf.c | 9 +-
tools/perf/util/strbuf.h | 21 +-
tools/perf/util/svghelper.h | 51 ++-
tools/perf/util/symbol-elf.c | 12 +-
tools/perf/util/symbol.h | 4 +-
tools/perf/util/usage.c | 8 +-
tools/perf/util/util.h | 27 +-
tools/perf/util/wrapper.c | 12 -
tools/{perf/config => scripts}/utilities.mak | 0
95 files changed, 1336 insertions(+), 634 deletions(-)
create mode 100644 arch/x86/events/amd/power.c
create mode 100644 tools/include/linux/stringify.h
delete mode 100644 tools/perf/util/abspath.c
rename tools/{perf/config => scripts}/utilities.mak (100%)arch/x86/Kconfig +9 -0
@@ -1206,6 +1206,15 @@ config MICROCODE_OLD_INTERFACE def_bool y depends on MICROCODE +config PERF_EVENTS_AMD_POWER + depends on PERF_EVENTS && CPU_SUP_AMD + tristate "AMD Processor Power Reporting Mechanism" + ---help--- + Provide power reporting mechanism support for AMD processors. + Currently, it leverages X86_FEATURE_ACC_POWER + (CPUID Fn8000_0007_EDX[12]) interface to calculate the + average power consumption on Family 15h processors. + config X86_MSR tristate "/dev/cpu/*/msr - Model-specific register support" ---help---
arch/x86/events/Makefile +1 -0
@@ -1,6 +1,7 @@ obj-y += core.o obj-$(CONFIG_CPU_SUP_AMD) += amd/core.o amd/uncore.o +obj-$(CONFIG_PERF_EVENTS_AMD_POWER) += amd/power.o obj-$(CONFIG_X86_LOCAL_APIC) += amd/ibs.o msr.o ifdef CONFIG_AMD_IOMMU obj-$(CONFIG_CPU_SUP_AMD) += amd/iommu.o
arch/x86/events/amd/ibs.c +33 -4
@@ -376,7 +376,13 @@ static void perf_ibs_start(struct perf_event *event, int flags) hwc->state =0 ;perf_ibs_set_period (perf_ibs, hwc, &period); +/* +* Set STARTED before enabling the hardware, such that +* a subsequent NMI must observe it. Then clear STOPPING +* such that we don't consume NMIs by accident. +*/ set_bit (IBS_STARTED , pcpu->state); +clear_bit (IBS_STOPPING , pcpu->state);perf_ibs_enable_event (perf_ibs, hwc, period >>4 );perf_event_update_userpage (event);
@@ -390,7 +396,7 @@ static void perf_ibs_stop(struct perf_event *event, int flags)u64 config;int stopping; - stopping =test_and_clear_bit (IBS_STARTED , pcpu->state); + stopping =test_bit (IBS_STARTED , pcpu->state);if (!stopping && (hwc->state &PERF_HES_UPTODATE ))return ;
@@ -398,8 +404,24 @@ static void perf_ibs_stop(struct perf_event *event, int flags)rdmsrl (hwc->config_base, config);if (stopping) { +/* +* Set STOPPING before disabling the hardware, such that it +* must be visible to NMIs the moment we clear the EN bit, +* at which point we can generate an !VALID sample which +* we need to consume. +*/ set_bit (IBS_STOPPING , pcpu->state);perf_ibs_disable_event (perf_ibs, hwc, config); +/* +* Clear STARTED after disabling the hardware; if it were +* cleared before an NMI hitting after the clear but before +* clearing the EN bit might think it a spurious NMI and not +* handle it. +* +* Clearing it after, however, creates the problem of the NMI +* handler seeing STARTED but not having a valid sample. +*/ +clear_bit (IBS_STARTED , pcpu->state);WARN_ON_ONCE (hwc->state &PERF_HES_STOPPED ); hwc->state |=PERF_HES_STOPPED ; }
@@ -527,20 +549,24 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)u64 *buf, *config, period;if (!test_bit (IBS_STARTED , pcpu->state)) { +fail:/* * Catch spurious interrupts after stopping IBS: After * disabling IBS there could be still incoming NMIs * with samples that even have the valid bit cleared. * Mark all this NMIs as handled. */ -return test_and_clear_bit (IBS_STOPPING , pcpu->state) ?1 :0 ; +if (test_and_clear_bit (IBS_STOPPING , pcpu->state)) +return 1 ; + +return 0 ; } msr = hwc->config_base; buf = ibs_data.regs;rdmsrl (msr, *buf);if (!(*buf++ & perf_ibs->valid_mask)) -return 0 ; + goto fail; config = &ibs_data.regs[0 ];perf_ibs_event_update (perf_ibs, event, config);
@@ -599,7 +625,7 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs) throttle =perf_event_overflow (event, &data, ®s); out:if (throttle) -perf_ibs_disable_event (perf_ibs, hwc, *config); +perf_ibs_stop (event,0 );else perf_ibs_enable_event (perf_ibs, hwc, period >>4 );
@@ -611,6 +637,7 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)static int perf_ibs_nmi_handler (unsigned int cmd,struct pt_regs *regs) { +u64 stamp =sched_clock ();int handled =0 ; handled +=perf_ibs_handle_irq (&perf_ibs_fetch, regs);
@@ -619,6 +646,8 @@ perf_ibs_nmi_handler(unsigned int cmd, struct pt_regs *regs)if (handled)inc_irq_stat (apic_perf_irqs); +perf_sample_event_took (sched_clock () - stamp); +return handled; }NOKPROBE_SYMBOL (perf_ibs_nmi_handler);
arch/x86/events/amd/iommu.c +5 -0
@@ -118,6 +118,11 @@ static struct amd_iommu_event_desc amd_iommu_v2_event_descs[] = {AMD_IOMMU_EVENT_DESC (cmd_processed,"csource=0x11" ),AMD_IOMMU_EVENT_DESC (cmd_processed_inv,"csource=0x12" ),AMD_IOMMU_EVENT_DESC (tlb_inv,"csource=0x13" ), +AMD_IOMMU_EVENT_DESC (ign_rd_wr_mmio_1ff8h,"csource=0x14" ), +AMD_IOMMU_EVENT_DESC (vapic_int_non_guest,"csource=0x15" ), +AMD_IOMMU_EVENT_DESC (vapic_int_guest,"csource=0x16" ), +AMD_IOMMU_EVENT_DESC (smi_recv,"csource=0x17" ), + AMD_IOMMU_EVENT_DESC(smi_blk, "csource=0x18"), { /* end: all zeroes */ }, };
arch/x86/events/amd/power.c new file +353 -0
353 lines not on this page · raw message
arch/x86/events/core.c +2 -2
@@ -1602,8 +1602,7 @@ __init struct attribute **merge_attr(struct attribute **a, struct attribute **b)return new; } -ssize_t events_sysfs_show (struct device *dev,struct device_attribute *attr, -char *page) +ssize_t events_sysfs_show (struct device *dev,struct device_attribute *attr,char *page) {struct perf_pmu_events_attr *pmu_attr = \ container_of(attr, struct perf_pmu_events_attr, attr);
@@ -1615,6 +1614,7 @@ ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr,return x86_pmu.events_sysfs_show (page, config); } +EXPORT_SYMBOL_GPL (events_sysfs_show);EVENT_ATTR (cpu-cycles,CPU_CYCLES );EVENT_ATTR (instructions,INSTRUCTIONS );
arch/x86/events/intel/cqm.c +431 -23
662 lines not on this page · raw message
arch/x86/events/intel/ds.c +4 -1
@@ -570,11 +570,12 @@ int intel_pmu_drain_bts_buffer(void)* We will overwrite the from and to address before we output * the sample. */ +rcu_read_lock ();perf_prepare_sample (&header, &data, event, ®s);if (perf_output_begin (&handle, event, header.size * (top - base - skip))) -return 1 ; + goto unlock;for (at = base; at < top; at++) {/* Filter out any records that contain kernel addresses. */
@@ -593,6 +594,8 @@ int intel_pmu_drain_bts_buffer(void)/* There's new data available. */ event->hw.interrupts++; event->pending_kill =POLL_IN ; +unlock: +rcu_read_unlock ();return 1 ; }
arch/x86/events/intel/rapl.c +2 -0
@@ -711,6 +711,7 @@ static int __init rapl_pmu_init(void) rapl_pmu_events_group.attrs = rapl_events_cln_attr;break ;case 63 :/* Haswell-Server */ +case 79 :/* Broadwell-Server */ apply_quirk = true; rapl_cntr_mask =RAPL_IDX_SRV ; rapl_pmu_events_group.attrs = rapl_events_srv_attr;
@@ -718,6 +719,7 @@ static int __init rapl_pmu_init(void)case 60 :/* Haswell */ case 69 :/* Haswell-Celeron */ case 61 :/* Broadwell */ +case 71 :/* Broadwell-H */ rapl_cntr_mask =RAPL_IDX_HSW ; rapl_pmu_events_group.attrs = rapl_events_hsw_attr;break ;
arch/x86/events/intel/uncore_snbep.c +2 -5
@@ -46,7 +46,6 @@ (SNBEP_PMON_CTL_EV_SEL_MASK | \ SNBEP_PCU_MSR_PMON_CTL_OCC_SEL_MASK | \ SNBEP_PMON_CTL_EDGE_DET | \ - SNBEP_PMON_CTL_EV_SEL_EXT | \ SNBEP_PMON_CTL_INVERT | \ SNBEP_PCU_MSR_PMON_CTL_TRESH_MASK | \ SNBEP_PCU_MSR_PMON_CTL_OCC_INVERT | \
@@ -148,7 +147,6 @@/* IVBEP PCU */ #define IVBEP_PCU_MSR_PMON_RAW_EVENT_MASK \ (SNBEP_PMON_CTL_EV_SEL_MASK | \ - SNBEP_PMON_CTL_EV_SEL_EXT | \ SNBEP_PCU_MSR_PMON_CTL_OCC_SEL_MASK | \ SNBEP_PMON_CTL_EDGE_DET | \ SNBEP_PCU_MSR_PMON_CTL_TRESH_MASK | \
@@ -258,7 +256,6 @@SNBEP_PCU_MSR_PMON_CTL_OCC_SEL_MASK | \SNBEP_PMON_CTL_EDGE_DET | \SNBEP_CBO_PMON_CTL_TID_EN | \ -SNBEP_PMON_CTL_EV_SEL_EXT | \SNBEP_PMON_CTL_INVERT | \KNL_PCU_MSR_PMON_CTL_TRESH_MASK | \ SNBEP_PCU_MSR_PMON_CTL_OCC_INVERT | \
@@ -472,7 +469,7 @@ static struct attribute *snbep_uncore_cbox_formats_attr[] = { };static struct attribute *snbep_uncore_pcu_formats_attr[] = { - &format_attr_event_ext.attr, + &format_attr_event.attr, &format_attr_occ_sel.attr, &format_attr_edge.attr, &format_attr_inv.attr,
@@ -1313,7 +1310,7 @@ static struct attribute *ivbep_uncore_cbox_formats_attr[] = { };static struct attribute *ivbep_uncore_pcu_formats_attr[] = { - &format_attr_event_ext.attr, + &format_attr_event.attr, &format_attr_occ_sel.attr, &format_attr_edge.attr, &format_attr_thresh5.attr,
arch/x86/include/asm/cpufeatures.h +3 -1
@@ -94,7 +94,7 @@#define X86_FEATURE_REP_GOOD ( 3*32+16)/* rep microcode works well */ #define X86_FEATURE_MFENCE_RDTSC ( 3*32+17)/* "" Mfence synchronizes RDTSC */ #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18)/* "" Lfence synchronizes RDTSC */ -/* free, was #define X86_FEATURE_11AP ( 3*32+19) * "" Bad local APIC aka 11AP */ +#define X86_FEATURE_ACC_POWER ( 3*32+19)/* AMD Accumulated Power Mechanism */ #define X86_FEATURE_NOPL ( 3*32+20)/* The NOPL (0F 1F) instructions */ #define X86_FEATURE_ALWAYS ( 3*32+21)/* "" Always-present feature */ #define X86_FEATURE_XTOPOLOGY ( 3*32+22)/* cpu topology enum extensions */
@@ -245,6 +245,8 @@/* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:1 (edx), word 12 */ #define X86_FEATURE_CQM_OCCUP_LLC (12*32+ 0)/* LLC occupancy monitoring if 1 */ +#define X86_FEATURE_CQM_MBM_TOTAL (12*32+ 1)/* LLC Total MBM monitoring */ +#define X86_FEATURE_CQM_MBM_LOCAL (12*32+ 2)/* LLC Local MBM monitoring */ /* AMD-defined CPU features, CPUID level 0x80000008 (ebx), word 13 */ #define X86_FEATURE_CLZERO (13*32+0)/* CLZERO instruction */
arch/x86/kernel/cpu/amd.c +16 -2
@@ -306,7 +306,6 @@ static void amd_get_topology(struct cpuinfo_x86 *c)u32 eax, ebx, ecx, edx;cpuid (0x8000001e , &eax, &ebx, &ecx, &edx); - nodes_per_socket = ((ecx >>8 ) &7 ) +1 ; node_id = ecx &7 ;/* get compute unit information */
@@ -317,7 +316,6 @@ static void amd_get_topology(struct cpuinfo_x86 *c)u64 value;rdmsrl (MSR_FAM10H_NODE_ID , value); - nodes_per_socket = ((value >>3 ) &7 ) +1 ; node_id = value &7 ; }else return ;
@@ -519,6 +517,18 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)if (cpu_has (c,X86_FEATURE_MWAITX ))use_mwaitx_delay (); + +if (boot_cpu_has (X86_FEATURE_TOPOEXT )) { +u32 ecx; + + ecx =cpuid_ecx (0x8000001e ); + nodes_per_socket = ((ecx >>8 ) &7 ) +1 ; + }else if (boot_cpu_has (X86_FEATURE_NODEID_MSR )) { +u64 value; + +rdmsrl (MSR_FAM10H_NODE_ID , value); + nodes_per_socket = ((value >>3 ) &7 ) +1 ; + } }static void early_init_amd (struct cpuinfo_x86 *c)
@@ -536,6 +546,10 @@ static void early_init_amd(struct cpuinfo_x86 *c)set_sched_clock_stable (); } +/* Bit 12 of 8000_0007 edx is accumulated power mechanism. */ +if (c->x86_power &BIT (12 )) +set_cpu_cap (c,X86_FEATURE_ACC_POWER ); +#ifdef CONFIG_X86_64 set_cpu_cap (c,X86_FEATURE_SYSCALL32 );#else
arch/x86/kernel/cpu/common.c +3 -1
@@ -649,7 +649,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c)cpuid_count (0x0000000F ,1 , &eax, &ebx, &ecx, &edx); c->x86_capability[CPUID_F_1_EDX ] = edx; -if (cpu_has (c,X86_FEATURE_CQM_OCCUP_LLC )) { +if ((cpu_has (c,X86_FEATURE_CQM_OCCUP_LLC )) || + ((cpu_has (c,X86_FEATURE_CQM_MBM_TOTAL )) || + (cpu_has (c,X86_FEATURE_CQM_MBM_LOCAL )))) { c->x86_cache_max_rmid = ecx; c->x86_cache_occ_scale = ebx; }
include/linux/perf_event.h +5 -0
@@ -121,6 +121,7 @@ struct hw_perf_event {struct {/* intel_cqm */ int cqm_state;u32 cqm_rmid; +int is_group_event;struct list_head cqm_events_entry;struct list_head cqm_groups_entry;struct list_head cqm_group_entry;
@@ -128,6 +129,10 @@ struct hw_perf_event {struct {/* itrace */ int itrace_started; }; +struct {/* amd_power */ +u64 pwr_acc; +u64 ptsc; + }; #ifdef CONFIG_HAVE_HW_BREAKPOINT struct { /* breakpoint */ /*
kernel/events/core.c +78 -36
171 lines not on this page · raw message
kernel/events/ring_buffer.c +4 -2
@@ -746,8 +746,10 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags) rb->user_page = all_buf; rb->data_pages[0 ] = all_buf +PAGE_SIZE ; - rb->page_order =ilog2 (nr_pages); - rb->nr_pages = !!nr_pages; +if (nr_pages) { + rb->nr_pages =1 ; + rb->page_order =ilog2 (nr_pages); + }ring_buffer_init (rb, watermark, flags);
tools/include/linux/stringify.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __LINUX_STRINGIFY_H +#define __LINUX_STRINGIFY_H + +/* Indirect stringification. Doing two levels allows the parameter to be a +* macro itself. For example, compile with -DFOO=bar, __stringify(FOO) +* converts to "bar". +*/ + +#define __stringify_1(x...) #x +#define __stringify(x...) __stringify_1(x) + +#endif /* !__LINUX_STRINGIFY_H */
tools/lib/api/Makefile +1 -1
@@ -1,5 +1,5 @@ include ../../scripts/Makefile.include -include ../../perf/config/utilities.mak # QUIET_CLEAN +include ../../scripts/utilities.mak # QUIET_CLEAN ifeq ($(srctree),) srctree := $(patsubst %/,%,$(dir $(shell pwd)))
tools/lib/subcmd/Makefile +1 -1
@@ -1,5 +1,5 @@ include ../../scripts/Makefile.include -include ../../perf/config/utilities.mak # QUIET_CLEAN +include ../../scripts/utilities.mak # QUIET_CLEAN ifeq ($(srctree),) srctree := $(patsubst %/,%,$(dir $(shell pwd)))
tools/lib/traceevent/event-parse.c +1 -3
@@ -5427,10 +5427,8 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, }if (pevent->latency_format) { -trace_seq_printf (s," %3d" , record->cpu);pevent_data_lat_fmt (pevent, s, record); - }else -trace_seq_printf (s," [%03d]" , record->cpu); + }if (use_usec_format) {if (pevent->flags &PEVENT_NSEC_OUTPUT ) {
tools/perf/Documentation/Makefile +1 -1
@@ -1,5 +1,5 @@ include ../../scripts/Makefile.include -include ../config/utilities.mak +include ../../scripts/utilities.mak MAN1_TXT= \ $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
tools/perf/Documentation/perf-list.txt +4 -2
@@ -40,10 +40,12 @@ The 'p' modifier can be used for specifying how precise the instruction 0 - SAMPLE_IP can have arbitrary skid 1 - SAMPLE_IP must have constant skid 2 - SAMPLE_IP requested to have 0 skid - 3 - SAMPLE_IP must have 0 skid + 3 - SAMPLE_IP must have 0 skid, or uses randomization to avoid + sample shadowing effects. For Intel systems precise event sampling is implemented with PEBS -which supports up to precise-level 2. +which supports up to precise-level 2, and precise level 3 for +some special cases On AMD systems it is implemented using IBS (up to precise-level 2). The precise modifier works with event types 0x76 (cpu-cycles, CPU
tools/perf/Makefile.perf +1 -1
@@ -3,7 +3,7 @@ include ../scripts/Makefile.include # The default target of this Makefile is... all: -include config/utilities.mak +include ../scripts/utilities.mak # Define V to have a more verbose compile. #
tools/perf/arch/powerpc/util/header.c +1 -3
@@ -3,9 +3,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> - -#include "../../util/header.h" -#include "../../util/util.h" +#include <linux/stringify.h> #define mfspr (rn) ({unsigned long rval; \ asm volatile("mfspr %0," __stringify(rn) \
tools/perf/bench/bench.h +10 -12
@@ -25,19 +25,17 @@# endif #endif -extern int bench_numa (int argc,const char **argv,const char *prefix); -extern int bench_sched_messaging (int argc,const char **argv,const char *prefix); -extern int bench_sched_pipe (int argc,const char **argv,const char *prefix); -extern int bench_mem_memcpy (int argc,const char **argv, -const char *prefix__maybe_unused ); -extern int bench_mem_memset (int argc,const char **argv,const char *prefix); -extern int bench_futex_hash (int argc,const char **argv,const char *prefix); -extern int bench_futex_wake (int argc,const char **argv,const char *prefix); -extern int bench_futex_wake_parallel (int argc,const char **argv, -const char *prefix); -extern int bench_futex_requeue (int argc,const char **argv,const char *prefix); +int bench_numa (int argc,const char **argv,const char *prefix); +int bench_sched_messaging (int argc,const char **argv,const char *prefix); +int bench_sched_pipe (int argc,const char **argv,const char *prefix); +int bench_mem_memcpy (int argc,const char **argv,const char *prefix); +int bench_mem_memset (int argc,const char **argv,const char *prefix); +int bench_futex_hash (int argc,const char **argv,const char *prefix); +int bench_futex_wake (int argc,const char **argv,const char *prefix); +int bench_futex_wake_parallel (int argc,const char **argv,const char *prefix); +int bench_futex_requeue (int argc,const char **argv,const char *prefix);/* pi futexes */ -extern int bench_futex_lock_pi (int argc,const char **argv,const char *prefix); +int bench_futex_lock_pi (int argc,const char **argv,const char *prefix);#define BENCH_FORMAT_DEFAULT_STR "default"#define BENCH_FORMAT_DEFAULT 0
tools/perf/bench/mem-memcpy-arch.h +1 -1
@@ -2,7 +2,7 @@#ifdef HAVE_ARCH_X86_64_SUPPORT #define MEMCPY_FN (fn, name, desc) \ - extern void *fn(void *, const void *, size_t); + void *fn(void *, const void *, size_t);#include "mem-memcpy-x86-64-asm-def.h"
tools/perf/bench/mem-memset-arch.h +1 -1
@@ -2,7 +2,7 @@#ifdef HAVE_ARCH_X86_64_SUPPORT #define MEMSET_FN (fn, name, desc) \ - extern void *fn(void *, int, size_t); + void *fn(void *, int, size_t);#include "mem-memset-x86-64-asm-def.h"
tools/perf/bench/numa.c +1 -1
@@ -293,7 +293,7 @@ static void bind_to_memnode(int node)if (node ==-1 )return ; -BUG_ON (g->p.nr_nodes > (int )sizeof (nodemask)); +BUG_ON (g->p.nr_nodes > (int )sizeof (nodemask)*8 ); nodemask =1L << node; ret =set_mempolicy (MPOL_BIND , &nodemask,sizeof (nodemask)*8 );
tools/perf/builtin-annotate.c +1 -1
@@ -94,7 +94,7 @@ static int process_sample_event(struct perf_tool *tool,struct addr_location al;int ret =0 ; -if (perf_event__preprocess_sample (event, machine, &al, sample) <0 ) { +if (machine__resolve (machine, &al, sample) <0 ) {pr_warning ("problem processing %d event, skipping it.\n" , event->header.type);return -1 ;
tools/perf/builtin-diff.c +1 -1
@@ -330,7 +330,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,struct hists *hists =evsel__hists (evsel);int ret =-1 ; -if (perf_event__preprocess_sample (event, machine, &al, sample) <0 ) { +if (machine__resolve (machine, &al, sample) <0 ) {pr_warning ("problem processing %d event, skipping it.\n" , event->header.type);return -1 ;
tools/perf/builtin-help.c +31 -38
141 lines not on this page · raw message
tools/perf/builtin-inject.c +2 -6
@@ -131,8 +131,7 @@ static int copy_bytes(struct perf_inject *inject, int fd, off_t size)static s64 perf_event__repipe_auxtrace (struct perf_tool *tool,union perf_event *event, -struct perf_session *session -__maybe_unused ) +struct perf_session *session) { struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
@@ -417,9 +416,6 @@ static int perf_event__inject_buildid(struct perf_tool *tool, {struct addr_location al;struct thread *thread; -u8 cpumode; - - cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; thread =machine__findnew_thread (machine, sample->pid, sample->tid);if (thread ==NULL ) {
@@ -428,7 +424,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, goto repipe; } -thread__find_addr_map (thread, cpumode,MAP__FUNCTION , sample->ip, &al); +thread__find_addr_map (thread, sample->cpumode,MAP__FUNCTION , sample->ip, &al);if (al.map !=NULL ) {if (!al.map->dso->hit) {
tools/perf/builtin-mem.c +1 -1
@@ -131,7 +131,7 @@ dump_raw_samples(struct perf_tool *tool,struct addr_location al;const char *fmt; -if (perf_event__preprocess_sample (event, machine, &al, sample) <0 ) { +if (machine__resolve (machine, &al, sample) <0 ) {fprintf (stderr,"problem processing %d event, skipping it.\n" , event->header.type);return -1 ;
tools/perf/builtin-report.c +2 -1
@@ -41,6 +41,7 @@#include <dlfcn.h> #include <linux/bitmap.h> +#include <linux/stringify.h> struct report {struct perf_tool tool;
@@ -154,7 +155,7 @@ static int process_sample_event(struct perf_tool *tool, };int ret =0 ; -if (perf_event__preprocess_sample (event, machine, &al, sample) <0 ) { +if (machine__resolve (machine, &al, sample) <0 ) {pr_debug ("problem processing %d event, skipping it.\n" , event->header.type);return -1 ;
tools/perf/builtin-script.c +18 -28
139 lines not on this page · raw message
tools/perf/builtin-timechart.c +1 -1
@@ -489,7 +489,7 @@ static const char *cat_backtrace(union perf_event *event,if (!chain) goto exit; -if (perf_event__preprocess_sample (event, machine, &al, sample) <0 ) { +if (machine__resolve (machine, &al, sample) <0 ) {fprintf (stderr,"problem processing %d event, skipping it.\n" , event->header.type); goto exit;
tools/perf/builtin-top.c +3 -5
@@ -67,6 +67,7 @@#include <sys/utsname.h> #include <sys/mman.h> +#include <linux/stringify.h> #include <linux/types.h> static volatile int done;
@@ -728,7 +729,7 @@ static void perf_event__process_sample(struct perf_tool *tool,if (event->header.misc &PERF_RECORD_MISC_EXACT_IP ) top->exact_samples++; -if (perf_event__preprocess_sample (event, machine, &al, sample) <0 ) +if (machine__resolve (machine, &al, sample) <0 )return ; if (!top->kptr_restrict_warned &&
@@ -809,7 +810,6 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)struct perf_session *session = top->session;union perf_event *event;struct machine *machine; -u8 origin;int ret;while ((event =perf_evlist__mmap_read (top->evlist, idx)) !=NULL ) {
@@ -822,12 +822,10 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) evsel =perf_evlist__id2evsel (session->evlist, sample.id);assert (evsel !=NULL ); - origin = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; -if (event->header.type ==PERF_RECORD_SAMPLE ) ++top->samples; -switch (origin) { +switch (sample.cpumode) {case PERF_RECORD_MISC_USER : ++top->us_samples;if (top->hide_user_symbols)
tools/perf/builtin-trace.c +4 -5
@@ -2256,11 +2256,10 @@ static void print_location(FILE *f, struct perf_sample *sample,static int trace__pgfault (struct trace *trace,struct perf_evsel *evsel, -union perf_event *event, +union perf_event *event__maybe_unused ,struct perf_sample *sample) {struct thread *thread; -u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct addr_location al;char map_type ='d' ;struct thread_trace *ttrace;
@@ -2279,7 +2278,7 @@ static int trace__pgfault(struct trace *trace,if (trace->summary_only) goto out; -thread__find_addr_location (thread, cpumode,MAP__FUNCTION , +thread__find_addr_location (thread, sample->cpumode,MAP__FUNCTION , sample->ip, &al);trace__fprintf_entry_head (trace, thread,0 , sample->time, trace->output);
@@ -2292,11 +2291,11 @@ static int trace__pgfault(struct trace *trace,fprintf (trace->output,"] => " ); -thread__find_addr_location (thread, cpumode,MAP__VARIABLE , +thread__find_addr_location (thread, sample->cpumode,MAP__VARIABLE , sample->addr, &al);if (!al.map) { -thread__find_addr_location (thread, cpumode, +thread__find_addr_location (thread, sample->cpumode,MAP__FUNCTION , sample->addr, &al);if (al.map)
tools/perf/builtin.h +32 -32
70 lines not on this page · raw message
tools/perf/config/Makefile +1 -1
@@ -109,7 +109,7 @@ ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET endif -include $(src-perf)/config/utilities.mak +include $(srctree)/tools/scripts/utilities.mak ifeq ($(call get-executable,$(FLEX)),) dummy := $(error Error: $(FLEX) is missing on this system, please install it)
tools/perf/tests/code-reading.c +1 -4
@@ -293,7 +293,6 @@ static int process_sample_event(struct machine *machine, {struct perf_sample sample;struct thread *thread; -u8 cpumode;int ret;if (perf_evlist__parse_sample (evlist, event, &sample)) {
@@ -307,9 +306,7 @@ static int process_sample_event(struct machine *machine,return -1 ; } - cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; - - ret =read_object_code (sample.ip,READLEN , cpumode, thread, state); + ret =read_object_code (sample.ip,READLEN , sample.cpumode, thread, state);thread__put (thread);return ret; }
tools/perf/tests/dwarf-unwind.c +2 -2
@@ -20,10 +20,10 @@static int mmap_handler (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__maybe_unused , +struct perf_sample *sample,struct machine *machine) { -return machine__process_mmap2_event (machine, event,NULL ); +return machine__process_mmap2_event (machine, event, sample); }static int init_live_machine (struct machine *machine)
tools/perf/tests/hists_common.c +4 -2
@@ -100,9 +100,11 @@ struct machine *setup_fake_machine(struct machines *machines) }for (i =0 ; i <ARRAY_SIZE (fake_mmap_info); i++) { +struct perf_sample sample = { + .cpumode =PERF_RECORD_MISC_USER , + };union perf_event fake_mmap_event = { .mmap = { - .header = { .misc =PERF_RECORD_MISC_USER , }, .pid = fake_mmap_info[i].pid, .tid = fake_mmap_info[i].pid, .start = fake_mmap_info[i].start,
@@ -114,7 +116,7 @@ struct machine *setup_fake_machine(struct machines *machines)strcpy (fake_mmap_event.mmap.filename, fake_mmap_info[i].filename); -machine__process_mmap_event (machine, &fake_mmap_event,NULL ); +machine__process_mmap_event (machine, &fake_mmap_event, &sample); }for (i =0 ; i <ARRAY_SIZE (fake_symbols); i++) {
tools/perf/tests/hists_cumulate.c +2 -7
@@ -81,11 +81,6 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)size_t i;for (i =0 ; i <ARRAY_SIZE (fake_samples); i++) { -const union perf_event event = { - .header = { - .misc =PERF_RECORD_MISC_USER , - }, - };struct hist_entry_iter iter = { .evsel = evsel, .sample = &sample,
@@ -97,13 +92,13 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)else iter.ops = &hist_iter_normal; + sample.cpumode =PERF_RECORD_MISC_USER ; sample.pid = fake_samples[i].pid; sample.tid = fake_samples[i].pid; sample.ip = fake_samples[i].ip; sample.callchain = (struct ip_callchain *)fake_callchains[i]; -if (perf_event__preprocess_sample (&event, machine, &al, - &sample) <0 ) +if (machine__resolve (machine, &al, &sample) <0 ) goto out; if (hist_entry_iter__add(&iter, &al, PERF_MAX_STACK_DEPTH,
tools/perf/tests/hists_filter.c +2 -7
@@ -58,11 +58,6 @@ static int add_hist_entries(struct perf_evlist *evlist,*/ evlist__for_each (evlist, evsel) {for (i =0 ; i <ARRAY_SIZE (fake_samples); i++) { -const union perf_event event = { - .header = { - .misc =PERF_RECORD_MISC_USER , - }, - };struct hist_entry_iter iter = { .evsel = evsel, .sample = &sample,
@@ -76,12 +71,12 @@ static int add_hist_entries(struct perf_evlist *evlist, hists->dso_filter =NULL ; hists->symbol_filter_str =NULL ; + sample.cpumode =PERF_RECORD_MISC_USER ; sample.pid = fake_samples[i].pid; sample.tid = fake_samples[i].pid; sample.ip = fake_samples[i].ip; -if (perf_event__preprocess_sample (&event, machine, &al, - &sample) <0 ) +if (machine__resolve (machine, &al, &sample) <0 ) goto out; al.socket = fake_samples[i].socket;
tools/perf/tests/hists_link.c +4 -16
@@ -76,17 +76,12 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)struct hists *hists =evsel__hists (evsel);for (k =0 ; k <ARRAY_SIZE (fake_common_samples); k++) { -const union perf_event event = { - .header = { - .misc =PERF_RECORD_MISC_USER , - }, - }; - + sample.cpumode =PERF_RECORD_MISC_USER ; sample.pid = fake_common_samples[k].pid; sample.tid = fake_common_samples[k].pid; sample.ip = fake_common_samples[k].ip; -if (perf_event__preprocess_sample (&event, machine, &al, - &sample) <0 ) + +if (machine__resolve (machine, &al, &sample) <0 ) goto out; he = __hists__add_entry(hists, &al, NULL,
@@ -102,17 +97,10 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) }for (k =0 ; k <ARRAY_SIZE (fake_samples[i]); k++) { -const union perf_event event = { - .header = { - .misc =PERF_RECORD_MISC_USER , - }, - }; - sample.pid = fake_samples[i][k].pid; sample.tid = fake_samples[i][k].pid; sample.ip = fake_samples[i][k].ip; -if (perf_event__preprocess_sample (&event, machine, &al, - &sample) <0 ) +if (machine__resolve (machine, &al, &sample) <0 ) goto out; he = __hists__add_entry(hists, &al, NULL,
tools/perf/tests/hists_output.c +2 -7
@@ -51,11 +51,6 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)size_t i;for (i =0 ; i <ARRAY_SIZE (fake_samples); i++) { -const union perf_event event = { - .header = { - .misc =PERF_RECORD_MISC_USER , - }, - };struct hist_entry_iter iter = { .evsel = evsel, .sample = &sample,
@@ -63,13 +58,13 @@ static int add_hist_entries(struct hists *hists, struct machine *machine) .hide_unresolved = false, }; + sample.cpumode =PERF_RECORD_MISC_USER ; sample.cpu = fake_samples[i].cpu; sample.pid = fake_samples[i].pid; sample.tid = fake_samples[i].pid; sample.ip = fake_samples[i].ip; -if (perf_event__preprocess_sample (&event, machine, &al, - &sample) <0 ) +if (machine__resolve (machine, &al, &sample) <0 ) goto out; if (hist_entry_iter__add(&iter, &al, PERF_MAX_STACK_DEPTH,
tools/perf/ui/gtk/hists.c +1 -1
@@ -55,7 +55,7 @@ static u64 he_get_acc_##_field(struct hist_entry *he) \return he->stat_acc->_field; \ } \ \ -static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ +static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt, \struct perf_hpp *hpp, \struct hist_entry *he) \ { \
tools/perf/util/Build +0 -1
@@ -1,4 +1,3 @@ -libperf-y += abspath.o libperf-y += alias.o libperf-y += annotate.o libperf-y += build-id.o
tools/perf/util/abspath.c deleted +0 -37
@@ -1,37 +0,0 @@ -#include "cache.h" - -static const char *get_pwd_cwd (void ) -{ -static char cwd[PATH_MAX +1 ]; -char *pwd; -struct stat cwd_stat, pwd_stat; -if (getcwd (cwd,PATH_MAX ) ==NULL ) -return NULL ; - pwd =getenv ("PWD" ); -if (pwd &&strcmp (pwd, cwd)) { -stat (cwd, &cwd_stat); -if (!stat (pwd, &pwd_stat) && - pwd_stat.st_dev == cwd_stat.st_dev && - pwd_stat.st_ino == cwd_stat.st_ino) { -strlcpy (cwd, pwd,PATH_MAX ); - } - } -return cwd; -} - -const char *make_nonrelative_path (const char *path) -{ -static char buf[PATH_MAX +1 ]; - -if (is_absolute_path (path)) { -if (strlcpy (buf, path,PATH_MAX ) >=PATH_MAX ) -die ("Too long path: %.*s" ,60 , path); - }else { -const char *cwd =get_pwd_cwd (); -if (!cwd) -die ("Cannot determine the current working directory" ); -if (snprintf (buf,PATH_MAX ,"%s/%s" , cwd, path) >=PATH_MAX ) -die ("Too long path: %.*s" ,60 , path); - } -return buf; -}
tools/perf/util/annotate.h +1 -1
@@ -158,7 +158,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize);int hist_entry__annotate (struct hist_entry *he,size_t privsize); -int symbol__annotate_init (struct map *map__maybe_unused ,struct symbol *sym); +int symbol__annotate_init (struct map *map,struct symbol *sym);int symbol__annotate_printf (struct symbol *sym,struct map *map,struct perf_evsel *evsel,bool full_paths,int min_pcnt,int max_lines,int context);
tools/perf/util/auxtrace.h +1 -1
@@ -517,7 +517,7 @@ static inline void auxtrace__free(struct perf_session *session)static inline struct auxtrace_record *auxtrace_record__init (struct perf_evlist *evlist__maybe_unused , -int *err__maybe_unused ) +int *err) { *err =0 ;return NULL ;
tools/perf/util/build-id.c +1 -2
@@ -28,7 +28,6 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused, struct machine *machine) {struct addr_location al; -u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct thread *thread =machine__findnew_thread (machine, sample->pid, sample->tid);
@@ -38,7 +37,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,return -1 ; } -thread__find_addr_map (thread, cpumode,MAP__FUNCTION , sample->ip, &al); +thread__find_addr_map (thread, sample->cpumode,MAP__FUNCTION , sample->ip, &al);if (al.map !=NULL ) al.map->dso->hit =1 ;
tools/perf/util/cache.h +10 -14
@@ -26,14 +26,14 @@extern const char *config_exclusive_filename;typedef int (*config_fn_t )(const char *,const char *,void *); -extern int perf_default_config (const char *,const char *,void *); -extern int perf_config (config_fn_t fn,void *); -extern int perf_config_int (const char *,const char *); -extern u64 perf_config_u64 (const char *,const char *); -extern int perf_config_bool (const char *,const char *); -extern int config_error_nonbool (const char *); -extern const char *perf_config_dirname (const char *,const char *); -extern const char *perf_etc_perfconfig (void ); +int perf_default_config (const char *,const char *,void *); +int perf_config (config_fn_t fn,void *); +int perf_config_int (const char *,const char *); +u64 perf_config_u64 (const char *,const char *); +int perf_config_bool (const char *,const char *); +int config_error_nonbool (const char *); +const char *perf_config_dirname (const char *,const char *); +const char *perf_etc_perfconfig (void );char *alias_lookup (const char *alias);int split_cmdline (char *cmdline,const char ***argv);
@@ -64,13 +64,9 @@ static inline int is_absolute_path(const char *path) return path[0] == '/'; } -const char *make_nonrelative_path (const char *path);char *strip_path_suffix (const char *path,const char *suffix); -extern char *mkpath (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); -extern char *perf_path (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); - -extern char *perf_pathdup (const char *fmt, ...) - __attribute__((format (printf,1 ,2 ))); +char *mkpath (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); +char *perf_path (const char *fmt, ...) __attribute__((format (printf,1 ,2 )));#endif /* __PERF_CACHE_H */
tools/perf/util/callchain.h +2 -2
@@ -220,7 +220,7 @@ int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node * bool hide_unresolved);extern const char record_callchain_help[]; -extern int parse_callchain_record (const char *arg,struct callchain_param *param); +int parse_callchain_record (const char *arg,struct callchain_param *param);int parse_callchain_record_opt (const char *arg,struct callchain_param *param);int parse_callchain_report_opt (const char *arg);int parse_callchain_top_opt (const char *arg);
@@ -236,7 +236,7 @@ static inline void callchain_cursor_snapshot(struct callchain_cursor *dest, }#ifdef HAVE_SKIP_CALLCHAIN_IDX -extern int arch_skip_callchain_idx (struct thread *thread,struct ip_callchain *chain); +int arch_skip_callchain_idx (struct thread *thread,struct ip_callchain *chain);#else static inline int arch_skip_callchain_idx (struct thread *thread__maybe_unused ,struct ip_callchain *chain__maybe_unused )
tools/perf/util/cgroup.h +2 -2
@@ -13,7 +13,7 @@ struct cgroup_sel {extern int nr_cgroups;/* number of explicit cgroups defined */ -extern void close_cgroup (struct cgroup_sel *cgrp); -extern int parse_cgroups (const struct option *opt,const char *str,int unset); +void close_cgroup (struct cgroup_sel *cgrp); +int parse_cgroups (const struct option *opt,const char *str,int unset);#endif /* __CGROUP_H__ */
tools/perf/util/cloexec.h +1 -1
@@ -5,7 +5,7 @@ unsigned long perf_event_open_cloexec_flag(void);#ifdef __GLIBC_PREREQ#if !__GLIBC_PREREQ (2 ,6 ) && !defined(__UCLIBC__) -extern int sched_getcpu(void) __THROW; +int sched_getcpu(void) __THROW;#endif #endif
tools/perf/util/data-convert-bt.c +1 -1
@@ -632,7 +632,7 @@ static bool is_flush_needed(struct ctf_stream *cs) }static int process_sample_event (struct perf_tool *tool, -union perf_event *_event__maybe_unused , +union perf_event *_event,struct perf_sample *sample,struct perf_evsel *evsel,struct machine *machine__maybe_unused )
tools/perf/util/db-export.c +1 -1
@@ -333,7 +333,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, sample_addr_correlates_sym(&evsel->attr)) {struct addr_location addr_al; -perf_event__preprocess_sample_addr (event, sample, thread, &addr_al); +thread__resolve (thread, &addr_al, sample); err =db_ids_from_al (dbe, &addr_al, &es.addr_dso_db_id, &es.addr_sym_db_id, &es.addr_offset);if (err)
tools/perf/util/dso.h +2 -1
@@ -162,6 +162,7 @@ struct dso {u8 loaded;u8 rel;u8 build_id[BUILD_ID_SIZE ]; +u64 text_offset;const char *short_name;const char *long_name;u16 long_name_len;
@@ -301,7 +302,7 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,* TODO */ int dso__data_get_fd (struct dso *dso,struct machine *machine); -void dso__data_put_fd (struct dso *dso__maybe_unused ); +void dso__data_put_fd (struct dso *dso);void dso__data_close (struct dso *dso);off_t dso__data_size (struct dso *dso,struct machine *machine);
tools/perf/util/dwarf-aux.c +5 -5
@@ -915,7 +915,7 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf) tmp ="*" ; else if (tag == DW_TAG_subroutine_type) {/* Function pointer */ -strbuf_addf (buf,"(function_type)" ); +strbuf_add (buf,"(function_type)" ,15 );return 0 ; } else {if (!dwarf_diename (&type))
@@ -932,7 +932,7 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf) } ret =die_get_typename (&type, buf);if (ret ==0 ) -strbuf_addf (buf,"%s" , tmp); +strbuf_addstr (buf, tmp);return ret; }
@@ -951,7 +951,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf) ret =die_get_typename (vr_die, buf);if (ret <0 ) {pr_debug ("Failed to get type, make it unknown.\n" ); -strbuf_addf (buf,"(unknown_type)" ); +strbuf_add (buf," (unknown_type)" ,14 ); }strbuf_addf (buf,"\t%s" ,dwarf_diename (vr_die));
@@ -1013,7 +1013,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die, }if (!first) -strbuf_addf (buf,"]>" ); +strbuf_add (buf,"]>" ,2 ); out:free (scopes);
@@ -1076,7 +1076,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf) }if (!first) -strbuf_addf (buf,"]>" ); +strbuf_add (buf,"]>" ,2 );return ret; }
tools/perf/util/dwarf-aux.h +35 -37
134 lines not on this page · raw message
tools/perf/util/event.c +8 -15
@@ -1295,12 +1295,9 @@ void thread__find_addr_location(struct thread *thread,* Callers need to drop the reference to al->thread, obtained in * machine__findnew_thread() */ -int perf_event__preprocess_sample (const union perf_event *event, -struct machine *machine, -struct addr_location *al, -struct perf_sample *sample) +int machine__resolve (struct machine *machine,struct addr_location *al, +struct perf_sample *sample) { -u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct thread *thread =machine__findnew_thread (machine, sample->pid, sample->tid);
@@ -1315,11 +1312,11 @@ int perf_event__preprocess_sample(const union perf_event *event,* events, but for older perf.data files there was no such thing, so do * it now. */ -if (cpumode ==PERF_RECORD_MISC_KERNEL && +if (sample->cpumode ==PERF_RECORD_MISC_KERNEL &&machine__kernel_map (machine) ==NULL )machine__create_kernel_maps (machine); -thread__find_addr_map (thread, cpumode,MAP__FUNCTION , sample->ip, al); +thread__find_addr_map (thread, sample->cpumode,MAP__FUNCTION , sample->ip, al);dump_printf (" ...... dso: %s\n" , al->map ? al->map->dso->long_name : al->level =='H' ?"[hypervisor]" :"<not found>" );
@@ -1395,16 +1392,12 @@ bool sample_addr_correlates_sym(struct perf_event_attr *attr)return false; } -void perf_event__preprocess_sample_addr (union perf_event *event, -struct perf_sample *sample, -struct thread *thread, -struct addr_location *al) +void thread__resolve (struct thread *thread,struct addr_location *al, +struct perf_sample *sample) { -u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; - -thread__find_addr_map (thread, cpumode,MAP__FUNCTION , sample->addr, al); +thread__find_addr_map (thread, sample->cpumode,MAP__FUNCTION , sample->addr, al);if (!al->map) -thread__find_addr_map (thread, cpumode,MAP__VARIABLE , +thread__find_addr_map (thread, sample->cpumode,MAP__VARIABLE , sample->addr, al); al->cpu = sample->cpu;
tools/perf/util/event.h +5 -8
@@ -192,6 +192,7 @@ struct perf_sample {u64 data_src;u32 flags;u16 insn_len; +u8 cpumode;void *raw_data;struct ip_callchain *callchain;struct branch_stack *branch_stack;
@@ -597,10 +598,8 @@ int perf_event__process(struct perf_tool *tool,struct addr_location ; -int perf_event__preprocess_sample (const union perf_event *event, -struct machine *machine, -struct addr_location *al, -struct perf_sample *sample); +int machine__resolve (struct machine *machine,struct addr_location *al, +struct perf_sample *sample);void addr_location__put (struct addr_location *al);
@@ -608,10 +607,8 @@ struct thread;bool is_bts_event (struct perf_event_attr *attr);bool sample_addr_correlates_sym (struct perf_event_attr *attr); -void perf_event__preprocess_sample_addr (union perf_event *event, -struct perf_sample *sample, -struct thread *thread, -struct addr_location *al); +void thread__resolve (struct thread *thread,struct addr_location *al, +struct perf_sample *sample);const char *perf_event__name (unsigned int id);
tools/perf/util/evsel.c +1 -0
@@ -1643,6 +1643,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, data->stream_id = data->id = data->time =-1ULL ; data->period = evsel->attr.sample_period; data->weight =0 ; + data->cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;if (event->header.type !=PERF_RECORD_SAMPLE ) {if (!evsel->attr.sample_id_all)
tools/perf/util/genelf.h +3 -5
@@ -2,12 +2,10 @@#define __GENELF_H__/* genelf.c */ -extern int jit_write_elf (int fd,uint64_t code_addr,const char *sym, -const void *code,int csize, -void *debug,int nr_debug_entries); +int jit_write_elf (int fd,uint64_t code_addr,const char *sym, +const void *code,int csize,void *debug,int nr_debug_entries);/* genelf_debug.c */ -extern int jit_add_debug_info (Elf *e,uint64_t code_addr, -void *debug,int nr_debug_entries); +int jit_add_debug_info (Elf *e,uint64_t code_addr,void *debug,int nr_debug_entries);#if defined(__arm__)#define GEN_ELF_ARCH EM_ARM
tools/perf/util/header.c +0 -5
@@ -1872,11 +1872,6 @@ static int process_cpu_topology(struct perf_file_section *section,if (ph->needs_swap) nr =bswap_32 (nr); -if (nr > (u32 )cpu_nr) { -pr_debug ("core_id number is too big." -"You may need to upgrade the perf tool.\n" ); - goto free_cpu; - } ph->env.cpu[i].core_id = nr; ret =readn (fd, &nr,sizeof (nr));
tools/perf/util/header.h +1 -1
@@ -121,7 +121,7 @@ int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, perf_event__handler_t process);int perf_event__process_attr (struct perf_tool *tool,union perf_event *event,struct perf_evlist **pevlist); -int perf_event__process_event_update (struct perf_tool *tool__maybe_unused , +int perf_event__process_event_update (struct perf_tool *tool,union perf_event *event,struct perf_evlist **pevlist);size_t perf_event__fprintf_event_update (union perf_event *event,FILE *fp);
tools/perf/util/hist.c +1 -1
@@ -670,7 +670,7 @@ iter_prepare_branch_entry(struct hist_entry_iter *iter, struct addr_location *al }static int -iter_add_single_branch_entry (struct hist_entry_iter *iter__maybe_unused , +iter_add_single_branch_entry (struct hist_entry_iter *iter,struct addr_location *al__maybe_unused ) {/* to avoid calling callback function */
tools/perf/util/hist.h +1 -2
@@ -433,8 +433,7 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al, struct perf_sample *sample, bool nonany_branch_mode);struct option ; -int parse_filter_percentage (const struct option *opt__maybe_unused , -const char *arg,int unset__maybe_unused ); +int parse_filter_percentage (const struct option *opt,const char *arg,int unset);int perf_hist_config (const char *var,const char *value);void perf_hpp_list__init (struct perf_hpp_list *list);
tools/perf/util/intel-bts.c +1 -1
@@ -678,7 +678,7 @@ static int intel_bts_process_auxtrace_event(struct perf_session *session,return 0 ; } -static int intel_bts_flush (struct perf_session *session__maybe_unused , +static int intel_bts_flush (struct perf_session *session,struct perf_tool *tool__maybe_unused ) { struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts,
tools/perf/util/jit.h +4 -8
@@ -3,13 +3,9 @@#include <data.h> -extern int jit_process (struct perf_session *session, -struct perf_data_file *output, -struct machine *machine, -char *filename, -pid_t pid, -u64 *nbytes); - -extern int jit_inject_record (const char *filename); +int jit_process (struct perf_session *session,struct perf_data_file *output, +struct machine *machine,char *filename,pid_t pid,u64 *nbytes); + +int jit_inject_record (const char *filename);#endif /* __JIT_H__ */
tools/perf/util/llvm-utils.c +16 -8
@@ -3,11 +3,11 @@* Copyright (C) 2015, Huawei Inc. */ +#include <limits.h> #include <stdio.h> -#include "util.h" +#include <stdlib.h> #include "debug.h" #include "llvm-utils.h" -#include "cache.h" #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\
@@ -98,11 +98,12 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz)void *buf =NULL ;FILE *file =NULL ;size_t read_sz =0 , buf_sz =0 ; +char serr[STRERR_BUFSIZE ]; file =popen (cmd,"r" );if (!file) {pr_err ("ERROR: unable to popen cmd: %s\n" , -strerror (errno)); +strerror_r (errno, serr,sizeof (serr)));return -EINVAL ; }
@@ -136,7 +137,7 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz)if (ferror (file)) {pr_err ("ERROR: error occurred when reading from pipe: %s\n" , -strerror (errno)); +strerror_r (errno, serr,sizeof (serr))); err = -EIO ; goto errout; }
@@ -334,10 +335,18 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,unsigned int kernel_version;char linux_version_code_str[64 ];const char *clang_opt = llvm_param.clang_opt; -char clang_path[PATH_MAX ], nr_cpus_avail_str[64 ]; +char clang_path[PATH_MAX ], abspath[PATH_MAX ], nr_cpus_avail_str[64 ]; +char serr[STRERR_BUFSIZE ];char *kbuild_dir =NULL , *kbuild_include_opts =NULL ;const char *template = llvm_param.clang_bpf_cmd_template; +if (path[0 ] !='-' &&realpath (path, abspath) ==NULL ) { + err = errno; +pr_err ("ERROR: problems with path %s: %s\n" , + path,strerror_r (err, serr,sizeof (serr))); +return -err; + } +if (!template) template =CLANG_BPF_CMD_DEFAULT_TEMPLATE ;
@@ -362,7 +371,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,if (nr_cpus_avail <=0 ) {pr_err ("WARNING:\tunable to get available CPUs in this system: %s\n" -" \tUse 128 instead.\n" ,strerror (errno)); +" \tUse 128 instead.\n" ,strerror_r (errno, serr,sizeof (serr))); nr_cpus_avail =128 ; } snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d",
@@ -387,8 +396,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,* stdin to be source file (testing). */ force_set_env ("CLANG_SOURCE" , - (path[0 ] =='-' ) ? path : -make_nonrelative_path (path)); + (path[0 ] =='-' ) ? path : abspath);pr_debug ("llvm compiling command template: %s\n" , template); err =read_from_pipe (template, &obj_buf, &obj_buf_sz);
tools/perf/util/llvm-utils.h +3 -4
@@ -39,11 +39,10 @@ struct llvm_param { };extern struct llvm_param llvm_param; -extern int perf_llvm_config (const char *var,const char *value); +int perf_llvm_config (const char *var,const char *value); -extern int llvm__compile_bpf (const char *path,void **p_obj_buf, -size_t *p_obj_buf_sz); +int llvm__compile_bpf (const char *path,void **p_obj_buf,size_t *p_obj_buf_sz);/* This function is for test__llvm() use only */ -extern int llvm__search_clang (void ); +int llvm__search_clang (void );#endif
tools/perf/util/machine.c +6 -8
@@ -1301,9 +1301,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine,int machine__process_mmap2_event (struct machine *machine,union perf_event *event, -struct perf_sample *sample__maybe_unused ) +struct perf_sample *sample) { -u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct thread *thread;struct map *map;enum map_type type;
@@ -1312,8 +1311,8 @@ int machine__process_mmap2_event(struct machine *machine,if (dump_trace)perf_event__fprintf_mmap2 (event, stdout); -if (cpumode ==PERF_RECORD_MISC_GUEST_KERNEL || - cpumode ==PERF_RECORD_MISC_KERNEL ) { +if (sample->cpumode ==PERF_RECORD_MISC_GUEST_KERNEL || + sample->cpumode ==PERF_RECORD_MISC_KERNEL ) { ret =machine__process_kernel_mmap_event (machine, event);if (ret <0 ) goto out_problem;
@@ -1355,9 +1354,8 @@ int machine__process_mmap2_event(struct machine *machine, }int machine__process_mmap_event (struct machine *machine,union perf_event *event, -struct perf_sample *sample__maybe_unused ) +struct perf_sample *sample) { -u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct thread *thread;struct map *map;enum map_type type;
@@ -1366,8 +1364,8 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *eventif (dump_trace)perf_event__fprintf_mmap (event, stdout); -if (cpumode ==PERF_RECORD_MISC_GUEST_KERNEL || - cpumode ==PERF_RECORD_MISC_KERNEL ) { +if (sample->cpumode ==PERF_RECORD_MISC_GUEST_KERNEL || + sample->cpumode ==PERF_RECORD_MISC_KERNEL ) { ret =machine__process_kernel_mmap_event (machine, event);if (ret <0 ) goto out_problem;
tools/perf/util/machine.h +1 -1
@@ -94,7 +94,7 @@ int machine__process_aux_event(struct machine *machine, union perf_event *event);int machine__process_itrace_start_event (struct machine *machine,union perf_event *event); -int machine__process_switch_event (struct machine *machine__maybe_unused , +int machine__process_switch_event (struct machine *machine,union perf_event *event);int machine__process_mmap_event (struct machine *machine,union perf_event *event,struct perf_sample *sample);
tools/perf/util/parse-events.h +10 -11
@@ -22,19 +22,18 @@ struct tracepoint_path {struct tracepoint_path *next; }; -extern struct tracepoint_path *tracepoint_id_to_path (u64 config); -extern struct tracepoint_path *tracepoint_name_to_path (const char *name); -extern bool have_tracepoints (struct list_head *evlist); +struct tracepoint_path *tracepoint_id_to_path (u64 config); +struct tracepoint_path *tracepoint_name_to_path (const char *name); +bool have_tracepoints (struct list_head *evlist);const char *event_type (int type); -extern int parse_events_option (const struct option *opt,const char *str, -int unset); -extern int parse_events (struct perf_evlist *evlist,const char *str, -struct parse_events_error *error); -extern int parse_events_terms (struct list_head *terms,const char *str); -extern int parse_filter (const struct option *opt,const char *str,int unset); -extern int exclude_perf (const struct option *opt,const char *arg,int unset); +int parse_events_option (const struct option *opt,const char *str,int unset); +int parse_events (struct perf_evlist *evlist,const char *str, +struct parse_events_error *error); +int parse_events_terms (struct list_head *terms,const char *str); +int parse_filter (const struct option *opt,const char *str,int unset); +int exclude_perf (const struct option *opt,const char *arg,int unset);#define EVENTS_HELP_MAX (128*1024)
@@ -183,7 +182,7 @@ void print_symbol_events(const char *event_glob, unsigned type,void print_tracepoint_events (const char *subsys_glob,const char *event_glob,bool name_only);int print_hwcache_events (const char *event_glob,bool name_only); -extern int is_valid_tracepoint (const char *event_string); +int is_valid_tracepoint (const char *event_string);int valid_event_mount (const char *eventfs);char *parse_events_formats_error_string (char *additional_terms);
tools/perf/util/path.c +0 -30
@@ -41,36 +41,6 @@ static char *cleanup_path(char *path)return path; } -static char *perf_vsnpath (char *buf,size_t n,const char *fmt,va_list args) -{ -const char *perf_dir =get_perf_dir (); -size_t len; - - len =strlen (perf_dir); -if (n < len +1 ) - goto bad; -memcpy (buf, perf_dir, len); -if (len && !is_dir_sep (perf_dir[len-1 ])) - buf[len++] ='/' ; - len +=vsnprintf (buf + len, n - len, fmt, args); -if (len >= n) - goto bad; -return cleanup_path (buf); -bad: -strlcpy (buf, bad_path, n); -return buf; -} - -char *perf_pathdup (const char *fmt, ...) -{ -char path[PATH_MAX ]; -va_list args; -va_start (args, fmt); - (void )perf_vsnpath (path,sizeof (path), fmt, args);
Lines of this file are not shown. View the raw message.
tools/perf/util/probe-event.h +26 -31
57 lines not on this page · raw message
tools/perf/util/svghelper.h +25 -26
51 lines not on this page · raw message
tools/scripts/utilities.mak renamed from tools/perf/config/utilities.mak +0 -0
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.