Skip to contentSkip to conversation

perf tree updates for v3.20

GIT PULL Ingo Molnar 1 participant 1 message Feb 9, 2015

Subsystems (6)
x86 perf events Tracing Scheduler +2 more subsystems
lore
Share & tools
lore
#0 lore raw

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: 2fde4f94e0a9531251e706fa57131b51b0df042e perf: Decouple unthrottling and rotating

Kernel side changes:

- AMD range breakpoints support:

Extend breakpoint tools and core to support address range through perf event with initial backend support for AMD extended breakpoints.

Syntax is:

perf record -e mem:addr/len:type

For example set write breakpoint from 0x1000 to 0x1200 (0x1000 + 512)

perf record -e mem:0x1000/512:w

- event throttling/rotating fixes

- various event group handling fixes, cleanups and general paranoia code to be more robust against bugs in the future.

- kernel stack overhead fixes

Tooling side changes:

User visible changes:

- Show precise number of samples in at the end of a 'record' session, if processing build ids, since we will then traverse the whole perf.data file and see all the PERF_RECORD_SAMPLE records, otherwise stop showing the previous off-base heuristicly counted number of "samples" (Namhyung Kim).

- Support to read compressed module from build-id cache (Namhyung Kim)

- Enable sampling loads and stores simultaneously in 'perf mem' (Stephane Eranian)

- 'perf diff' output improvements (Namhyung Kim)

- Fix error reporting for evsel pgfault constructor (Arnaldo Carvalho de Melo)

Infrastructure changes:

- Cache eh/debug frame offset for dwarf unwind (Namhyung Kim)

- Support parsing parameterized events (Cody P Schafer)

- Add support for IP address formats in libtraceevent (David Ahern)

Plus other misc fixes.

Thanks,

Ingo

------------------>
Arnaldo Carvalho de Melo (9):
perf mem: Move the mem_operations global to struct perf_mem perf tools: Remove EOL whitespaces
perf hists: Rename hist_entry__free to __delete
perf hists: Introduce function for deleting/removing hist_entry tools lib fs: Adopt debugfs open strerrno method
tools lib fs: Pass filename to debugfs__strerror_open
perf trace: Fix error reporting for evsel pgfault constructor tools lib fs debugfs: Introduce debugfs__strerror_open_tp tools lib fs debugfs: Check if debugfs is mounted when handling ENOENT

Cody P Schafer (4):
perf tools: Support parsing parameterized events perf tools: Extend format_alias() to include event parameters perf Documentation: Add event parameters
perf tools: Document parameterized and symbolic events

David Ahern (1):
tools lib traceevent: Add support for IP address formats

Jacob Shin (4):
perf/x86/amd: AMD support for bp_len > HW_BREAKPOINT_LEN_8 perf tools: allow user to specify hardware breakpoint bp_len perf tools: add hardware breakpoint bp_len test cases perf/x86: Remove get_hbp_len and replace with bp_len

Jiri Olsa (1):
perf: Use POLLIN instead of POLL_IN for perf poll data in flag

Mark Rutland (2):
perf: Drop module reference on event init failure
perf: Decouple unthrottling and rotating

Namhyung Kim (17):
perf report: Get rid of report__inc_stat()
perf tools: Allow use of an exclusive option more than once perf diff: Get rid of hists__compute_resort()
perf diff: Print diff result more precisely
perf diff: Introduce fmt_to_data_file() helper
perf tools: Pass struct perf_hpp_fmt to its callbacks perf diff: Fix output ordering to honor next column perf diff: Fix -o/--order option behavior
perf ui/tui: Show fatal error message only if exists perf callchain: Cache eh/debug frame offset for dwarf unwind perf tools: Do not use __perf_session__process_events() directly perf record: Show precise number of samples
perf header: Set header version correctly
perf evsel: Set attr.task bit for a tracking event
perf symbols: Support to read compressed module from build-id cache perf tools: Use perf_data_file__fd() consistently
perf symbols: Convert lseek + read to pread

Peter Zijlstra (3):
perf: Add a bit of paranoia
perf: Fix event->ctx locking
perf: Fix put_event() ctx lock

Peter Zijlstra (Intel) (2):
perf: Avoid horrible stack usage
perf: Fix move_group() order

Rasmus Villemoes (1):
perf tests: Fix typo in sample-parsing.c

Rickard Strandqvist (1):
perf tools: Remove some unused functions from color.c

Stephane Eranian (1):
perf mem: Enable sampling loads and stores simultaneously

Vineet Gupta (2):
perf evsel: Don't rely on malloc working for sz 0 perf tools: Provide stub for missing pthread_attr_setaffinity_np

 .../testing/sysfs-bus-event_source-devices-events  |   6 +
 arch/x86/include/asm/cpufeature.h                  |   2 +
 arch/x86/include/asm/debugreg.h                    |   5 +
 arch/x86/include/asm/hw_breakpoint.h               |   1 +
 arch/x86/include/uapi/asm/msr-index.h              |   4 +
 arch/x86/kernel/cpu/amd.c                          |  19 +
 arch/x86/kernel/hw_breakpoint.c                    |  45 +-
 include/linux/ftrace_event.h                       |   2 +-
 include/linux/perf_event.h                         |  30 +-
 include/trace/ftrace.h                             |   7 +-
 kernel/events/core.c                               | 464 +++++++++++++++------
 kernel/events/ring_buffer.c                        |   3 +-
 kernel/sched/core.c                                |   2 +-
 kernel/trace/trace_event_perf.c                    |   4 +-
 kernel/trace/trace_kprobe.c                        |   4 +-
 kernel/trace/trace_syscalls.c                      |   4 +-
 kernel/trace/trace_uprobe.c                        |   2 +-
 tools/lib/api/fs/debugfs.c                         |  43 ++
 tools/lib/api/fs/debugfs.h                         |   3 +
 tools/lib/traceevent/event-parse.c                 | 328 +++++++++++++++
 tools/perf/Documentation/perf-buildid-cache.txt    |   2 +-
 tools/perf/Documentation/perf-list.txt             |  13 +
 tools/perf/Documentation/perf-mem.txt              |   9 +-
 tools/perf/Documentation/perf-record.txt           |  19 +-
 tools/perf/Documentation/perf-script.txt           |  28 +-
 tools/perf/Documentation/perf-stat.txt             |  20 +-
 tools/perf/bench/futex.h                           |  13 +
 tools/perf/builtin-buildid-cache.c                 |   4 +-
 tools/perf/builtin-diff.c                          | 248 +++++++----
 tools/perf/builtin-inject.c                        |   5 +-
 tools/perf/builtin-mem.c                           | 131 ++++--
 tools/perf/builtin-record.c                        |  70 +++-
 tools/perf/builtin-report.c                        |  16 +-
 tools/perf/builtin-stat.c                          |   2 +-
 tools/perf/builtin-top.c                           |   2 +-
 tools/perf/builtin-trace.c                         | 106 ++---
 tools/perf/config/Makefile                         |   6 +
 tools/perf/config/feature-checks/Makefile          |   4 +
 tools/perf/config/feature-checks/test-all.c        |   5 +
 .../test-pthread-attr-setaffinity-np.c             |  14 +
 tools/perf/tests/attr.py                           |   1 -
 tools/perf/tests/hists_cumulate.c                  |   2 +-
 tools/perf/tests/hists_output.c                    |   2 +-
 tools/perf/tests/make                              |   1 -
 tools/perf/tests/parse-events.c                    |  60 ++-
 tools/perf/tests/sample-parsing.c                  |   2 +-
 tools/perf/ui/browsers/annotate.c                  |   3 +-
 tools/perf/ui/hist.c                               |  12 +-
 tools/perf/ui/progress.h                           |   4 +-
 tools/perf/ui/tui/helpline.c                       |   3 +
 tools/perf/ui/tui/setup.c                          |   3 +-
 tools/perf/util/annotate.c                         |   2 +-
 tools/perf/util/color.c                            | 126 ------
 tools/perf/util/color.h                            |   2 -
 tools/perf/util/dso.c                              |   6 +-
 tools/perf/util/dso.h                              |   1 +
 tools/perf/util/evlist.c                           |  27 --
 tools/perf/util/evlist.h                           |   1 -
 tools/perf/util/evsel.c                            |   4 +
 tools/perf/util/header.c                           |   2 +-
 tools/perf/util/hist.c                             |  48 +--
 tools/perf/util/hist.h                             |  11 +-
 tools/perf/util/parse-events.c                     |  27 +-
 tools/perf/util/parse-events.h                     |   3 +-
 tools/perf/util/parse-events.l                     |   1 +
 tools/perf/util/parse-events.y                     |  26 +-
 tools/perf/util/parse-options.c                    |   2 +-
 tools/perf/util/pmu.c                              | 102 ++++-
 tools/perf/util/python.c                           |   2 +-
 .../util/scripting-engines/trace-event-python.c    |   2 +-
 tools/perf/util/session.c                          |   8 +-
 tools/perf/util/session.h                          |   3 -
 tools/perf/util/sort.c                             |  37 +-
 tools/perf/util/symbol-elf.c                       |  13 +-
 tools/perf/util/symbol.c                           |   2 +-
 tools/perf/util/unwind-libunwind.c                 |  31 +-
 76 files changed, 1611 insertions(+), 666 deletions(-)
 create mode 100644 tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
Documentation/ABI/testing/sysfs-bus-event_source-devices-events +6 -0
index 20979f8b3edb..505f080d20a1 100644
@@ -52,12 +52,18 @@ Description:	Per-pmu performance monitoring events specific to the running syste
 			event=0x2abc
 			event=0x423,inv,cmask=0x3
 			domain=0x1,offset=0x8,starting_index=0xffff
+			domain=0x1,offset=0x8,core=?
 
 		Each of the assignments indicates a value to be assigned to a
 		particular set of bits (as defined by the format file
 		corresponding to the <term>) in the perf_event structure passed
 		to the perf_open syscall.
 
+		In the case of the last example, a value replacing "?" would
+		need to be provided by the user selecting the particular event.
+		This is referred to as "event parameterization". Event
+		parameters have the format 'param=?'.
+
 What: /sys/bus/event_source/devices/<pmu>/events/<event>.unit
 Date: 2014/02/24
 Contact:	Linux kernel mailing list <[email protected]>
arch/x86/include/asm/cpufeature.h +2 -0
index aede2c347bde..90a54851aedc 100644
@@ -174,6 +174,7 @@
 #define X86_FEATURE_TOPOEXT	( 6*32+22) /* topology extensions CPUID leafs */
 #define X86_FEATURE_PERFCTR_CORE ( 6*32+23) /* core performance counter extensions */
 #define X86_FEATURE_PERFCTR_NB  ( 6*32+24) /* NB performance counter extensions */
+#define X86_FEATURE_BPEXT	(6*32+26) /* data breakpoint extension */
 #define X86_FEATURE_PERFCTR_L2	( 6*32+28) /* L2 performance counter extensions */
 
 /*
@@ -388,6 +389,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
 #define cpu_has_cx16		boot_cpu_has(X86_FEATURE_CX16)
 #define cpu_has_eager_fpu	boot_cpu_has(X86_FEATURE_EAGER_FPU)
 #define cpu_has_topoext		boot_cpu_has(X86_FEATURE_TOPOEXT)
+#define cpu_has_bpext		boot_cpu_has(X86_FEATURE_BPEXT)
 
 #if __GNUC__ >= 4
 extern void warn_pre_alternatives(void);
arch/x86/include/asm/debugreg.h +5 -0
index 61fd18b83b6c..12cb66f6d3a5 100644
@@ -114,5 +114,10 @@ static inline void debug_stack_usage_inc(void) { }
 static inline void debug_stack_usage_dec(void) { }
 #endif /* X86_64 */
 
+#ifdef CONFIG_CPU_SUP_AMD
+extern void set_dr_addr_mask(unsigned long mask, int dr);
+#else
+static inline void set_dr_addr_mask(unsigned long mask, int dr) { }
+#endif
 
 #endif /* _ASM_X86_DEBUGREG_H */
arch/x86/include/asm/hw_breakpoint.h +1 -0
index ef1c4d2d41ec..6c98be864a75 100644
@@ -12,6 +12,7 @@
  */
 struct arch_hw_breakpoint {
 	unsigned long	address;
+	unsigned long	mask;
 	u8		len;
 	u8		type;
 };
arch/x86/include/uapi/asm/msr-index.h +4 -0
index c8aa65d56027..d979e5abae55 100644
@@ -251,6 +251,10 @@
 /* Fam 16h MSRs */
 #define MSR_F16H_L2I_PERF_CTL		0xc0010230
 #define MSR_F16H_L2I_PERF_CTR		0xc0010231
+#define MSR_F16H_DR1_ADDR_MASK		0xc0011019
+#define MSR_F16H_DR2_ADDR_MASK		0xc001101a
+#define MSR_F16H_DR3_ADDR_MASK		0xc001101b
+#define MSR_F16H_DR0_ADDR_MASK		0xc0011027
 
 /* Fam 15h MSRs */
 #define MSR_F15H_PERF_CTL		0xc0010200
arch/x86/kernel/cpu/amd.c +19 -0
index 15c5df92f74e..a220239cea65 100644
@@ -869,3 +869,22 @@ static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
 
 	return false;
 }
+
+void set_dr_addr_mask(unsigned long mask, int dr)
+{
+	if (!cpu_has_bpext)
+		return;
+
+	switch (dr) {
+	case 0:
+		wrmsr(MSR_F16H_DR0_ADDR_MASK, mask, 0);
+		break;
+	case 1:
+	case 2:
+	case 3:
+		wrmsr(MSR_F16H_DR1_ADDR_MASK - 1 + dr, mask, 0);
+		break;
+	default:
+		break;
+	}
+}
arch/x86/kernel/hw_breakpoint.c +17 -28

94 lines not on this page · raw message

include/linux/ftrace_event.h +1 -1
index 0bebb5c348b8..d36f68b08acc 100644
@@ -595,7 +595,7 @@ extern int  ftrace_profile_set_filter(struct perf_event *event, int event_id,
 				     char *filter_str);
 extern void ftrace_profile_free_filter(struct perf_event *event);
 extern void *perf_trace_buf_prepare(int size, unsigned short type,
-				    struct pt_regs *regs, int *rctxp);
+				    struct pt_regs **regs, int *rctxp);
 
 static inline void
 perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
include/linux/perf_event.h +22 -8
index 664de5a4ec46..5cad0e6f3552 100644
@@ -469,6 +469,7 @@ struct perf_event_context {
 	 */
 	struct mutex			mutex;
 
+	struct list_head		active_ctx_list;
 	struct list_head		pinned_groups;
 	struct list_head		flexible_groups;
 	struct list_head		event_list;
@@ -519,7 +520,6 @@ struct perf_cpu_context {
 	int				exclusive;
 	struct hrtimer			hrtimer;
 	ktime_t				hrtimer_interval;
-	struct list_head		rotation_list;
 	struct pmu			*unique_pmu;
 	struct perf_cgroup		*cgrp;
 };
@@ -659,6 +659,7 @@ static inline int is_software_event(struct perf_event *event)
 
 extern struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
 
+extern void ___perf_sw_event(u32, u64, struct pt_regs *, u64);
 extern void __perf_sw_event(u32, u64, struct pt_regs *, u64);
 
 #ifndef perf_arch_fetch_caller_regs
@@ -683,14 +684,25 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs)
 static __always_inline void
 perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
 {
-	struct pt_regs hot_regs;
+	if (static_key_false(&perf_swevent_enabled[event_id]))
+		__perf_sw_event(event_id, nr, regs, addr);
+}
+
+DECLARE_PER_CPU(struct pt_regs, __perf_regs[4]);
 
+/*
+ * 'Special' version for the scheduler, it hard assumes no recursion,
+ * which is guaranteed by us not actually scheduling inside other swevents
+ * because those disable preemption.
+ */
+static __always_inline void
+perf_sw_event_sched(u32 event_id, u64 nr, u64 addr)
+{
 	if (static_key_false(&perf_swevent_enabled[event_id])) {
-		if (!regs) {
-			perf_fetch_caller_regs(&hot_regs);
-			regs = &hot_regs;
-		}
-		__perf_sw_event(event_id, nr, regs, addr);
+		struct pt_regs *regs = this_cpu_ptr(&__perf_regs[0]);
+
+		perf_fetch_caller_regs(regs);
+		___perf_sw_event(event_id, nr, regs, addr);
 	}
 }
 
@@ -706,7 +718,7 @@ static inline void perf_event_task_sched_in(struct task_struct *prev,
 static inline void perf_event_task_sched_out(struct task_struct *prev,
 					     struct task_struct *next)
 {
-	perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0);
+	perf_sw_event_sched(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 0);
 
 	if (static_key_false(&perf_sched_events.key))
 		__perf_event_task_sched_out(prev, next);
@@ -817,6 +829,8 @@ static inline int perf_event_refresh(struct perf_event *event, int refresh)
 static inline void
 perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)	{ }
 static inline void
+perf_sw_event_sched(u32 event_id, u64 nr, u64 addr)			{ }
+static inline void
 perf_bp_event(struct perf_event *event, void *data)			{ }
 
 static inline int perf_register_guest_info_callbacks
include/trace/ftrace.h +4 -3
index 139b5067345b..27609dfcce25 100644
@@ -763,7 +763,7 @@ perf_trace_##call(void *__data, proto)					\
 	struct ftrace_event_call *event_call = __data;			\
 	struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
 	struct ftrace_raw_##call *entry;				\
-	struct pt_regs __regs;						\
+	struct pt_regs *__regs;						\
 	u64 __addr = 0, __count = 1;					\
 	struct task_struct *__task = NULL;				\
 	struct hlist_head *head;					\
@@ -782,18 +782,19 @@ perf_trace_##call(void *__data, proto)					\
 			     sizeof(u64));				\
 	__entry_size -= sizeof(u32);					\
 									\
-	perf_fetch_caller_regs(&__regs);				\
 	entry = perf_trace_buf_prepare(__entry_size,			\
 			event_call->event.type, &__regs, &rctx);	\
 	if (!entry)							\
 		return;							\
 									\
+	perf_fetch_caller_regs(__regs);					\
+									\
 	tstruct								\
 									\
 	{ assign; }							\
 									\
 	perf_trace_buf_submit(entry, __entry_size, rctx, __addr,	\
-		__count, &__regs, head, __task);			\
+		__count, __regs, head, __task);				\
 }
 
 /*
kernel/events/core.c +344 -120

867 lines not on this page · raw message

kernel/events/ring_buffer.c +2 -1
index 146a5792b1d2..eadb95ce7aac 100644
@@ -13,12 +13,13 @@
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
 #include <linux/circ_buf.h>
+#include <linux/poll.h>
 
 #include "internal.h"
 
 static void perf_output_wakeup(struct perf_output_handle *handle)
 {
-	atomic_set(&handle->rb->poll, POLL_IN);
+	atomic_set(&handle->rb->poll, POLLIN);
 
 	handle->event->pending_wakeup = 1;
 	irq_work_queue(&handle->event->pending);
kernel/sched/core.c +1 -1
index e628cb11b560..ae1188f62693 100644
@@ -1082,7 +1082,7 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
 		if (p->sched_class->migrate_task_rq)
 			p->sched_class->migrate_task_rq(p, new_cpu);
 		p->se.nr_migrations++;
-		perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, NULL, 0);
+		perf_sw_event_sched(PERF_COUNT_SW_CPU_MIGRATIONS, 1, 0);
 	}
 
 	__set_task_cpu(p, new_cpu);
kernel/trace/trace_event_perf.c +3 -1
index 4b9c114ee9de..6fa484de2ba1 100644
@@ -261,7 +261,7 @@ void perf_trace_del(struct perf_event *p_event, int flags)
 }
 
 void *perf_trace_buf_prepare(int size, unsigned short type,
-			     struct pt_regs *regs, int *rctxp)
+			     struct pt_regs **regs, int *rctxp)
 {
 	struct trace_entry *entry;
 	unsigned long flags;
@@ -280,6 +280,8 @@ void *perf_trace_buf_prepare(int size, unsigned short type,
 	if (*rctxp < 0)
 		return NULL;
 
+	if (regs)
+		*regs = this_cpu_ptr(&__perf_regs[*rctxp]);
 	raw_data = this_cpu_ptr(perf_trace_buf[*rctxp]);
 
 	/* zero the dead bytes from align to not leak stack to user */
kernel/trace/trace_kprobe.c +2 -2
index 5edb518be345..296079ae6583 100644
@@ -1148,7 +1148,7 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
 
-	entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
+	entry = perf_trace_buf_prepare(size, call->event.type, NULL, &rctx);
 	if (!entry)
 		return;
 
@@ -1179,7 +1179,7 @@ kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
 
-	entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
+	entry = perf_trace_buf_prepare(size, call->event.type, NULL, &rctx);
 	if (!entry)
 		return;
 
kernel/trace/trace_syscalls.c +2 -2
index c6ee36fcbf90..f97f6e3a676c 100644
@@ -574,7 +574,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 	size -= sizeof(u32);
 
 	rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size,
-				sys_data->enter_event->event.type, regs, &rctx);
+				sys_data->enter_event->event.type, NULL, &rctx);
 	if (!rec)
 		return;
 
@@ -647,7 +647,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 	size -= sizeof(u32);
 
 	rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size,
-				sys_data->exit_event->event.type, regs, &rctx);
+				sys_data->exit_event->event.type, NULL, &rctx);
 	if (!rec)
 		return;
 
kernel/trace/trace_uprobe.c +1 -1
index 8520acc34b18..b11441321e7a 100644
@@ -1111,7 +1111,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
 	if (hlist_empty(head))
 		goto out;
 
-	entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
+	entry = perf_trace_buf_prepare(size, call->event.type, NULL, &rctx);
 	if (!entry)
 		goto out;
 
tools/lib/api/fs/debugfs.c +43 -0

49 lines not on this page · raw message

tools/lib/api/fs/debugfs.h +3 -0
index f19d3df9609d..0739881a9897 100644
@@ -26,4 +26,7 @@ char *debugfs_mount(const char *mountpoint);
 
 extern char debugfs_mountpoint[];
 
+int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename);
+int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
+
 #endif /* __API_DEBUGFS_H__ */
tools/lib/traceevent/event-parse.c +328 -0

346 lines not on this page · raw message

tools/perf/Documentation/perf-buildid-cache.txt +1 -1
index fd77d81ea748..0294c57b1f5e 100644
@@ -38,7 +38,7 @@ OPTIONS
 --remove=::
         Remove specified file from the cache.
 -M::
---missing=:: 
+--missing=::
 	List missing build ids in the cache for the specified file.
 -u::
 --update::
tools/perf/Documentation/perf-list.txt +13 -0
index cbb4f743d921..3e2aec94f806 100644
@@ -89,6 +89,19 @@ MODIFIERS>>.
 You should refer to the processor specific documentation for getting these
 details. Some of them are referenced in the SEE ALSO section below.
 
+PARAMETERIZED EVENTS
+--------------------
+
+Some pmu events listed by 'perf-list' will be displayed with '?' in them. For
+example:
+
+  hv_gpci/dtbp_ptitc,phys_processor_idx=?/
+
+This means that when provided as an event, a value for '?' must
+also be supplied. For example:
+
+  perf stat -C 0 -e 'hv_gpci/dtbp_ptitc,phys_processor_idx=0x2/' ...
+
 OPTIONS
 -------
 
tools/perf/Documentation/perf-mem.txt +5 -4
index 1d78a4064da4..43310d8661fe 100644
@@ -12,11 +12,12 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-"perf mem -t <TYPE> record" runs a command and gathers memory operation data
+"perf mem record" runs a command and gathers memory operation data
 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.
+"perf mem report" displays the result. It invokes perf report with the
+right set of options to display a memory access profile. By default, loads
+and stores are sampled. Use the -t option to limit to loads or stores.
 
 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
@@ -29,7 +30,7 @@ OPTIONS
 
 -t::
 --type=::
-	Select the memory operation type: load or store (default: load)
+	Select the memory operation type: load or store (default: load,store)
 
 -D::
 --dump-raw-samples=::
tools/perf/Documentation/perf-record.txt +17 -2
index af9a54ece024..31e977459c51 100644
@@ -33,12 +33,27 @@ OPTIONS
         - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
 	  hexadecimal event descriptor.
 
-        - a hardware breakpoint event in the form of '\mem:addr[:access]'
+	- a symbolically formed PMU event like 'pmu/param1=0x3,param2/' where
+	  'param1', 'param2', etc are defined as formats for the PMU in
+	  /sys/bus/event_sources/devices/<pmu>/format/*.
+
+	- a symbolically formed event like 'pmu/config=M,config1=N,config3=K/'
+
+          where M, N, K are numbers (in decimal, hex, octal format). Acceptable
+          values for each of 'config', 'config1' and 'config2' are defined by
+          corresponding entries in /sys/bus/event_sources/devices/<pmu>/format/*
+          param1 and param2 are defined as formats for the PMU in:
+          /sys/bus/event_sources/devices/<pmu>/format/*
+
+        - a hardware breakpoint event in the form of '\mem:addr[/len][:access]'
           where addr is the address in memory you want to break in.
           Access is the memory access type (read, write, execute) it can
-          be passed as follows: '\mem:addr[:[r][w][x]]'.
+          be passed as follows: '\mem:addr[:[r][w][x]]'. len is the range,
+          number of bytes from specified addr, which the breakpoint will cover.
           If you want to profile read-write accesses in 0x1000, just set
           'mem:0x1000:rw'.
+          If you want to profile write accesses in [0x1000~1008), just set
+          'mem:0x1000/8:w'.
 
 --filter=<filter>::
         Event filter.
tools/perf/Documentation/perf-script.txt +14 -14
index 21494806c0ab..a21eec05bc42 100644
@@ -125,46 +125,46 @@ OPTIONS
 	is equivalent to:
 
 		perf script -f trace:<fields> -f sw:<fields> -f hw:<fields>
-    
+
 	i.e., the specified fields apply to all event types if the type string
 	is not given.
-    
+
 	The arguments are processed in the order received. A later usage can
 	reset a prior request. e.g.:
-    
+
 		-f trace: -f comm,tid,time,ip,sym
-    
+
 	The first -f suppresses trace events (field list is ""), but then the
 	second invocation sets the fields to comm,tid,time,ip,sym. In this case a
 	warning is given to the user:
-    
+
 		"Overriding previous field request for all events."
-    
+
 	Alternatively, consider the order:
-    
+
 		-f comm,tid,time,ip,sym -f trace:
-    
+
 	The first -f sets the fields for all events and the second -f
 	suppresses trace events. The user is given a warning message about
 	the override, and the result of the above is that only S/W and H/W
 	events are displayed with the given fields.
-    
+
 	For the 'wildcard' option if a user selected field is invalid for an
 	event type, a message is displayed to the user that the option is
 	ignored for that type. For example:
-    
+
 		$ perf script -f comm,tid,trace
 		'trace' not valid for hardware events. Ignoring.
 		'trace' not valid for software events. Ignoring.
-    
+
 	Alternatively, if the type is given an invalid field is specified it
 	is an error. For example:
-    
+
         perf script -v -f sw:comm,tid,trace
         'trace' not valid for software events.
-    
+
 	At this point usage is displayed, and perf-script exits.
-    
+
 	Finally, a user may not set fields to none for all event types.
 	i.e., -f "" is not allowed.
 
tools/perf/Documentation/perf-stat.txt +16 -4
index 29ee857c09c6..04e150d83e7d 100644
@@ -25,10 +25,22 @@ OPTIONS
 
 -e::
 --event=::
-	Select the PMU event. Selection can be a symbolic event name
-	(use 'perf list' to list all events) or a raw PMU
-	event (eventsel+umask) in the form of rNNN where NNN is a
-	 hexadecimal event descriptor.
+	Select the PMU event. Selection can be:
+
+	- a symbolic event name (use 'perf list' to list all events)
+
+	- a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
+	  hexadecimal event descriptor.
+
+	- a symbolically formed event like 'pmu/param1=0x3,param2/' where
+	  param1 and param2 are defined as formats for the PMU in
+	  /sys/bus/event_sources/devices/<pmu>/format/*
+
+	- a symbolically formed event like 'pmu/config=M,config1=N,config2=K/'
+	  where M, N, K are numbers (in decimal, hex, octal format).
+	  Acceptable values for each of 'config', 'config1' and 'config2'
+	  parameters are defined by corresponding entries in
+	  /sys/bus/event_sources/devices/<pmu>/format/*
 
 -i::
 --no-inherit::
tools/perf/bench/futex.h +13 -0
index 71f2844cf97f..7ed22ff1e1ac 100644
@@ -68,4 +68,17 @@ futex_cmp_requeue(u_int32_t *uaddr, u_int32_t val, u_int32_t *uaddr2, int nr_wak
 		 val, opflags);
 }
 
+#ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP
+#include <pthread.h>
+static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
+					      size_t cpusetsize,
+					      cpu_set_t *cpuset)
+{
+	attr = attr;
+	cpusetsize = cpusetsize;
+	cpuset = cpuset;
+	return 0;
+}
+#endif
+
 #endif /* _FUTEX_H */
tools/perf/builtin-buildid-cache.c +2 -2
index 77d5cae54c6a..50e6b66aea1f 100644
@@ -236,10 +236,10 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)
 		if (errno == ENOENT)
 			return false;
 
-		pr_warning("Problems with %s file, consider removing it from the cache\n", 
+		pr_warning("Problems with %s file, consider removing it from the cache\n",
 			   filename);
 	} else if (memcmp(dso->build_id, build_id, sizeof(dso->build_id))) {
-		pr_warning("Problems with %s file, consider removing it from the cache\n", 
+		pr_warning("Problems with %s file, consider removing it from the cache\n",
 			   filename);
 	}
 
tools/perf/builtin-diff.c +157 -91

386 lines not on this page · raw message

tools/perf/builtin-inject.c +3 -2
index 84df2deed988..a13641e066f5 100644
@@ -343,6 +343,7 @@ static int __cmd_inject(struct perf_inject *inject)
 	int ret = -EINVAL;
 	struct perf_session *session = inject->session;
 	struct perf_data_file *file_out = &inject->output;
+	int fd = perf_data_file__fd(file_out);
 
 	signal(SIGINT, sig_handler);
 
@@ -376,7 +377,7 @@ static int __cmd_inject(struct perf_inject *inject)
 	}
 
 	if (!file_out->is_pipe)
-		lseek(file_out->fd, session->header.data_offset, SEEK_SET);
+		lseek(fd, session->header.data_offset, SEEK_SET);
 
 	ret = perf_session__process_events(session, &inject->tool);
 
@@ -385,7 +386,7 @@ static int __cmd_inject(struct perf_inject *inject)
 			perf_header__set_feat(&session->header,
 					      HEADER_BUILD_ID);
 		session->header.data_size = inject->bytes_written;
-		perf_session__write_header(session, session->evlist, file_out->fd, true);
+		perf_session__write_header(session, session->evlist, fd, true);
 	}
 
 	return ret;
tools/perf/builtin-mem.c +104 -27

195 lines not on this page · raw message

tools/perf/builtin-record.c +48 -22

142 lines not on this page · raw message

tools/perf/builtin-report.c +3 -13
index 072ae8ad67fc..2f91094e228b 100644
@@ -86,17 +86,6 @@ static int report__config(const char *var, const char *value, void *cb)
 	return perf_default_config(var, value, cb);
 }
 
-static void report__inc_stats(struct report *rep, struct hist_entry *he)
-{
-	/*
-	 * The @he is either of a newly created one or an existing one
-	 * merging current sample.  We only want to count a new one so
-	 * checking ->nr_events being 1.
-	 */
-	if (he->stat.nr_events == 1)
-		rep->nr_entries++;
-}
-
 static int hist_iter__report_callback(struct hist_entry_iter *iter,
 				      struct addr_location *al, bool single,
 				      void *arg)
@@ -108,8 +97,6 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
 	struct mem_info *mi;
 	struct branch_info *bi;
 
-	report__inc_stats(rep, he);
-
 	if (!ui__has_annotation())
 		return 0;
 
@@ -499,6 +486,9 @@ static int __cmd_report(struct report *rep)
 
 	report__warn_kptr_restrict(rep);
 
+	evlist__for_each(session->evlist, pos)
+		rep->nr_entries += evsel__hists(pos)->nr_entries;
+
 	if (use_browser == 0) {
 		if (verbose > 3)
 			perf_session__fprintf(session, stdout);
tools/perf/builtin-stat.c +1 -1
index 891086376381..e598e4e98170 100644
@@ -1730,7 +1730,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "detailed run - start a lot of events"),
 	OPT_BOOLEAN('S', "sync", &sync_run,
 		    "call sync() before starting a run"),
-	OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL, 
+	OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL,
 			   "print large numbers with thousands\' separators",
 			   stat__set_big_num),
 	OPT_STRING('C', "cpu", &target.cpu_list, "cpu",
tools/perf/builtin-top.c +1 -1
index 616f0fcb4701..c4c7eac69de4 100644
@@ -165,7 +165,7 @@ static void ui__warn_map_erange(struct map *map, struct symbol *sym, u64 ip)
 		    err ? "[unknown]" : uts.release, perf_version_string);
 	if (use_browser <= 0)
 		sleep(5);
-	
+
 	map->erange_warned = true;
 }
 
tools/perf/builtin-trace.c +57 -49

242 lines not on this page · raw message

tools/perf/config/Makefile +6 -0
index 648e31ff4021..cc224080b525 100644
@@ -198,6 +198,7 @@ CORE_FEATURE_TESTS =			\
 	libpython-version		\
 	libslang			\
 	libunwind			\
+	pthread-attr-setaffinity-np	\
 	stackprotector-all		\
 	timerfd				\
 	libdw-dwarf-unwind		\
@@ -226,6 +227,7 @@ VF_FEATURE_TESTS =			\
 	libelf-getphdrnum		\
 	libelf-mmap			\
 	libpython-version		\
+	pthread-attr-setaffinity-np	\
 	stackprotector-all		\
 	timerfd				\
 	libunwind-debug-frame		\
@@ -301,6 +303,10 @@ ifeq ($(feature-sync-compare-and-swap), 1)
   CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
 endif
 
+ifeq ($(feature-pthread-attr-setaffinity-np), 1)
+  CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
+endif
+
 ifndef NO_BIONIC
   $(call feature_check,bionic)
   ifeq ($(feature-bionic), 1)
tools/perf/config/feature-checks/Makefile +4 -0
index 53f19b5dbc37..42ac05aaf8ac 100644
@@ -25,6 +25,7 @@ FILES=					\
 	test-libslang.bin		\
 	test-libunwind.bin		\
 	test-libunwind-debug-frame.bin	\
+	test-pthread-attr-setaffinity-np.bin	\
 	test-stackprotector-all.bin	\
 	test-timerfd.bin		\
 	test-libdw-dwarf-unwind.bin	\
@@ -47,6 +48,9 @@ BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
 test-hello.bin:
 	$(BUILD)
 
+test-pthread-attr-setaffinity-np.bin:
+	$(BUILD) -Werror -lpthread
+
 test-stackprotector-all.bin:
 	$(BUILD) -Werror -fstack-protector-all
 
tools/perf/config/feature-checks/test-all.c +5 -0
index 652e0098eba6..6d4d09323922 100644
@@ -97,6 +97,10 @@
 # include "test-zlib.c"
 #undef main
 
+#define main main_test_pthread_attr_setaffinity_np
+# include "test-pthread_attr_setaffinity_np.c"
+#undef main
+
 int main(int argc, char *argv[])
 {
 	main_test_libpython();
@@ -121,6 +125,7 @@ int main(int argc, char *argv[])
 	main_test_libdw_dwarf_unwind();
 	main_test_sync_compare_and_swap(argc, argv);
 	main_test_zlib();
+	main_test_pthread_attr_setaffinity_np();
 
 	return 0;
 }
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c new file +14 -0
new file mode 100644
index 000000000000..0a0d3ecb4e8a
@@ -0,0 +1,14 @@
+#include <stdint.h>
+#include <pthread.h>
+
+int main(void)
+{
+	int ret = 0;
+	pthread_attr_t thread_attr;
+
+	pthread_attr_init(&thread_attr);
+	/* don't care abt exact args, just the API itself in libpthread */
+	ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
+
+	return ret;
+}
tools/perf/tests/attr.py +0 -1
index c9b4b6269b51..1091bd47adfd 100644
@@ -104,7 +104,6 @@ import ConfigParser
                 continue
             if not self.compare_data(self[t], other[t]):
 		log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
-                
 
 # Test file description needs to have following sections:
 # [config]
tools/perf/tests/hists_cumulate.c +1 -1
index 8d110dec393e..18619966454c 100644
@@ -140,7 +140,7 @@ static void del_hist_entries(struct hists *hists)
 		he = rb_entry(node, struct hist_entry, rb_node);
 		rb_erase(node, root_out);
 		rb_erase(&he->rb_node_in, root_in);
-		hist_entry__free(he);
+		hist_entry__delete(he);
 	}
 }
 
tools/perf/tests/hists_output.c +1 -1
index f5547610da02..b52c9faea224 100644
@@ -106,7 +106,7 @@ static void del_hist_entries(struct hists *hists)
 		he = rb_entry(node, struct hist_entry, rb_node);
 		rb_erase(node, root_out);
 		rb_erase(&he->rb_node_in, root_in);
-		hist_entry__free(he);
+		hist_entry__delete(he);
 	}
 }
 
tools/perf/tests/make +0 -1
index 69a71ff84e01..75709d2b17b4 100644
@@ -222,7 +222,6 @@ clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
 	@cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
 	echo "- $@: $$cmd" && echo $$cmd > $@ && \
 	( eval $$cmd ) >> $@ 2>&1
-	
 
 all: $(run) $(run_O) tarpkg
 	@echo OK
tools/perf/tests/parse-events.c +59 -1

40 lines not on this page · raw message

tools/perf/tests/sample-parsing.c +1 -1
index 4908c648a597..30c02181e78b 100644

Lines of this file are not shown. View the raw message.

tools/perf/ui/browsers/annotate.c +1 -2
index 1e0a2fd80115..9d32e3c0cfee 100644

Lines of this file are not shown. View the raw message.

tools/perf/ui/hist.c +8 -4
index 482adae3cc44..25d608394d74 100644

Lines of this file are not shown. View the raw message.

tools/perf/ui/progress.h +2 -2
index f34f89eb607c..717d39d3052b 100644

Lines of this file are not shown. View the raw message.

tools/perf/ui/tui/helpline.c +3 -0
index 1c8b9afd5d6e..88f5143a5981 100644

Lines of this file are not shown. View the raw message.

tools/perf/ui/tui/setup.c +2 -1
index 3c38f25b1695..b77e1d771363 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/annotate.c +1 -1
index 01bc4e23a2cf..61bf9128e1f2 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/color.c +0 -126

126 lines not on this page · raw message

tools/perf/util/color.h +0 -2
index 0a594b8a0c26..38146f922c54 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/dso.c +1 -5
index 45be944d450a..c2f7d3b90966 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/dso.h +1 -0
index 3782c82c6e44..ced92841ff97 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/evlist.c +0 -27
index 2e507b5025a3..28b8ce86bf12 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/evlist.h +0 -1
index 0ba93f67ab94..c94a9e03ecf1 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/evsel.c +4 -0
index 1e90c8557ede..ea51a90e20a0 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/header.c +1 -1
index b20e40c74468..1f407f7352a7 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/hist.c +23 -25

48 lines not on this page · raw message

tools/perf/util/hist.h +7 -4
index 46bd50344f85..2b690d028907 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/parse-events.c +14 -13
index 77b43fe43d55..7f8ec6ce2823 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/parse-events.h +2 -1
index db2cf78ff0f3..ff6e1fa4111e 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/parse-events.l +1 -0
index 906630bbf8eb..94eacb6c1ef7 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/parse-events.y +24 -2
index 93c4c9fbc922..72def077dbbf 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/parse-options.c +1 -1
index f62dee7bd924..4a015f77e2b5 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/pmu.c +90 -12

102 lines not on this page · raw message

tools/perf/util/python.c +1 -1
index 3dda85ca50c1..d906d0ad5d40 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/scripting-engines/trace-event-python.c +1 -1
index d808a328f4dc..0c815a40a6e8 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/session.c +4 -4
index 5f0e05a76c05..0baf75f12b7c 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/session.h +0 -3
index dc26ebf60fe4..6d663dc76404 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/sort.c +34 -3
index 9139dda9f9a3..7a39c1ed8d37 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/symbol-elf.c +8 -5
index 06fcd1bf98b6..b24f9d8727a8 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/symbol.c +1 -1
index a194702a0a2f..a69066865a55 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/unwind-libunwind.c +20 -11
index 6edf535f65c2..e3c40a520a25 100644

Lines of this file are not shown. View the 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.