Commit 2a0a50fe authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

perf_counter: Update userspace callchain sampling uses

Update the tools to reflect the new callchain sampling format.

LKML-Reference: <new-submission>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f9188e02
...@@ -59,6 +59,11 @@ struct ip_event { ...@@ -59,6 +59,11 @@ struct ip_event {
unsigned char __more_data[]; unsigned char __more_data[];
}; };
struct ip_callchain {
__u64 nr;
__u64 ips[0];
};
struct mmap_event { struct mmap_event {
struct perf_event_header header; struct perf_event_header header;
__u32 pid, tid; __u32 pid, tid;
...@@ -833,15 +838,12 @@ got_dso: ...@@ -833,15 +838,12 @@ got_dso:
return dso->find_symbol(dso, ip); return dso->find_symbol(dso, ip);
} }
static struct symbol *call__match(struct symbol *sym) static int call__match(struct symbol *sym)
{ {
if (!sym)
return NULL;
if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0)) if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0))
return sym; return 1;
return NULL; return 0;
} }
/* /*
...@@ -850,7 +852,7 @@ static struct symbol *call__match(struct symbol *sym) ...@@ -850,7 +852,7 @@ static struct symbol *call__match(struct symbol *sym)
static int static int
hist_entry__add(struct thread *thread, struct map *map, struct dso *dso, hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
struct symbol *sym, __u64 ip, struct perf_callchain_entry *chain, struct symbol *sym, __u64 ip, struct ip_callchain *chain,
char level, __u64 count) char level, __u64 count)
{ {
struct rb_node **p = &hist.rb_node; struct rb_node **p = &hist.rb_node;
...@@ -869,31 +871,35 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso, ...@@ -869,31 +871,35 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
int cmp; int cmp;
if (sort__has_parent && chain) { if (sort__has_parent && chain) {
int i, nr = chain->hv; __u64 context = PERF_CONTEXT_MAX;
struct symbol *sym; int i;
struct dso *dso;
__u64 ip; for (i = 0; i < chain->nr; i++) {
__u64 ip = chain->ips[i];
for (i = 0; i < chain->kernel; i++) { struct dso *dso = NULL;
ip = chain->ip[nr + i]; struct symbol *sym;
dso = kernel_dso;
if (ip >= PERF_CONTEXT_MAX) {
context = ip;
continue;
}
switch (context) {
case PERF_CONTEXT_KERNEL:
dso = kernel_dso;
break;
default:
break;
}
sym = resolve_symbol(thread, NULL, &dso, &ip); sym = resolve_symbol(thread, NULL, &dso, &ip);
entry.parent = call__match(sym);
if (entry.parent) if (sym && call__match(sym)) {
goto got_parent; entry.parent = sym;
} break;
nr += i; }
for (i = 0; i < chain->user; i++) {
ip = chain->ip[nr + i];
sym = resolve_symbol(thread, NULL, NULL, &ip);
entry.parent = call__match(sym);
if (entry.parent)
goto got_parent;
} }
nr += i;
} }
got_parent:
while (*p != NULL) { while (*p != NULL) {
parent = *p; parent = *p;
...@@ -1095,21 +1101,10 @@ static unsigned long total = 0, ...@@ -1095,21 +1101,10 @@ static unsigned long total = 0,
total_unknown = 0, total_unknown = 0,
total_lost = 0; total_lost = 0;
static int validate_chain(struct perf_callchain_entry *chain, event_t *event) static int validate_chain(struct ip_callchain *chain, event_t *event)
{ {
unsigned int chain_size; unsigned int chain_size;
if (chain->nr > MAX_STACK_DEPTH)
return -1;
if (chain->hv > MAX_STACK_DEPTH)
return -1;
if (chain->kernel > MAX_STACK_DEPTH)
return -1;
if (chain->user > MAX_STACK_DEPTH)
return -1;
if (chain->hv + chain->kernel + chain->user != chain->nr)
return -1;
chain_size = event->header.size; chain_size = event->header.size;
chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
...@@ -1130,7 +1125,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head) ...@@ -1130,7 +1125,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
__u64 period = 1; __u64 period = 1;
struct map *map = NULL; struct map *map = NULL;
void *more_data = event->ip.__more_data; void *more_data = event->ip.__more_data;
struct perf_callchain_entry *chain = NULL; struct ip_callchain *chain = NULL;
if (event->header.type & PERF_SAMPLE_PERIOD) { if (event->header.type & PERF_SAMPLE_PERIOD) {
period = *(__u64 *)more_data; period = *(__u64 *)more_data;
...@@ -1150,10 +1145,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head) ...@@ -1150,10 +1145,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
chain = (void *)more_data; chain = (void *)more_data;
dprintf("... chain: u:%d, k:%d, nr:%d\n", dprintf("... chain: nr:%Lu\n", chain->nr);
chain->user,
chain->kernel,
chain->nr);
if (validate_chain(chain, event) < 0) { if (validate_chain(chain, event) < 0) {
eprintf("call-chain problem with event, skipping it.\n"); eprintf("call-chain problem with event, skipping it.\n");
...@@ -1162,7 +1154,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head) ...@@ -1162,7 +1154,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
if (dump_trace) { if (dump_trace) {
for (i = 0; i < chain->nr; i++) for (i = 0; i < chain->nr; i++)
dprintf("..... %2d: %016Lx\n", i, chain->ip[i]); dprintf("..... %2d: %016Lx\n", i, chain->ips[i]);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment