Skip to content

Commit

Permalink
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/tip/tip

Pull perf updates from Ingo Molnar:
 "Mostly tooling and PMU driver fixes, but also a number of late updates
  such as the reworking of the call-chain size limiting logic to make
  call-graph recording more robust, plus tooling side changes for the
  new 'backwards ring-buffer' extension to the perf ring-buffer"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (34 commits)
  perf record: Read from backward ring buffer
  perf record: Rename variable to make code clear
  perf record: Prevent reading invalid data in record__mmap_read
  perf evlist: Add API to pause/resume
  perf trace: Use the ptr->name beautifier as default for "filename" args
  perf trace: Use the fd->name beautifier as default for "fd" args
  perf report: Add srcline_from/to branch sort keys
  perf evsel: Record fd into perf_mmap
  perf evsel: Add overwrite attribute and check write_backward
  perf tools: Set buildid dir under symfs when --symfs is provided
  perf trace: Only auto set call-graph to "dwarf" when syscalls are being traced
  perf annotate: Sort list of recognised instructions
  perf annotate: Fix identification of ARM blt and bls instructions
  perf tools: Fix usage of max_stack sysctl
  perf callchain: Stop validating callchains by the max_stack sysctl
  perf trace: Fix exit_group() formatting
  perf top: Use machine->kptr_restrict_warned
  perf trace: Warn when trying to resolve kernel addresses with kptr_restrict=1
  perf machine: Do not bail out if not managing to read ref reloc symbol
  perf/x86/intel/p4: Trival indentation fix, remove space
  ...
  • Loading branch information
torvalds committed May 26, 2016
2 parents c4a3460 + 0c9f790 commit bdc6b75
Show file tree
Hide file tree
Showing 56 changed files with 618 additions and 330 deletions.
14 changes: 14 additions & 0 deletions Documentation/sysctl/kernel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ show up in /proc/sys/kernel:
- perf_cpu_time_max_percent
- perf_event_paranoid
- perf_event_max_stack
- perf_event_max_contexts_per_stack
- pid_max
- powersave-nap [ PPC only ]
- printk
Expand Down Expand Up @@ -668,6 +669,19 @@ The default value is 127.

==============================================================

perf_event_max_contexts_per_stack:

Controls maximum number of stack frame context entries for
(attr.sample_type & PERF_SAMPLE_CALLCHAIN) configured events, for
instance, when using 'perf record -g' or 'perf trace --call-graph fp'.

This can only be done when no events are in use that have callchains
enabled, otherwise writing to this file will return -EBUSY.

The default value is 8.

==============================================================

pid_max:

PID allocation wrap value. When the kernel's next PID value
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -8881,6 +8881,7 @@ F: arch/*/kernel/*/perf_event*.c
F: arch/*/kernel/*/*/perf_event*.c
F: arch/*/include/asm/perf_event.h
F: arch/*/kernel/perf_callchain.c
F: arch/*/events/*
F: tools/perf/

PERSONALITY HANDLING
Expand Down
6 changes: 3 additions & 3 deletions arch/arc/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct arc_callchain_trace {
static int callchain_trace(unsigned int addr, void *data)
{
struct arc_callchain_trace *ctrl = data;
struct perf_callchain_entry *entry = ctrl->perf_stuff;
struct perf_callchain_entry_ctx *entry = ctrl->perf_stuff;
perf_callchain_store(entry, addr);

if (ctrl->depth++ < 3)
Expand All @@ -58,7 +58,7 @@ static int callchain_trace(unsigned int addr, void *data)
}

void
perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
struct arc_callchain_trace ctrl = {
.depth = 0,
Expand All @@ -69,7 +69,7 @@ perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
}

void
perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
/*
* User stack can't be unwound trivially with kernel dwarf unwinder
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/kernel/perf_callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct frame_tail {
*/
static struct frame_tail __user *
user_backtrace(struct frame_tail __user *tail,
struct perf_callchain_entry *entry)
struct perf_callchain_entry_ctx *entry)
{
struct frame_tail buftail;
unsigned long err;
Expand Down Expand Up @@ -59,7 +59,7 @@ user_backtrace(struct frame_tail __user *tail,
}

void
perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
struct frame_tail __user *tail;

Expand All @@ -75,7 +75,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)

tail = (struct frame_tail __user *)regs->ARM_fp - 1;

while ((entry->nr < sysctl_perf_event_max_stack) &&
while ((entry->nr < entry->max_stack) &&
tail && !((unsigned long)tail & 0x3))
tail = user_backtrace(tail, entry);
}
Expand All @@ -89,13 +89,13 @@ static int
callchain_trace(struct stackframe *fr,
void *data)
{
struct perf_callchain_entry *entry = data;
struct perf_callchain_entry_ctx *entry = data;
perf_callchain_store(entry, fr->pc);
return 0;
}

void
perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
struct stackframe fr;

Expand Down
14 changes: 7 additions & 7 deletions arch/arm64/kernel/perf_callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct frame_tail {
*/
static struct frame_tail __user *
user_backtrace(struct frame_tail __user *tail,
struct perf_callchain_entry *entry)
struct perf_callchain_entry_ctx *entry)
{
struct frame_tail buftail;
unsigned long err;
Expand Down Expand Up @@ -76,7 +76,7 @@ struct compat_frame_tail {

static struct compat_frame_tail __user *
compat_user_backtrace(struct compat_frame_tail __user *tail,
struct perf_callchain_entry *entry)
struct perf_callchain_entry_ctx *entry)
{
struct compat_frame_tail buftail;
unsigned long err;
Expand Down Expand Up @@ -106,7 +106,7 @@ compat_user_backtrace(struct compat_frame_tail __user *tail,
}
#endif /* CONFIG_COMPAT */

void perf_callchain_user(struct perf_callchain_entry *entry,
void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) {
Expand All @@ -122,7 +122,7 @@ void perf_callchain_user(struct perf_callchain_entry *entry,

tail = (struct frame_tail __user *)regs->regs[29];

while (entry->nr < sysctl_perf_event_max_stack &&
while (entry->nr < entry->max_stack &&
tail && !((unsigned long)tail & 0xf))
tail = user_backtrace(tail, entry);
} else {
Expand All @@ -132,7 +132,7 @@ void perf_callchain_user(struct perf_callchain_entry *entry,

tail = (struct compat_frame_tail __user *)regs->compat_fp - 1;

while ((entry->nr < sysctl_perf_event_max_stack) &&
while ((entry->nr < entry->max_stack) &&
tail && !((unsigned long)tail & 0x3))
tail = compat_user_backtrace(tail, entry);
#endif
Expand All @@ -146,12 +146,12 @@ void perf_callchain_user(struct perf_callchain_entry *entry,
*/
static int callchain_trace(struct stackframe *frame, void *data)
{
struct perf_callchain_entry *entry = data;
struct perf_callchain_entry_ctx *entry = data;
perf_callchain_store(entry, frame->pc);
return 0;
}

void perf_callchain_kernel(struct perf_callchain_entry *entry,
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
struct stackframe frame;
Expand Down
10 changes: 5 additions & 5 deletions arch/metag/kernel/perf_callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static bool is_valid_call(unsigned long calladdr)

static struct metag_frame __user *
user_backtrace(struct metag_frame __user *user_frame,
struct perf_callchain_entry *entry)
struct perf_callchain_entry_ctx *entry)
{
struct metag_frame frame;
unsigned long calladdr;
Expand All @@ -56,7 +56,7 @@ user_backtrace(struct metag_frame __user *user_frame,
}

void
perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
unsigned long sp = regs->ctx.AX[0].U0;
struct metag_frame __user *frame;
Expand All @@ -65,7 +65,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)

--frame;

while ((entry->nr < sysctl_perf_event_max_stack) && frame)
while ((entry->nr < entry->max_stack) && frame)
frame = user_backtrace(frame, entry);
}

Expand All @@ -78,13 +78,13 @@ static int
callchain_trace(struct stackframe *fr,
void *data)
{
struct perf_callchain_entry *entry = data;
struct perf_callchain_entry_ctx *entry = data;
perf_callchain_store(entry, fr->pc);
return 0;
}

void
perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
struct stackframe fr;

Expand Down
12 changes: 6 additions & 6 deletions arch/mips/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
* the user stack callchains, we will add it here.
*/

static void save_raw_perf_callchain(struct perf_callchain_entry *entry,
unsigned long reg29)
static void save_raw_perf_callchain(struct perf_callchain_entry_ctx *entry,
unsigned long reg29)
{
unsigned long *sp = (unsigned long *)reg29;
unsigned long addr;
Expand All @@ -35,14 +35,14 @@ static void save_raw_perf_callchain(struct perf_callchain_entry *entry,
addr = *sp++;
if (__kernel_text_address(addr)) {
perf_callchain_store(entry, addr);
if (entry->nr >= sysctl_perf_event_max_stack)
if (entry->nr >= entry->max_stack)
break;
}
}
}

void perf_callchain_kernel(struct perf_callchain_entry *entry,
struct pt_regs *regs)
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
unsigned long sp = regs->regs[29];
#ifdef CONFIG_KALLSYMS
Expand All @@ -59,7 +59,7 @@ void perf_callchain_kernel(struct perf_callchain_entry *entry,
}
do {
perf_callchain_store(entry, pc);
if (entry->nr >= sysctl_perf_event_max_stack)
if (entry->nr >= entry->max_stack)
break;
pc = unwind_stack(current, &sp, pc, &ra);
} while (pc);
Expand Down
20 changes: 10 additions & 10 deletions arch/powerpc/perf/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int valid_next_sp(unsigned long sp, unsigned long prev_sp)
}

void
perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
unsigned long sp, next_sp;
unsigned long next_ip;
Expand Down Expand Up @@ -76,7 +76,7 @@ perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
next_ip = regs->nip;
lr = regs->link;
level = 0;
perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
perf_callchain_store_context(entry, PERF_CONTEXT_KERNEL);

} else {
if (level == 0)
Expand Down Expand Up @@ -232,7 +232,7 @@ static int sane_signal_64_frame(unsigned long sp)
puc == (unsigned long) &sf->uc;
}

static void perf_callchain_user_64(struct perf_callchain_entry *entry,
static void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
unsigned long sp, next_sp;
Expand All @@ -247,7 +247,7 @@ static void perf_callchain_user_64(struct perf_callchain_entry *entry,
sp = regs->gpr[1];
perf_callchain_store(entry, next_ip);

while (entry->nr < sysctl_perf_event_max_stack) {
while (entry->nr < entry->max_stack) {
fp = (unsigned long __user *) sp;
if (!valid_user_sp(sp, 1) || read_user_stack_64(fp, &next_sp))
return;
Expand All @@ -274,7 +274,7 @@ static void perf_callchain_user_64(struct perf_callchain_entry *entry,
read_user_stack_64(&uregs[PT_R1], &sp))
return;
level = 0;
perf_callchain_store(entry, PERF_CONTEXT_USER);
perf_callchain_store_context(entry, PERF_CONTEXT_USER);
perf_callchain_store(entry, next_ip);
continue;
}
Expand Down Expand Up @@ -319,7 +319,7 @@ static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
return rc;
}

static inline void perf_callchain_user_64(struct perf_callchain_entry *entry,
static inline void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
}
Expand Down Expand Up @@ -439,7 +439,7 @@ static unsigned int __user *signal_frame_32_regs(unsigned int sp,
return mctx->mc_gregs;
}

static void perf_callchain_user_32(struct perf_callchain_entry *entry,
static void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
unsigned int sp, next_sp;
Expand All @@ -453,7 +453,7 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
sp = regs->gpr[1];
perf_callchain_store(entry, next_ip);

while (entry->nr < sysctl_perf_event_max_stack) {
while (entry->nr < entry->max_stack) {
fp = (unsigned int __user *) (unsigned long) sp;
if (!valid_user_sp(sp, 0) || read_user_stack_32(fp, &next_sp))
return;
Expand All @@ -473,7 +473,7 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
read_user_stack_32(&uregs[PT_R1], &sp))
return;
level = 0;
perf_callchain_store(entry, PERF_CONTEXT_USER);
perf_callchain_store_context(entry, PERF_CONTEXT_USER);
perf_callchain_store(entry, next_ip);
continue;
}
Expand All @@ -487,7 +487,7 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
}

void
perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
if (current_is_64bit())
perf_callchain_user_64(entry, regs);
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ arch_initcall(service_level_perf_register);

static int __perf_callchain_kernel(void *data, unsigned long address)
{
struct perf_callchain_entry *entry = data;
struct perf_callchain_entry_ctx *entry = data;

perf_callchain_store(entry, address);
return 0;
}

void perf_callchain_kernel(struct perf_callchain_entry *entry,
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
struct pt_regs *regs)
{
if (user_mode(regs))
Expand Down
4 changes: 2 additions & 2 deletions arch/sh/kernel/perf_callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int callchain_stack(void *data, char *name)

static void callchain_address(void *data, unsigned long addr, int reliable)
{
struct perf_callchain_entry *entry = data;
struct perf_callchain_entry_ctx *entry = data;

if (reliable)
perf_callchain_store(entry, addr);
Expand All @@ -33,7 +33,7 @@ static const struct stacktrace_ops callchain_ops = {
};

void
perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
perf_callchain_store(entry, regs->pc);

Expand Down
Loading

0 comments on commit bdc6b75

Please sign in to comment.