Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-20160516' of git://git.kernel.org/pub/…
Browse files Browse the repository at this point in the history
…scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

User visible changes:

- Honour the kernel.perf_event_max_stack knob more precisely by not counting
  PERF_CONTEXT_{KERNEL,USER} when deciding when to stop adding entries to
  the perf_sample->ip_callchain[] array (Arnaldo Carvalho de Melo)

- Fix identation of 'stalled-backend-cycles' in 'perf stat' (Namhyung Kim)

- Update runtime using 'cpu-clock' event in 'perf stat' (Namhyung Kim)

- Use 'cpu-clock' for cpu targets in 'perf stat' (Namhyung Kim)

- Avoid fractional digits for integer scales in 'perf stat' (Andi Kleen)

- Store vdso buildid unconditionally, as it appears in callchains and
  we're not checking those when creating the build-id table, so we
  end up not being able to resolve VDSO symbols when doing analysis
  on a different machine than the one where recording was done, possibly
  of a different arch even (arm -> x86_64) (He Kuang)

Infrastructure changes:

- Generalize max_stack sysctl handler, will be used for configuring
  multiple kernel knobs related to callchains (Arnaldo Carvalho de Melo)

Cleanups:

- Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE, to stop using
  open coded strings (Masami Hiramatsu)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed May 20, 2016
2 parents b0a434f + a29d5c9 commit 21f77d2
Show file tree
Hide file tree
Showing 30 changed files with 201 additions and 117 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
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 21f77d2

Please sign in to comment.