Skip to content

Commit

Permalink
perf core: Add perf_callchain_store_context() helper
Browse files Browse the repository at this point in the history
We need have different helpers to account how many contexts we have in
the sample and for real addresses, so do it now as a prep patch, to
ease review.

Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed May 17, 2016
1 parent 3b1fff0 commit 3e4de4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions arch/powerpc/perf/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
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 @@ -274,7 +274,7 @@ static void perf_callchain_user_64(struct perf_callchain_entry_ctx *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 @@ -473,7 +473,7 @@ static void perf_callchain_user_32(struct perf_callchain_entry_ctx *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 Down
2 changes: 2 additions & 0 deletions include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,8 @@ extern void put_callchain_buffers(void);

extern int sysctl_perf_event_max_stack;

#define perf_callchain_store_context(ctx, context) perf_callchain_store(ctx, context)

static inline int perf_callchain_store(struct perf_callchain_entry_ctx *ctx, u64 ip)
{
if (ctx->nr < ctx->max_stack) {
Expand Down
4 changes: 2 additions & 2 deletions kernel/events/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,

if (kernel && !user_mode(regs)) {
if (add_mark)
perf_callchain_store(&ctx, PERF_CONTEXT_KERNEL);
perf_callchain_store_context(&ctx, PERF_CONTEXT_KERNEL);
perf_callchain_kernel(&ctx, regs);
}

Expand All @@ -217,7 +217,7 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
goto exit_put;

if (add_mark)
perf_callchain_store(&ctx, PERF_CONTEXT_USER);
perf_callchain_store_context(&ctx, PERF_CONTEXT_USER);
perf_callchain_user(&ctx, regs);
}
}
Expand Down

0 comments on commit 3e4de4e

Please sign in to comment.