aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/perf_counter.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-03-25 07:30:25 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-06 03:30:34 -0400
commitea5d20cf99db5d26d43b6d322d3ace17e08a6552 (patch)
tree287bb37825294d4f3cd943d83b6fb7d4b7009630 /kernel/perf_counter.c
parent63e35b25d6b5c3136d22ef249dbbf96716aa08bf (diff)
perf_counter: optionally provide the pid/tid of the sampled task
Allow cpu wide counters to profile userspace by providing what process the sample belongs to. This raises the first issue with the output type, lots of these options: group, tid, callchain, etc.. are non-exclusive and could be combined, suggesting a bitfield. However, things like the mmap() data stream doesn't fit in that. How to split the type field... Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Arjan van de Ven <arjan@infradead.org> Cc: Wu Fengguang <fengguang.wu@intel.com> Orig-LKML-Reference: <20090325113317.013775235@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r--kernel/perf_counter.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 7669afe82cc7..f3e1b27bc1b8 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -1528,16 +1528,30 @@ out:
1528static void perf_output_simple(struct perf_counter *counter, 1528static void perf_output_simple(struct perf_counter *counter,
1529 int nmi, struct pt_regs *regs) 1529 int nmi, struct pt_regs *regs)
1530{ 1530{
1531 unsigned int size;
1531 struct { 1532 struct {
1532 struct perf_event_header header; 1533 struct perf_event_header header;
1533 u64 ip; 1534 u64 ip;
1535 u32 pid, tid;
1534 } event; 1536 } event;
1535 1537
1536 event.header.type = PERF_EVENT_IP; 1538 event.header.type = PERF_EVENT_IP;
1537 event.header.size = sizeof(event);
1538 event.ip = instruction_pointer(regs); 1539 event.ip = instruction_pointer(regs);
1539 1540
1540 perf_output_write(counter, nmi, &event, sizeof(event)); 1541 size = sizeof(event);
1542
1543 if (counter->hw_event.include_tid) {
1544 /* namespace issues */
1545 event.pid = current->group_leader->pid;
1546 event.tid = current->pid;
1547
1548 event.header.type |= __PERF_EVENT_TID;
1549 } else
1550 size -= sizeof(u64);
1551
1552 event.header.size = size;
1553
1554 perf_output_write(counter, nmi, &event, size);
1541} 1555}
1542 1556
1543static void perf_output_group(struct perf_counter *counter, int nmi) 1557static void perf_output_group(struct perf_counter *counter, int nmi)