perf changes for v3.15
Subsystems (6)
Linus,
Please pull the latest perf-core-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-core-for-linus
# HEAD: 538592ff0b008237ae88f5ce5fb1247127dc3ce5 Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Main changes:
Kernel side changes:
* Add SNB/IVB/HSW client uncore memory controller support (Stephane Eranian)
* Fix various x86/P4 PMU driver bugs (Don Zickus)
Tooling, user visible changes:
* Add several futex 'perf bench' microbenchmarks (Davidlohr Bueso)
* Speed up thread map generation (Don Zickus)
* Introduce 'perf kvm --list-cmds' command line option for use by scripts (Ramkumar Ramachandra)
* Print the evsel name in the annotate stdio output, prep to fix support outputting annotation for multiple events, not just for the first one (Arnaldo Carvalho de Melo)
* Allow setting preferred callchain method in .perfconfig (Jiri Olsa)
* Show in what binaries/modules 'perf probe's are set (Masami Hiramatsu)
* Support distro-style debuginfo for uprobe in 'perf probe' (Masami Hiramatsu)
Tooling, internal changes and fixes:
* Use tid in mmap/mmap2 events to find maps (Don Zickus)
* Record the reason for filtering an address_location (Namhyung Kim)
* Apply all filters to an addr_location (Namhyung Kim)
* Merge al->filtered with hist_entry->filtered in report/hists (Namhyung Kim)
* Fix memory leak when synthesizing thread records (Namhyung Kim)
* Use ui__has_annotation() in 'report' (Namhyung Kim)
* hists browser refactorings to reuse code accross UIs (Namhyung Kim)
* Add support for the new DWARF unwinder library in elfutils (Jiri Olsa)
* Fix build race in the generation of bison files (Jiri Olsa)
* Further streamline the feature detection display, trimming it a bit to show just the libraries detected, using VF=1 gets a more verbose output, showing the less interesting feature checks as well (Jiri Olsa).
* Check compatible symtab type before loading dso (Namhyung Kim)
* Check return value of filename__read_debuglink() (Stephane Eranian)
* Move some hashing and fs related code from tools/perf/util/ to tools/lib/ so that it can be used by more tools/ living utilities (Borislav Petkov)
* Prepare DWARF unwinding code for using an elfutils alternative unwinding library (Jiri Olsa)
* Fix DWARF unwind max_stack processing (Jiri Olsa)
* Add dwarf unwind 'perf test' entry (Jiri Olsa)
* 'perf probe' improvements including memory leak fixes, sharing the intlist class with other tools, uprobes/kprobes code sharing and use of ref_reloc_sym (Masami Hiramatsu)
* Shorten sample symbol resolving by adding cpumode to struct addr_location (Arnaldo Carvalho de Melo)
* Fix synthesizing mmaps for threads (Don Zickus)
* Fix invalid output on event group stdio report (Namhyung Kim)
* Fixup header alignment in 'perf sched latency' output (Ramkumar Ramachandra)
* Fix off-by-one error in 'perf timechart record' argv handling (Ramkumar Ramachandra)
Tooling, cleanups:
* Remove unused thread__find_map function (Jiri Olsa)
* Remove unused simple_strtoul() function (Ramkumar Ramachandra)
Tooling, documentation updates:
* Update function names in debug messages (Ramkumar Ramachandra)
* Update some code references in design.txt (Ramkumar Ramachandra)
* Clarify load-latency information in the 'perf mem' docs (Andi Kleen)
* Clarify x86 register naming in 'perf probe' docs (Andi Kleen)
Thanks,
Ingo
------------------>
Andi Kleen (2):
perf mem: Clarify load-latency in documentation perf probe: Clarify x86 register naming for perf probe
Arnaldo Carvalho de Melo (8):
perf report: Use al->cpumode where applicable
perf tools: Shorten sample symbol resolving function signature perf tools: Shorten sample symbol resolving function signature perf report: Remove some needless container_of usage perf symbols: No need to export dso__first_symbol perf tools: Warn the user about how to enable libunwind support perf symbols: Introduce thread__find_cpumode_addr_location perf annotate: Print the evsel name in the stdio output
Borislav Petkov (3):
perf tools: Move fs.* to lib/api/fs/
perf tools: Move hash.h header
perf tools: Drop prefetch.h
Davidlohr Bueso (3):
perf bench: Add futex-hash microbenchmark perf bench: Add futex-wake microbenchmark perf bench: Add futex-requeue microbenchmark
Don Zickus (6):
perf/x86/p4: Fix counter corruption when using lots of perf groups perf/x86/p4: Block PMIs on init to prevent a stream of unkown NMIs perf tools: Fix synthesizing mmaps for threads
perf session: Change header.misc dump from decimal to hex perf tools: Speed up thread map generation
perf tools: Use tid in mmap/mmap2 events to find maps
Dongsheng Yang (1):
perf/x86/uncore: Add __init for uncore_cpumask_init()
Jiri Olsa (27):
perf tools: Put proper period for for samples without PERIOD sample_type perf tools: Add call-graph option support into .perfconfig
perf record: Add readable output for callchain debug
perf tools: Fix memory leak in event_format__print function
perf tests x86: Introduce perf_regs_load function
perf tests x86: Add dwarf unwind test
perf tools: Fix dwarf unwind max_stack processing
perf callchain: Do not report zero address in unwind
perf callchain: Add mask into struct regs_dump
perf callchain: Separate libunwind code to special object
perf callchain: Rename unwind__arch_reg_id into libunwind__arch_reg_id perf callchain: Introduce HAVE_DWARF_UNWIND_SUPPORT macro
perf callchain: Separate perf_reg_value function in perf_regs object perf tests: Fix *.o make tests
perf tests: Add pmu-bison.o make test
perf tools: Fix bison OUTPUT directories dependency
perf tools: Factor features display code
perf tools: Add variable display for VF make output
perf tools: Add feature check for libdw dwarf unwind
perf tools: Add libdw DWARF post unwind support
perf tools: Setup default dwarf post unwinder
perf tests: Add NO_LIBDW_DWARF_UNWIND make test
perf: Disallow user-space callchains for function trace events
perf: Disallow user-space stack dumps for function trace events perf tools: Disable user-space callchain/stack dumps for function trace events perf machine: Factor machine__find_thread to take tid argument perf tools: Remove thread__find_map function
Mark Rutland (2):
perf: Fix prototype of find_pmu_context()
perf: Remove redundant PMU assignment
Masami Hiramatsu (11):
perf probe: Fix to do exit call for symbol maps
perf probe: Remove incorrect symbol check for --list
perf probe: Replace line_list with intlist
perf probe: Unify show_available_functions for uprobes/kprobes perf probe: Show in what binaries/modules probes are set perf probe: Use ref_reloc_sym based address instead of the symbol name perf probe: Find given address from offline dwarf
perf probe: Show appropriate symbol for ref_reloc_sym based kprobes perf probe: Show source-level or symbol-level info for uprobes perf probe: Allow to add events on the local functions perf probe: Support distro-style debuginfo for uprobe
Namhyung Kim (11):
perf symbols: Check compatible symtab type before loading dso perf ui/stdio: Fix invalid output on event group report perf ui/gtk: Reuse generic __hpp__fmt() code
perf ui/hists: Pass struct hpp to print functions
perf ui/tui: Reuse generic __hpp__fmt() code
perf ui hists: Pass evsel to hpp->header/width functions explicitly perf symbols: Record the reason for filtering an address_location perf symbols: Apply all filters to an addr_location perf report: Merge al->filtered with hist_entry->filtered perf tools: Fix memory leak when synthesizing thread records perf report: Use ui__has_annotation()
Peter Zijlstra (5):
perf/x86: Push the duration-logging printk() to IRQ context x86/nmi: Push duration printk() to irq context perf/x86: Warn to early_printk() in case irq_work is too slow perf/x86: Add a few more comments
perf: Optimize group_sched_in()
Ramkumar Ramachandra (6):
perf kvm: introduce --list-cmds for use by scripts perf timechart: Fix off-by-one error in 'record' argv handling perf sched: Fixup header alignment in 'latency' output perf evsel: Update function names in debug messages perf tools: Update some code references in design.txt perf tools: Remove unused simple_strtoul() function
Stephane Eranian (11):
perf/x86/uncore: fix initialization of cpumask perf/x86/uncore: add ability to customize pmu callbacks perf/x86/uncore: add PCI ids for SNB/IVB/HSW IMC perf/x86/uncore: make hrtimer timeout configurable per box perf/x86/uncore: move uncore_event_to_box() and uncore_pmu_to_box() perf/x86/uncore: add SNB/IVB/HSW client uncore memory controller support perf/x86/uncore: add hrtimer to SNB uncore IMC PMU perf/x86/uncore: use MiB unit for events for SNB/IVB/HSW IMC perf symbols: Check return value of filename__read_debuglink() perf/x86/uncore: Fix compilation warning in snb_uncore_imc_init_box() perf/x86/uncore: Fix missing end markers for SNB/IVB/HSW IMC PMU
arch/x86/include/asm/nmi.h | 3 +
arch/x86/kernel/cpu/perf_event.c | 47 +-
arch/x86/kernel/cpu/perf_event.h | 8 +-
arch/x86/kernel/cpu/perf_event_intel_uncore.c | 544 +++++++++++--
arch/x86/kernel/cpu/perf_event_intel_uncore.h | 5 +
arch/x86/kernel/cpu/perf_event_p4.c | 34 +-
arch/x86/kernel/nmi.c | 37 +-
include/linux/irq_work.h | 4 +-
include/linux/pci_ids.h | 3 +
kernel/events/core.c | 39 +-
kernel/irq_work.c | 6 +-
kernel/trace/trace_event_perf.c | 22 +-
tools/include/linux/hash.h | 5 +
tools/lib/api/Makefile | 2 +
tools/{perf/util => lib/api/fs}/fs.c | 11 +-
.../util/include/linux/magic.h => lib/api/fs/fs.h} | 12 +-
tools/perf/Documentation/perf-mem.txt | 4 +
tools/perf/Documentation/perf-probe.txt | 2 +
tools/perf/MANIFEST | 1 +
tools/perf/Makefile.perf | 42 +-
tools/perf/arch/arm/Makefile | 2 +-
.../arch/arm/util/{unwind.c => unwind-libunwind.c} | 2 +-
tools/perf/arch/x86/Makefile | 9 +-
tools/perf/arch/x86/include/perf_regs.h | 6 +
tools/perf/arch/x86/tests/dwarf-unwind.c | 59 ++
tools/perf/arch/x86/tests/regs_load.S | 92 +++
tools/perf/arch/x86/util/unwind-libdw.c | 51 ++
.../arch/x86/util/{unwind.c => unwind-libunwind.c} | 4 +-
tools/perf/bench/bench.h | 3 +
tools/perf/bench/futex-hash.c | 212 +++++
tools/perf/bench/futex-requeue.c | 211 +++++
tools/perf/bench/futex-wake.c | 201 +++++
tools/perf/bench/futex.h | 71 ++
tools/perf/builtin-bench.c | 12 +-
tools/perf/builtin-diff.c | 7 +-
tools/perf/builtin-inject.c | 1 -
tools/perf/builtin-kvm.c | 12 +-
tools/perf/builtin-probe.c | 12 +-
tools/perf/builtin-record.c | 30 +-
tools/perf/builtin-report.c | 28 +-
tools/perf/builtin-sched.c | 10 +-
tools/perf/builtin-timechart.c | 4 +-
tools/perf/builtin-top.c | 12 +
tools/perf/config/Makefile | 232 ++++--
tools/perf/config/feature-checks/Makefile | 6 +-
tools/perf/config/feature-checks/test-all.c | 5 +
.../feature-checks/test-libdw-dwarf-unwind.c | 13 +
tools/perf/design.txt | 12 +-
tools/perf/perf-completion.sh | 2 +-
tools/perf/perf.h | 10 +-
tools/perf/tests/builtin-test.c | 8 +
tools/perf/tests/dwarf-unwind.c | 144 ++++
tools/perf/tests/hists_link.c | 1 +
tools/perf/tests/make | 25 +-
tools/perf/tests/parse-events.c | 2 +-
tools/perf/tests/sample-parsing.c | 17 +-
tools/perf/tests/tests.h | 9 +
tools/perf/ui/browsers/hists.c | 122 +--
tools/perf/ui/gtk/hists.c | 78 +-
tools/perf/ui/hist.c | 138 +++-
tools/perf/ui/stdio/hist.c | 11 +-
tools/perf/util/annotate.c | 14 +-
tools/perf/util/cpumap.c | 2 +-
tools/perf/util/dso.c | 4 +-
tools/perf/util/dso.h | 10 +
tools/perf/util/event.c | 188 +++--
tools/perf/util/event.h | 5 +-
tools/perf/util/evsel.c | 60 +-
tools/perf/util/evsel.h | 18 +
tools/perf/util/fs.h | 7 -
tools/perf/util/hist.c | 13 +-
tools/perf/util/hist.h | 29 +-
tools/perf/util/include/linux/hash.h | 5 -
tools/perf/util/include/linux/kernel.h | 6 -
tools/perf/util/include/linux/list.h | 1 -
tools/perf/util/include/linux/prefetch.h | 6 -
tools/perf/util/machine.c | 79 +-
tools/perf/util/machine.h | 13 +-
tools/perf/util/map.h | 10 +
tools/perf/util/parse-options.c | 37 +-
tools/perf/util/parse-options.h | 8 +-
tools/perf/util/perf_regs.c | 19 +
tools/perf/util/perf_regs.h | 13 +
tools/perf/util/pmu.c | 2 +-
tools/perf/util/probe-event.c | 863 ++++++++++++---------
tools/perf/util/probe-event.h | 12 +-
tools/perf/util/probe-finder.c | 198 ++---
tools/perf/util/probe-finder.h | 5 +-
tools/perf/util/python-ext-sources | 2 +-
tools/perf/util/record.c | 2 +-
tools/perf/util/session.c | 7 +-
tools/perf/util/symbol-elf.c | 2 +
tools/perf/util/symbol.c | 63 +-
tools/perf/util/symbol.h | 14 +-
tools/perf/util/thread.c | 21 +
tools/perf/util/thread.h | 11 +-
tools/perf/util/trace-event-parse.c | 1 +
tools/perf/util/unwind-libdw.c | 210 +++++
tools/perf/util/unwind-libdw.h | 21 +
tools/perf/util/{unwind.c => unwind-libunwind.c} | 50 +-
tools/perf/util/unwind.h | 11 +-
tools/perf/util/util.c | 2 +-
102 files changed, 3472 insertions(+), 1289 deletions(-)
create mode 100644 tools/include/linux/hash.h
rename tools/{perf/util => lib/api/fs}/fs.c (91%)
rename tools/{perf/util/include/linux/magic.h => lib/api/fs/fs.h} (50%)
rename tools/perf/arch/arm/util/{unwind.c => unwind-libunwind.c} (95%)
create mode 100644 tools/perf/arch/x86/tests/dwarf-unwind.c
create mode 100644 tools/perf/arch/x86/tests/regs_load.S
create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
rename tools/perf/arch/x86/util/{unwind.c => unwind-libunwind.c} (95%)
create mode 100644 tools/perf/bench/futex-hash.c
create mode 100644 tools/perf/bench/futex-requeue.c
create mode 100644 tools/perf/bench/futex-wake.c
create mode 100644 tools/perf/bench/futex.h
create mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
create mode 100644 tools/perf/tests/dwarf-unwind.c
delete mode 100644 tools/perf/util/fs.h
delete mode 100644 tools/perf/util/include/linux/hash.h
delete mode 100644 tools/perf/util/include/linux/prefetch.h
create mode 100644 tools/perf/util/perf_regs.c
create mode 100644 tools/perf/util/unwind-libdw.c
create mode 100644 tools/perf/util/unwind-libdw.h
rename tools/perf/util/{unwind.c => unwind-libunwind.c} (92%)arch/x86/include/asm/nmi.h +3 -0
@@ -1,6 +1,7 @@#ifndef _ASM_X86_NMI_H#define _ASM_X86_NMI_H +#include <linux/irq_work.h> #include <linux/pm.h> #include <asm/irq.h> #include <asm/io.h>
@@ -38,6 +39,8 @@ typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);struct nmiaction {struct list_head list;nmi_handler_t handler; +u64 max_duration; +struct irq_work irq_work;unsigned long flags;const char *name; };
arch/x86/kernel/cpu/perf_event.c +33 -14
100 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event.h +5 -3
@@ -130,9 +130,11 @@ struct cpu_hw_events {unsigned long running[BITS_TO_LONGS (X86_PMC_IDX_MAX )];int enabled; -int n_events; -int n_added; -int n_txn; +int n_events;/* the # of events in the below arrays */ +int n_added;/* the # last events in the below arrays; +they've never been enabled yet */ +int n_txn;/* the # last events in the below arrays; +added in the current transaction */ int assign[X86_PMC_IDX_MAX ];/* event to counter assignment */ u64 tags[X86_PMC_IDX_MAX ];struct perf_event *event_list[X86_PMC_IDX_MAX ];/* in enabled order */
arch/x86/kernel/cpu/perf_event_intel_uncore.c +473 -71
623 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_intel_uncore.h +5 -0
@@ -6,6 +6,7 @@#define UNCORE_PMU_NAME_LEN 32#define UNCORE_PMU_HRTIMER_INTERVAL (60LL * NSEC_PER_SEC) +#define UNCORE_SNB_IMC_HRTIMER_INTERVAL (5ULL * NSEC_PER_SEC)#define UNCORE_FIXED_EVENT 0xff#define UNCORE_PMC_IDX_MAX_GENERIC 8
@@ -440,6 +441,7 @@ struct intel_uncore_type {struct intel_uncore_ops *ops;struct uncore_event_desc *event_descs;const struct attribute_group *attr_groups[4 ]; +struct pmu *pmu;/* for custom pmu ops */ };#define pmu_group attr_groups[0]
@@ -488,8 +490,11 @@ struct intel_uncore_box {u64 tags[UNCORE_PMC_IDX_MAX ];struct pci_dev *pci_dev;struct intel_uncore_pmu *pmu; +u64 hrtimer_duration;/* hrtimer timeout for this box */ struct hrtimer hrtimer;struct list_head list; +struct list_head active_list; +void *io_addr;struct intel_uncore_extra_reg shared_regs[0 ]; };
arch/x86/kernel/cpu/perf_event_p4.c +33 -1
@@ -1257,7 +1257,24 @@ again: pass++; goto again; } - +/* +* Perf does test runs to see if a whole group can be assigned +* together succesfully. There can be multiple rounds of this. +* Unfortunately, p4_pmu_swap_config_ts touches the hwc->config +* bits, such that the next round of group assignments will +* cause the above p4_should_swap_ts to pass instead of fail. +* This leads to counters exclusive to thread0 being used by +* thread1. +* +* Solve this with a cheap hack, reset the idx back to -1 to +* force a new lookup (p4_next_cntr) to get the right counter +* for the right thread. +* +* This probably doesn't comply with the general spirit of how +* perf wants to work, but P4 is special. :-( +*/ +if (p4_should_swap_ts (hwc->config, cpu)) + hwc->idx =-1 ;p4_pmu_swap_config_ts (hwc, cpu);if (assign) assign[i] = cntr_idx;
@@ -1322,6 +1339,7 @@ static __initconst const struct x86_pmu p4_pmu = {__init int p4_pmu_init (void ) {unsigned int low, high; +int i, reg;/* If we get stripped -- indexing fails */ BUILD_BUG_ON (ARCH_P4_MAX_CCCR >INTEL_PMC_MAX_GENERIC );
@@ -1340,5 +1358,19 @@ __init int p4_pmu_init(void) x86_pmu = p4_pmu; +/* +* Even though the counters are configured to interrupt a particular +* logical processor when an overflow happens, testing has shown that +* on kdump kernels (which uses a single cpu), thread1's counter +* continues to run and will report an NMI on thread0. Due to the +* overflow bug, this leads to a stream of unknown NMIs. +* +* Solve this by zero'ing out the registers to mimic a reset. +*/ +for (i =0 ; i < x86_pmu.num_counters; i++) { + reg =x86_pmu_config_addr (i); +wrmsrl_safe (reg,0ULL ); + } +return 0 ; }
arch/x86/kernel/nmi.c +24 -13
@@ -87,6 +87,7 @@ __setup("unknown_nmi_panic", setup_unknown_nmi_panic);#define nmi_to_desc (type) (&nmi_desc[type])static u64 nmi_longest_ns =1 *NSEC_PER_MSEC ; +static int __init nmi_warning_debugfs (void ) { debugfs_create_u64("nmi_longest_ns", 0644,
@@ -95,6 +96,20 @@ static int __init nmi_warning_debugfs(void) }fs_initcall (nmi_warning_debugfs); +static void nmi_max_handler (struct irq_work *w) +{ + struct nmiaction *a = container_of(w, struct nmiaction, irq_work); +int remainder_ns, decimal_msecs; +u64 whole_msecs =ACCESS_ONCE (a->max_duration); + + remainder_ns =do_div (whole_msecs, (1000 *1000 )); + decimal_msecs = remainder_ns /1000 ; + +printk_ratelimited (KERN_INFO +"INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n" , + a->handler, whole_msecs, decimal_msecs); +} +static int __kprobes nmi_handle (unsigned int type,struct pt_regs *regs,bool b2b) {struct nmi_desc *desc =nmi_to_desc (type);
@@ -110,26 +125,20 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2* to handle those situations. */ list_for_each_entry_rcu (a, &desc->head, list) { -u64 before, delta, whole_msecs; -int remainder_ns, decimal_msecs, thishandled; +int thishandled; +u64 delta; - before =sched_clock (); + delta =sched_clock (); thishandled = a->handler (type, regs); handled += thishandled; - delta =sched_clock () - before; + delta =sched_clock () - delta;trace_nmi_handler (a->handler, (int )delta, thishandled); -if (delta < nmi_longest_ns) +if (delta < nmi_longest_ns || delta < a->max_duration)continue ; - nmi_longest_ns = delta; - whole_msecs = delta; - remainder_ns =do_div (whole_msecs, (1000 *1000 )); - decimal_msecs = remainder_ns /1000 ; -printk_ratelimited (KERN_INFO -"INFO: NMI handler (%ps) took too long to run: " -"%lld.%03d msecs\n" , a->handler, whole_msecs, - decimal_msecs); + a->max_duration = delta; +irq_work_queue (&a->irq_work); }rcu_read_unlock ();
@@ -146,6 +155,8 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)if (!action->handler)return -EINVAL ; +init_irq_work (&action->irq_work, nmi_max_handler); +spin_lock_irqsave (&desc->lock, flags);/*
include/linux/irq_work.h +3 -1
@@ -30,7 +30,9 @@ void init_irq_work(struct irq_work *work, void (*func)(struct irq_work *)) work->func = func; } -void irq_work_queue (struct irq_work *work); +#define DEFINE_IRQ_WORK (name, _f) struct irq_work name = { .func = (_f), } + +bool irq_work_queue (struct irq_work *work);void irq_work_run (void );void irq_work_sync (struct irq_work *work);
include/linux/pci_ids.h +3 -0
@@ -2531,6 +2531,9 @@#define PCI_VENDOR_ID_INTEL 0x8086#define PCI_DEVICE_ID_INTEL_EESSC 0x0008 +#define PCI_DEVICE_ID_INTEL_SNB_IMC 0x0100 +#define PCI_DEVICE_ID_INTEL_IVB_IMC 0x0154 +#define PCI_DEVICE_ID_INTEL_HSW_IMC 0x0c00#define PCI_DEVICE_ID_INTEL_PXHD_0 0x0320#define PCI_DEVICE_ID_INTEL_PXHD_1 0x0321#define PCI_DEVICE_ID_INTEL_PXH_0 0x0329
kernel/events/core.c +28 -11
@@ -231,11 +231,29 @@ int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,#define NR_ACCUMULATED_SAMPLES 128 static DEFINE_PER_CPU(u64, running_sample_length); -void perf_sample_event_took (u64 sample_len_ns) +static void perf_duration_warn (struct irq_work *w) { +u64 allowed_ns =ACCESS_ONCE (perf_sample_allowed_ns);u64 avg_local_sample_len;u64 local_samples_len; + + local_samples_len =__get_cpu_var (running_sample_length); + avg_local_sample_len = local_samples_len/NR_ACCUMULATED_SAMPLES ; + +printk_ratelimited (KERN_WARNING +"perf interrupt took too long (%lld > %lld), lowering " +"kernel.perf_event_max_sample_rate to %d\n" , + avg_local_sample_len, allowed_ns >>1 , + sysctl_perf_event_sample_rate); +} + +static DEFINE_IRQ_WORK(perf_duration_work, perf_duration_warn); + +void perf_sample_event_took (u64 sample_len_ns) +{u64 allowed_ns =ACCESS_ONCE (perf_sample_allowed_ns); +u64 avg_local_sample_len; +u64 local_samples_len;if (allowed_ns ==0 )return ;
@@ -263,13 +281,14 @@ void perf_sample_event_took(u64 sample_len_ns) sysctl_perf_event_sample_rate = max_samples_per_tick *HZ ; perf_sample_period_ns =NSEC_PER_SEC / sysctl_perf_event_sample_rate; -printk_ratelimited (KERN_WARNING -"perf samples too long (%lld > %lld), lowering " -"kernel.perf_event_max_sample_rate to %d\n" , - avg_local_sample_len, allowed_ns, - sysctl_perf_event_sample_rate); -update_perf_cpu_limits (); + +if (!irq_work_queue (&perf_duration_work)) { +early_printk ("perf interrupt took too long (%lld > %lld), lowering " +"kernel.perf_event_max_sample_rate to %d\n" , + avg_local_sample_len, allowed_ns >>1 , + sysctl_perf_event_sample_rate); + } }static atomic64_t perf_event_id;
@@ -1714,7 +1733,7 @@ group_sched_in(struct perf_event *group_event, struct perf_event_context *ctx) {struct perf_event *event, *partial_group =NULL ; -struct pmu *pmu = group_event->pmu; +struct pmu *pmu = ctx->pmu;u64 now = ctx->time;bool simulate = false;
@@ -2563,8 +2582,6 @@ static void perf_branch_stack_sched_in(struct task_struct *prev,if (cpuctx->ctx.nr_branch_stack >0 && pmu->flush_branch_stack) { - pmu = cpuctx->ctx.pmu; -perf_ctx_lock (cpuctx, cpuctx->task_ctx);perf_pmu_disable (pmu);
@@ -6294,7 +6311,7 @@ static int perf_event_idx_default(struct perf_event *event)* Ensures all contexts with the same task_ctx_nr have the same * pmu_cpu_context too. */ -static void *find_pmu_context (int ctxn) +static struct perf_cpu_context __percpu *find_pmu_context (int ctxn) {struct pmu *pmu;
kernel/irq_work.c +4 -2
@@ -61,11 +61,11 @@ void __weak arch_irq_work_raise(void)* * Can be re-enqueued while the callback is still in progress. */ -void irq_work_queue (struct irq_work *work) +bool irq_work_queue (struct irq_work *work) {/* Only queue if not already pending */ if (!irq_work_claim (work)) -return ; +return false;/* Queue the entry and raise the IPI if needed. */ preempt_disable ();
@@ -83,6 +83,8 @@ void irq_work_queue(struct irq_work *work) }preempt_enable (); + +return true; }EXPORT_SYMBOL_GPL (irq_work_queue);
kernel/trace/trace_event_perf.c +19 -3
@@ -31,9 +31,25 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event, }/* The ftrace function trace is allowed only for root. */ -if (ftrace_event_is_function (tp_event) && -perf_paranoid_tracepoint_raw () && !capable (CAP_SYS_ADMIN )) -return -EPERM ; +if (ftrace_event_is_function (tp_event)) { +if (perf_paranoid_tracepoint_raw () && !capable (CAP_SYS_ADMIN )) +return -EPERM ; + +/* +* We don't allow user space callchains for function trace +* event, due to issues with page faults while tracing page +* fault handler and its overall trickiness nature. +*/ +if (!p_event->attr.exclude_callchain_user) +return -EINVAL ; + +/* +* Same reason to disable user stack dump as for user space +* callchains above. +*/ +if (p_event->attr.sample_type &PERF_SAMPLE_STACK_USER ) +return -EINVAL ; + }/* No tracing, just counting, so no obvious leak */ if (!(p_event->attr.sample_type &PERF_SAMPLE_RAW ))
tools/include/linux/hash.h new file +5 -0
@@ -0,0 +1,5 @@ +#include "../../../include/linux/hash.h" + +#ifndef _TOOLS_LINUX_HASH_H +#define _TOOLS_LINUX_HASH_H +#endif
tools/lib/api/Makefile +2 -0
@@ -9,8 +9,10 @@ LIB_H= LIB_OBJS= LIB_H += fs/debugfs.h +LIB_H += fs/fs.h LIB_OBJS += $(OUTPUT)fs/debugfs.o +LIB_OBJS += $(OUTPUT)fs/fs.o LIBFILE = libapikfs.a
tools/lib/api/fs/fs.c renamed from tools/perf/util/fs.c +8 -3
@@ -1,8 +1,13 @@ +/* TODO merge/factor in debugfs.c here */ -/* TODO merge/factor into tools/lib/lk/debugfs.c */ +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> +#include <sys/vfs.h> -#include "util.h" -#include "util/fs.h" +#include "debugfs.h" +#include "fs.h" static const char *const sysfs__fs_known_mountpoints[] = {"/sys" ,
tools/lib/api/fs/fs.h renamed from tools/perf/util/include/linux/magic.h +5 -7
@@ -1,9 +1,5 @@ -#ifndef _PERF_LINUX_MAGIC_H_ -#define _PERF_LINUX_MAGIC_H_ - -#ifndef DEBUGFS_MAGIC -#define DEBUGFS_MAGIC 0x64626720 -#endif +#ifndef __API_FS__ +#define __API_FS__#ifndef SYSFS_MAGIC #define SYSFS_MAGIC 0x62656572
@@ -13,4 +9,6 @@#define PROC_SUPER_MAGIC 0x9fa0#endif -#endif +const char *sysfs__mountpoint (void ); +const char *procfs__mountpoint (void ); +#endif /* __API_FS__ */
tools/perf/Documentation/perf-mem.txt +4 -0
@@ -18,6 +18,10 @@ from it, into perf.data. Perf record options are accepted and are passed through "perf mem -t <TYPE> report" displays the result. It invokes perf report with the right set of options to display a memory access profile. +Note that on Intel systems the memory latency reported is the use-latency, +not the pure load (or store latency). Use latency includes any pipeline +queueing delays in addition to the memory subsystem latency. + OPTIONS ------- <command>...::
tools/perf/Documentation/perf-probe.txt +2 -0
@@ -136,6 +136,8 @@ Each probe argument follows below syntax. 'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), local array with fixed index (e.g. array[1], var->array[0], var->pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) 'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type. +On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. + LINE SYNTAX ----------- Line range is described by following syntax.
tools/perf/MANIFEST +1 -0
@@ -6,6 +6,7 @@ tools/lib/symbol/kallsyms.c tools/lib/symbol/kallsyms.h tools/include/asm/bug.h tools/include/linux/compiler.h +tools/include/linux/hash.h include/linux/const.h include/linux/perf_event.h include/linux/rbtree.h
tools/perf/Makefile.perf +33 -9
123 lines not on this page · raw message
tools/perf/arch/arm/Makefile +1 -1
@@ -3,5 +3,5 @@ PERF_HAVE_DWARF_REGS := 1 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o endif ifndef NO_LIBUNWIND -LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o endif
tools/perf/arch/arm/util/unwind-libunwind.c renamed from tools/perf/arch/arm/util/unwind.c +1 -1
@@ -4,7 +4,7 @@#include "perf_regs.h" #include "../../util/unwind.h" -int unwind__arch_reg_id (int regnum) +int libunwind__arch_reg_id (int regnum) {switch (regnum) {case UNW_ARM_R0 :
tools/perf/arch/x86/Makefile +8 -1
@@ -3,7 +3,14 @@ PERF_HAVE_DWARF_REGS := 1 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o endif ifndef NO_LIBUNWIND -LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o +endif +ifndef NO_LIBDW_DWARF_UNWIND +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libdw.o +endif +ifndef NO_DWARF_UNWIND +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/dwarf-unwind.o endif LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o
tools/perf/arch/x86/include/perf_regs.h +6 -0
@@ -5,14 +5,20 @@#include "../../util/types.h" #include <asm/perf_regs.h> +void perf_regs_load (u64 *regs); +#ifndef HAVE_ARCH_X86_64_SUPPORT #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) +#define PERF_REGS_MAX PERF_REG_X86_32_MAX +#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32#else #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \ (1ULL << PERF_REG_X86_ES) | \ (1ULL << PERF_REG_X86_FS) | \ (1ULL << PERF_REG_X86_GS))#define PERF_REGS_MASK (((1ULL << PERF_REG_X86_64_MAX) - 1) & ~REG_NOSUPPORT) +#define PERF_REGS_MAX PERF_REG_X86_64_MAX +#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_64#endif #define PERF_REG_IP PERF_REG_X86_IP#define PERF_REG_SP PERF_REG_X86_SP
tools/perf/arch/x86/tests/dwarf-unwind.c new file +59 -0
59 lines not on this page · raw message
tools/perf/arch/x86/tests/regs_load.S new file +92 -0
92 lines not on this page · raw message
tools/perf/arch/x86/util/unwind-libdw.c new file +51 -0
51 lines not on this page · raw message
tools/perf/arch/x86/util/unwind-libunwind.c renamed from tools/perf/arch/x86/util/unwind.c +2 -2
@@ -5,7 +5,7 @@#include "../../util/unwind.h" #ifdef HAVE_ARCH_X86_64_SUPPORT -int unwind__arch_reg_id (int regnum) +int libunwind__arch_reg_id (int regnum) {int id;
@@ -69,7 +69,7 @@ int unwind__arch_reg_id(int regnum) return id; }#else -int unwind__arch_reg_id (int regnum) +int libunwind__arch_reg_id (int regnum) {int id;
tools/perf/bench/bench.h +3 -0
@@ -31,6 +31,9 @@ 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_requeue (int argc,const char **argv,const char *prefix);#define BENCH_FORMAT_DEFAULT_STR "default"#define BENCH_FORMAT_DEFAULT 0
tools/perf/bench/futex-hash.c new file +212 -0
212 lines not on this page · raw message
tools/perf/bench/futex-requeue.c new file +211 -0
211 lines not on this page · raw message
tools/perf/bench/futex-wake.c new file +201 -0
201 lines not on this page · raw message
tools/perf/bench/futex.h new file +71 -0
71 lines not on this page · raw message
tools/perf/builtin-bench.c +11 -1
@@ -12,6 +12,7 @@* sched ... scheduler and IPC performance * mem ... memory access performance * numa ... NUMA scheduling and MM performance +* futex ... Futex performance */ #include "perf.h" #include "util/util.h"
@@ -54,6 +55,14 @@ static struct bench mem_benchmarks[] = { { NULL, NULL, NULL } }; +static struct bench futex_benchmarks[] = { + {"hash" ,"Benchmark for futex hash table" , bench_futex_hash }, + {"wake" ,"Benchmark for futex wake calls" , bench_futex_wake }, + {"requeue" ,"Benchmark for futex requeue calls" , bench_futex_requeue }, + {"all" ,"Test all futex benchmarks" ,NULL }, + {NULL ,NULL ,NULL } +}; +struct collection {const char *name;const char *summary;
@@ -61,11 +70,12 @@ struct collection { };static struct collection collections[] = { - {"sched" ,"Scheduler and IPC benchmarks" , sched_benchmarks }, + {"sched" ,"Scheduler and IPC benchmarks" , sched_benchmarks }, {"mem" ,"Memory access benchmarks" , mem_benchmarks }, #ifdef HAVE_LIBNUMA_SUPPORT {"numa" ,"NUMA scheduling and MM benchmarks" , numa_benchmarks }, #endif + {"futex" ,"Futex stressing benchmarks" , futex_benchmarks }, {"all" ,"All benchmarks" ,NULL }, {NULL ,NULL ,NULL } };
tools/perf/builtin-diff.c +4 -3
@@ -952,8 +952,8 @@ static int hpp__entry_global(struct perf_hpp_fmt *_fmt, struct perf_hpp *hpp, dfmt->header_width, buf); } -static int hpp__header (struct perf_hpp_fmt *fmt, -struct perf_hpp *hpp) +static int hpp__header (struct perf_hpp_fmt *fmt,struct perf_hpp *hpp, +struct perf_evsel *evsel__maybe_unused ) {struct diff_hpp_fmt *dfmt = container_of(fmt, struct diff_hpp_fmt, fmt);
@@ -963,7 +963,8 @@ static int hpp__header(struct perf_hpp_fmt *fmt, }static int hpp__width (struct perf_hpp_fmt *fmt, -struct perf_hpp *hpp__maybe_unused ) +struct perf_hpp *hpp__maybe_unused , +struct perf_evsel *evsel__maybe_unused ) {struct diff_hpp_fmt *dfmt = container_of(fmt, struct diff_hpp_fmt, fmt);
tools/perf/builtin-inject.c +0 -1
@@ -312,7 +312,6 @@ found: sample_sw.period = sample->period; sample_sw.time = sample->time;perf_event__synthesize_sample (event_sw, evsel->attr.sample_type, - evsel->attr.sample_regs_user, evsel->attr.read_format, &sample_sw, false);build_id__mark_dso_hit (tool, event_sw, &sample_sw, evsel, machine);
tools/perf/builtin-kvm.c +5 -7
@@ -1691,17 +1691,15 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused) OPT_END() }; - -const char *const kvm_usage[] = { -"perf kvm [<options>] {top|record|report|diff|buildid-list|stat}" , -NULL - }; +const char *const kvm_subcommands[] = {"top" ,"record" ,"report" ,"diff" , +"buildid-list" ,"stat" ,NULL }; +const char *kvm_usage[] = {NULL ,NULL }; perf_host =0 ; perf_guest =1 ; - argc =parse_options (argc, argv, kvm_options, kvm_usage, -PARSE_OPT_STOP_AT_NON_OPTION ); + argc =parse_options_subcommand (argc, argv, kvm_options, kvm_subcommands, kvm_usage, +PARSE_OPT_STOP_AT_NON_OPTION );if (!argc)usage_with_options (kvm_usage, kvm_options);
tools/perf/builtin-probe.c +7 -5
@@ -268,9 +268,9 @@ static int opt_set_filter(const struct option *opt __maybe_unused,return 0 ; } -static void init_params (void ) +static int init_params (void ) { -line_range__init (¶ms.line_range); +return line_range__init (¶ms.line_range); }static void cleanup_params (void )
@@ -515,9 +515,11 @@ int cmd_probe(int argc, const char **argv, const char *prefix) {int ret; -init_params (); - ret =__cmd_probe (argc, argv, prefix); -cleanup_params (); + ret =init_params (); +if (!ret) { + ret =__cmd_probe (argc, argv, prefix); +cleanup_params (); + }return ret; }
tools/perf/builtin-record.c +24 -6
@@ -649,7 +649,7 @@ error:return ret; } -#ifdef HAVE_LIBUNWIND_SUPPORT +#ifdef HAVE_DWARF_UNWIND_SUPPORT static int get_stack_size (char *str,unsigned long *_size) {char *endptr;
@@ -675,7 +675,7 @@ static int get_stack_size(char *str, unsigned long *_size) max_size, str); return -1; } -#endif /* HAVE_LIBUNWIND_SUPPORT */ +#endif /* HAVE_DWARF_UNWIND_SUPPORT */ int record_parse_callchain (const char *arg,struct record_opts *opts) {
@@ -704,7 +704,7 @@ int record_parse_callchain(const char *arg, struct record_opts *opts) "needed for -g fp\n");break ; -#ifdef HAVE_LIBUNWIND_SUPPORT +#ifdef HAVE_DWARF_UNWIND_SUPPORT /* Dwarf style */ }else if (!strncmp (name,"dwarf" ,sizeof ("dwarf" ))) {const unsigned long default_stack_dump_size =8192 ;
@@ -720,7 +720,7 @@ int record_parse_callchain(const char *arg, struct record_opts *opts) ret =get_stack_size (tok, &size); opts->stack_dump_size = size; } -#endif /* HAVE_LIBUNWIND_SUPPORT */ +#endif /* HAVE_DWARF_UNWIND_SUPPORT */ }else {pr_err ("callchain: Unknown --call-graph option " "value: %s\n" , arg);
@@ -735,7 +735,9 @@ int record_parse_callchain(const char *arg, struct record_opts *opts)static void callchain_debug (struct record_opts *opts) { -pr_debug ("callchain: type %d\n" , opts->call_graph); +static const char *str[CALLCHAIN_MAX ] = {"NONE" ,"FP" ,"DWARF" }; + +pr_debug ("callchain: type %s\n" , str[opts->call_graph]);if (opts->call_graph ==CALLCHAIN_DWARF ) pr_debug("callchain: stack dump size %d\n",
@@ -749,6 +751,8 @@ int record_parse_callchain_opt(const struct option *opt,struct record_opts *opts = opt->value;int ret; + opts->call_graph_enabled = !unset; +/* --no-call-graph */ if (unset) { opts->call_graph =CALLCHAIN_NONE ;
@@ -769,6 +773,8 @@ int record_callchain_opt(const struct option *opt, {struct record_opts *opts = opt->value; + opts->call_graph_enabled = !unset; +if (opts->call_graph ==CALLCHAIN_NONE ) opts->call_graph =CALLCHAIN_FP ;
@@ -776,6 +782,16 @@ int record_callchain_opt(const struct option *opt,return 0 ; } +static int perf_record_config (const char *var,const char *value,void *cb) +{ +struct record *rec = cb; + +if (!strcmp (var,"record.call-graph" )) +return record_parse_callchain (value, &rec->opts); + +return perf_default_config (var, value, cb); +} +static const char *const record_usage[] = {"perf record [<options>] [<command>]" ,"perf record [<options>] -- <command> [<options>]" ,
@@ -807,7 +823,7 @@ static struct record record = {#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: " -#ifdef HAVE_LIBUNWIND_SUPPORT +#ifdef HAVE_DWARF_UNWIND_SUPPORT const char record_callchain_help[] =CALLCHAIN_HELP "fp dwarf" ;#else const char record_callchain_help[] =CALLCHAIN_HELP "fp" ;
@@ -907,6 +923,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)if (rec->evlist ==NULL )return -ENOMEM ; +perf_config (perf_record_config, rec); + argc =parse_options (argc, argv, record_options, record_usage,PARSE_OPT_STOP_AT_NON_OPTION );if (!argc &&target__none (&rec->opts.target))
tools/perf/builtin-report.c +11 -17
@@ -75,13 +75,10 @@ static int report__config(const char *var, const char *value, void *cb)return perf_default_config (var, value, cb); } -static int report__add_mem_hist_entry (struct perf_tool *tool,struct addr_location *al, -struct perf_sample *sample,struct perf_evsel *evsel, -union perf_event *event) +static int report__add_mem_hist_entry (struct report *rep,struct addr_location *al, +struct perf_sample *sample,struct perf_evsel *evsel) { - struct report *rep = container_of(tool, struct report, tool);struct symbol *parent =NULL ; -u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct hist_entry *he;struct mem_info *mi, *mx;uint64_t cost;
@@ -90,7 +87,7 @@ static int report__add_mem_hist_entry(struct perf_tool *tool, struct addr_locatiif (err)return err; - mi =machine__resolve_mem (al->machine, al->thread, sample, cpumode); + mi =sample__resolve_mem (sample, al);if (!mi)return -ENOMEM ;
@@ -131,10 +128,9 @@ out:return err; } -static int report__add_branch_hist_entry (struct perf_tool *tool,struct addr_location *al, +static int report__add_branch_hist_entry (struct report *rep,struct addr_location *al,struct perf_sample *sample,struct perf_evsel *evsel) { - struct report *rep = container_of(tool, struct report, tool);struct symbol *parent =NULL ;unsigned i;struct hist_entry *he;
@@ -144,8 +140,7 @@ static int report__add_branch_hist_entry(struct perf_tool *tool, struct addr_locif (err)return err; - bi =machine__resolve_bstack (al->machine, al->thread, - sample->branch_stack); + bi =sample__resolve_bstack (sample, al);if (!bi)return -ENOMEM ;
@@ -190,10 +185,9 @@ out:return err; } -static int report__add_hist_entry (struct perf_tool *tool,struct perf_evsel *evsel, +static int report__add_hist_entry (struct report *rep,struct perf_evsel *evsel,struct addr_location *al,struct perf_sample *sample) { - struct report *rep = container_of(tool, struct report, tool);struct symbol *parent =NULL ;struct hist_entry *he;int err =sample__resolve_callchain (sample, &parent, evsel, al, rep->max_stack);
@@ -237,25 +231,25 @@ static int process_sample_event(struct perf_tool *tool,return -1 ; } -if (al.filtered || (rep->hide_unresolved && al.sym ==NULL )) +if (rep->hide_unresolved && al.sym ==NULL )return 0 ;if (rep->cpu_list && !test_bit (sample->cpu, rep->cpu_bitmap))return 0 ;if (sort__mode ==SORT_MODE__BRANCH ) { - ret =report__add_branch_hist_entry (tool, &al, sample, evsel); + ret =report__add_branch_hist_entry (rep, &al, sample, evsel);if (ret <0 )pr_debug ("problem adding lbr entry, skipping event\n" ); }else if (rep->mem_mode ==1 ) { - ret =report__add_mem_hist_entry (tool, &al, sample, evsel, event); + ret =report__add_mem_hist_entry (rep, &al, sample, evsel);if (ret <0 )pr_debug ("problem adding mem entry, skipping event\n" ); }else {if (al.map !=NULL ) al.map->dso->hit =1 ; - ret =report__add_hist_entry (tool, evsel, &al, sample); + ret =report__add_hist_entry (rep, evsel, &al, sample);if (ret <0 )pr_debug ("problem incrementing symbol period, skipping event\n" ); }
@@ -934,7 +928,7 @@ repeat:* so don't allocate extra space that won't be used in the stdio * implementation. */ -if (use_browser ==1 && sort__has_sym) { +if (ui__has_annotation ()) { symbol_conf.priv_size =sizeof (struct annotation );machines__set_symbol_filter (&session->machines, symbol__annotate_init);
tools/perf/builtin-sched.c +5 -5
@@ -1124,7 +1124,7 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ avg = work_list->total_lat / work_list->nb_atoms; - printf("|%11.3f ms |%9" PRIu64 " | avg:%9.3f ms | max:%9.3f ms | max at: %9.6f s\n", + printf("|%11.3f ms |%9" PRIu64 " | avg:%9.3f ms | max:%9.3f ms | max at: %13.6f s\n", (double)work_list->total_runtime / 1e6, work_list->nb_atoms, (double)avg / 1e6, (double)work_list->max_lat / 1e6,
@@ -1527,9 +1527,9 @@ static int perf_sched__lat(struct perf_sched *sched)perf_sched__sort_lat (sched); -printf ("\n ---------------------------------------------------------------------------------------------------------------\n" ); -printf (" Task | Runtime ms | Switches | Average delay ms | Maximum delay ms | Maximum delay at |\n" ); -printf (" ---------------------------------------------------------------------------------------------------------------\n" ); +printf ("\n -----------------------------------------------------------------------------------------------------------------\n" ); +printf (" Task | Runtime ms | Switches | Average delay ms | Maximum delay ms | Maximum delay at |\n" ); +printf (" -----------------------------------------------------------------------------------------------------------------\n" ); next =rb_first (&sched->sorted_atom_root);
@@ -1541,7 +1541,7 @@ static int perf_sched__lat(struct perf_sched *sched) next =rb_next (next); } -printf (" -----------------------------------------------------------------------------------------\n" ); +printf (" -----------------------------------------------------------------------------------------------------------------\n" );printf (" TOTAL: |%11.3f ms |%9" PRIu64" |\n" , (double )sched->all_runtime /1e6 , sched->all_count);
tools/perf/builtin-timechart.c +2 -2
@@ -494,7 +494,7 @@ static const char *cat_backtrace(union perf_event *event,continue ; } - tal.filtered = false; + tal.filtered =0 ;thread__find_addr_location (al.thread, machine, cpumode,MAP__FUNCTION , ip, &tal);
@@ -1238,7 +1238,7 @@ static int timechart__record(struct timechart *tchart, int argc, const char **arfor (i =0 ; i < old_power_args_nr; i++) *p++ =strdup (old_power_args[i]); -for (j =1 ; j < (unsigned int )argc; j++) +for (j =0 ; j < (unsigned int )argc; j++) *p++ = argv[j];return cmd_record (rec_argc, rec_argv,NULL );
tools/perf/builtin-top.c +12 -0
@@ -993,6 +993,16 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)return record_parse_callchain_opt (opt, arg, unset); } +static int perf_top_config (const char *var,const char *value,void *cb) +{ +struct perf_top *top = cb; + +if (!strcmp (var,"top.call-graph" )) +return record_parse_callchain (value, &top->record_opts); + +return perf_default_config (var, value, cb); +} +static int parse_percent_limit (const struct option *opt,const char *arg,int unset__maybe_unused )
@@ -1117,6 +1127,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)if (top.evlist ==NULL )return -ENOMEM ; +perf_config (perf_top_config, &top); + argc =parse_options (argc, argv, options, top_usage,0 );if (argc)usage_with_options (top_usage, options);
tools/perf/config/Makefile +169 -63
288 lines not on this page · raw message
tools/perf/config/feature-checks/Makefile +5 -1
@@ -26,7 +26,8 @@ FILES= \ test-libunwind-debug-frame.bin \ test-on-exit.bin \ test-stackprotector-all.bin \ - test-timerfd.bin + test-timerfd.bin \ + test-libdw-dwarf-unwind.bin CC := $(CROSS_COMPILE)gcc -MD PKG_CONFIG := $(CROSS_COMPILE)pkg-config
@@ -141,6 +142,9 @@ test-backtrace.bin: test-timerfd.bin: $(BUILD) +test-libdw-dwarf-unwind.bin: + $(BUILD) + -include *.d ###############################
tools/perf/config/feature-checks/test-all.c +5 -0
@@ -89,6 +89,10 @@# include "test-stackprotector-all.c" #undef main +#define main main_test_libdw_dwarf_unwind +# include "test-libdw-dwarf-unwind.c" +#undef main +int main (int argc,char *argv[]) {main_test_libpython ();
@@ -111,6 +115,7 @@ int main(int argc, char *argv[])main_test_libnuma ();main_test_timerfd ();main_test_stackprotector_all (); +main_test_libdw_dwarf_unwind ();return 0 ; }
tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c new file +13 -0
@@ -0,0 +1,13 @@ + +#include <elfutils/libdwfl.h> + +int main (void ) +{ +/* +* This function is guarded via: __nonnull_attribute__ (1, 2). +* Passing '1' as arguments value. This code is never executed, +* only compiled. +*/ +dwfl_thread_getframes ((void *)1 , (void *)1 ,NULL ); +return 0 ; +}
tools/perf/design.txt +6 -6
@@ -18,7 +18,7 @@ underlying hardware counters. Performance counters are accessed via special file descriptors. There's one file descriptor per virtual counter used. -The special file descriptor is opened via the perf_event_open() +The special file descriptor is opened via the sys_perf_event_open() system call: int sys_perf_event_open(struct perf_event_attr *hw_event_uptr,
@@ -82,7 +82,7 @@ machine-specific. If 'raw_type' is 0, then the 'type' field says what kind of counter this is, with the following encoding: -enum perf_event_types { +enum perf_type_id { PERF_TYPE_HARDWARE = 0, PERF_TYPE_SOFTWARE = 1, PERF_TYPE_TRACEPOINT = 2,
@@ -95,7 +95,7 @@ specified by 'event_id': * Generalized performance counter event types, used by the hw_event.event_id * parameter of the sys_perf_event_open() syscall: */ -enum hw_event_ids { +enum perf_hw_id { /* * Common hardware events, generalized by the kernel: */
@@ -129,7 +129,7 @@ software events, selected by 'event_id': * physical and sw events of the kernel (and allow the profiling of them as * well): */ -enum sw_event_ids { +enum perf_sw_ids { PERF_COUNT_SW_CPU_CLOCK = 0, PERF_COUNT_SW_TASK_CLOCK = 1, PERF_COUNT_SW_PAGE_FAULTS = 2,
@@ -230,7 +230,7 @@ these events are recorded in the ring-buffer (see below). The 'comm' bit allows tracking of process comm data on process creation. This too is recorded in the ring-buffer (see below). -The 'pid' parameter to the perf_event_open() system call allows the +The 'pid' parameter to the sys_perf_event_open() system call allows the counter to be specific to a task: pid == 0: if the pid parameter is zero, the counter is attached to the
@@ -260,7 +260,7 @@ The 'flags' parameter is currently unused and must be zero. The 'group_fd' parameter allows counter "groups" to be set up. A counter group has one counter which is the group "leader". The leader -is created first, with group_fd = -1 in the perf_event_open call +is created first, with group_fd = -1 in the sys_perf_event_open call that creates it. The rest of the group members are created subsequently, with group_fd giving the fd of the group leader. (A single counter on its own is created with group_fd = -1 and is
tools/perf/perf-completion.sh +1 -1
@@ -123,7 +123,7 @@ __perf_main () __perfcomp_colon "$evts" "$cur" # List subcommands for 'perf kvm' elif [[ $prev == "kvm" ]]; then - subcmds="top record report diff buildid-list stat" + subcmds=$($cmd $prev --list-cmds) __perfcomp_colon "$subcmds" "$cur" # List long option names elif [[ $cur == --* ]]; then
tools/perf/perf.h +9 -1
@@ -12,6 +12,9 @@#ifndef __NR_perf_event_open# define __NR_perf_event_open 336#endif +#ifndef __NR_futex +# define __NR_futex 240 +#endif #endif #if defined(__x86_64__)
@@ -23,6 +26,9 @@#ifndef __NR_perf_event_open# define __NR_perf_event_open 298#endif +#ifndef __NR_futex +# define __NR_futex 202 +#endif #endif #ifdef __powerpc__
@@ -251,12 +257,14 @@ void pthread__unblock_sigwinch(void);enum perf_call_graph_mode {CALLCHAIN_NONE ,CALLCHAIN_FP , -CALLCHAIN_DWARF +CALLCHAIN_DWARF , +CALLCHAIN_MAX };struct record_opts {struct target target;int call_graph; +bool call_graph_enabled;bool group;bool inherit_stat;bool no_buffering;
tools/perf/tests/builtin-test.c +8 -0
@@ -115,6 +115,14 @@ static struct test { .desc = "Test parsing with no sample_id_all bit set", .func = test__parse_no_sample_id_all, }, +#if defined(__x86_64__) || defined(__i386__) +#ifdef HAVE_DWARF_UNWIND_SUPPORT + { + .desc = "Test dwarf unwind", + .func = test__dwarf_unwind, + }, +#endif +#endif { .func = NULL,
Lines of this file are not shown. View the raw message.
tools/perf/tests/dwarf-unwind.c new file +144 -0
144 lines not on this page · raw message
tools/perf/ui/browsers/hists.c +40 -82
122 lines not on this page · raw message
tools/perf/ui/gtk/hists.c +13 -65
78 lines not on this page · raw message
tools/perf/ui/hist.c +100 -38
138 lines not on this page · raw message
tools/perf/util/event.c +116 -72
188 lines not on this page · raw message
tools/perf/util/evsel.c +40 -20
60 lines not on this page · raw message
tools/perf/util/include/linux/hash.h deleted +0 -5
Lines of this file are not shown. View the raw message.
tools/perf/util/include/linux/prefetch.h deleted +0 -6
Lines of this file are not shown. View the raw message.
tools/perf/util/machine.c +32 -47
79 lines not on this page · raw message
tools/perf/util/probe-event.c +475 -388
863 lines not on this page · raw message
tools/perf/util/probe-finder.c +47 -151
198 lines not on this page · raw message
tools/perf/util/symbol.c +53 -10
63 lines not on this page · raw message
tools/perf/util/unwind-libdw.c new file +210 -0
210 lines not on this page · raw message
tools/perf/util/unwind-libdw.h new file +21 -0
Lines of this file are not shown. View the raw message.
tools/perf/util/unwind-libunwind.c renamed from tools/perf/util/unwind.c +16 -34
50 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.