Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147314
b: refs/heads/master
c: 394ee07
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 6, 2009
1 parent 4c8f3cc commit 261f55a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 023c54c42288416b4f43c67bfd5049a76926fad6
refs/heads/master: 394ee07623cf556c8daae2b3c00cf5fea47f0811
13 changes: 12 additions & 1 deletion trunk/include/linux/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ struct perf_counter_hw_event {
include_tid : 1, /* include the tid */
mmap : 1, /* include mmap data */
munmap : 1, /* include munmap data */
callchain : 1, /* add callchain data */

__reserved_1 : 52;
__reserved_1 : 51;

__u32 extra_config_len;
__u32 __reserved_4;
Expand Down Expand Up @@ -219,6 +220,7 @@ enum perf_event_type {
PERF_EVENT_OVERFLOW = 1UL << 31,
__PERF_EVENT_IP = 1UL << 30,
__PERF_EVENT_TID = 1UL << 29,
__PERF_EVENT_CALLCHAIN = 1UL << 28,
};

#ifdef __KERNEL__
Expand Down Expand Up @@ -504,6 +506,15 @@ extern void perf_counter_mmap(unsigned long addr, unsigned long len,
extern void perf_counter_munmap(unsigned long addr, unsigned long len,
unsigned long pgoff, struct file *file);

#define MAX_STACK_DEPTH 255

struct perf_callchain_entry {
u64 nr;
u64 ip[MAX_STACK_DEPTH];
};

extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs);

#else
static inline void
perf_counter_task_sched_in(struct task_struct *task, int cpu) { }
Expand Down
27 changes: 27 additions & 0 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,17 @@ void perf_counter_do_pending(void)
__perf_pending_run();
}

/*
* Callchain support -- arch specific
*/

struct perf_callchain_entry *
__attribute__((weak))
perf_callchain(struct pt_regs *regs)
{
return NULL;
}

/*
* Output
*/
Expand Down Expand Up @@ -1764,6 +1775,8 @@ static void perf_output_simple(struct perf_counter *counter,
struct {
u32 pid, tid;
} tid_entry;
struct perf_callchain_entry *callchain = NULL;
int callchain_size = 0;

header.type = PERF_EVENT_OVERFLOW;
header.size = sizeof(header);
Expand All @@ -1781,6 +1794,17 @@ static void perf_output_simple(struct perf_counter *counter,
header.size += sizeof(tid_entry);
}

if (counter->hw_event.callchain) {
callchain = perf_callchain(regs);

if (callchain) {
callchain_size = (1 + callchain->nr) * sizeof(u64);

header.type |= __PERF_EVENT_CALLCHAIN;
header.size += callchain_size;
}
}

ret = perf_output_begin(&handle, counter, header.size, nmi);
if (ret)
return;
Expand All @@ -1791,6 +1815,9 @@ static void perf_output_simple(struct perf_counter *counter,
if (counter->hw_event.include_tid)
perf_output_put(&handle, tid_entry);

if (callchain)
perf_output_copy(&handle, callchain, callchain_size);

perf_output_end(&handle);
}

Expand Down

0 comments on commit 261f55a

Please sign in to comment.