Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169773
b: refs/heads/master
c: e74328d
h: refs/heads/master
i:
  169771: 2c6900a
v: v3
  • Loading branch information
John Kacur authored and Ingo Molnar committed Nov 24, 2009
1 parent 9c875d9 commit 854d6ba
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 117 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: c9c7ccaf3a2686ed3a44d69bb1f8b55eeead8a4e
refs/heads/master: e74328d3a17ed75ffdf72b86f289965823a47240
2 changes: 2 additions & 0 deletions trunk/tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ LIB_H += util/sort.h
LIB_H += util/hist.h
LIB_H += util/thread.h
LIB_H += util/data_map.h
LIB_H += util/process_events.h

LIB_OBJS += util/abspath.o
LIB_OBJS += util/alias.o
Expand Down Expand Up @@ -411,6 +412,7 @@ LIB_OBJS += util/svghelper.o
LIB_OBJS += util/sort.o
LIB_OBJS += util/hist.o
LIB_OBJS += util/data_map.o
LIB_OBJS += util/process_events.o

BUILTIN_OBJS += builtin-annotate.o

Expand Down
56 changes: 2 additions & 54 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "util/thread.h"
#include "util/sort.h"
#include "util/hist.h"
#include "util/process_events.h"

static char const *input_name = "perf.data";

Expand Down Expand Up @@ -201,32 +202,6 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
return 0;
}

static int
process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
{
struct map *map = map__new(&event->mmap, NULL, 0);
struct thread *thread = threads__findnew(event->mmap.pid);

dump_printf("%p [%p]: PERF_RECORD_MMAP %d: [%p(%p) @ %p]: %s\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->mmap.pid,
(void *)(long)event->mmap.start,
(void *)(long)event->mmap.len,
(void *)(long)event->mmap.pgoff,
event->mmap.filename);

if (thread == NULL || map == NULL) {
dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
return 0;
}

thread__insert_map(thread, map);
total_mmap++;

return 0;
}

static int
process_comm_event(event_t *event, unsigned long offset, unsigned long head)
{
Expand All @@ -247,33 +222,6 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head)
return 0;
}

static int
process_fork_event(event_t *event, unsigned long offset, unsigned long head)
{
struct thread *thread = threads__findnew(event->fork.pid);
struct thread *parent = threads__findnew(event->fork.ppid);

dump_printf("%p [%p]: PERF_RECORD_FORK: %d:%d\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->fork.pid, event->fork.ppid);

/*
* A thread clone will have the same PID for both
* parent and child.
*/
if (thread == parent)
return 0;

if (!thread || !parent || thread__fork(thread, parent)) {
dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
return -1;
}
total_fork++;

return 0;
}

static int
process_event(event_t *event, unsigned long offset, unsigned long head)
{
Expand All @@ -288,7 +236,7 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
return process_comm_event(event, offset, head);

case PERF_RECORD_FORK:
return process_fork_event(event, offset, head);
return process_task_event(event, offset, head);
/*
* We dont process them right now but they are fine:
*/
Expand Down
63 changes: 1 addition & 62 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "util/thread.h"
#include "util/sort.h"
#include "util/hist.h"
#include "util/process_events.h"

static char const *input_name = "perf.data";

Expand All @@ -54,9 +55,6 @@ static int exclude_other = 1;
static char callchain_default_opt[] = "fractal,0.5";
const char *vmlinux_name;

static char *cwd;
static int cwdlen;

static struct perf_header *header;

static u64 sample_type;
Expand Down Expand Up @@ -750,33 +748,6 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
return 0;
}

static int
process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
{
struct map *map = map__new(&event->mmap, cwd, cwdlen);
struct thread *thread = threads__findnew(event->mmap.pid);

dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->mmap.pid,
event->mmap.tid,
(void *)(long)event->mmap.start,
(void *)(long)event->mmap.len,
(void *)(long)event->mmap.pgoff,
event->mmap.filename);

if (thread == NULL || map == NULL) {
dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
return 0;
}

thread__insert_map(thread, map);
total_mmap++;

return 0;
}

static int
process_comm_event(event_t *event, unsigned long offset, unsigned long head)
{
Expand All @@ -797,38 +768,6 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head)
return 0;
}

static int
process_task_event(event_t *event, unsigned long offset, unsigned long head)
{
struct thread *thread = threads__findnew(event->fork.pid);
struct thread *parent = threads__findnew(event->fork.ppid);

dump_printf("%p [%p]: PERF_RECORD_%s: (%d:%d):(%d:%d)\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->header.type == PERF_RECORD_FORK ? "FORK" : "EXIT",
event->fork.pid, event->fork.tid,
event->fork.ppid, event->fork.ptid);

/*
* A thread clone will have the same PID for both
* parent and child.
*/
if (thread == parent)
return 0;

if (event->header.type == PERF_RECORD_EXIT)
return 0;

if (!thread || !parent || thread__fork(thread, parent)) {
dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
return -1;
}
total_fork++;

return 0;
}

static int
process_lost_event(event_t *event, unsigned long offset, unsigned long head)
{
Expand Down
53 changes: 53 additions & 0 deletions trunk/tools/perf/util/process_event.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "process_event.h"

char *cwd;
int cwdlen;

int
process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
{
struct map *map = map__new(&event->mmap, cwd, cwdlen);
struct thread *thread = threads__findnew(event->mmap.pid);

dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->mmap.pid,
event->mmap.tid,
(void *)(long)event->mmap.start,
(void *)(long)event->mmap.len,
(void *)(long)event->mmap.pgoff,
event->mmap.filename);

if (thread == NULL || map == NULL) {
dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
return 0;
}

thread__insert_map(thread, map);
total_mmap++;

return 0;

}

int
process_comm_event(event_t *event, unsigned long offset, unsigned long head)
{
struct thread *thread = threads__findnew(event->comm.pid);

dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->comm.comm, event->comm.pid);

if (thread == NULL ||
thread__set_comm_adjust(thread, event->comm.comm)) {
dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
return -1;
}
total_comm++;

return 0;
}

29 changes: 29 additions & 0 deletions trunk/tools/perf/util/process_event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef __PROCESS_EVENT_H
#define __PROCESS_EVENT_H

#include "../builtin.h"
#include "util.h"

#include "color.h"
#include <linux/list.h>
#include "cache.h"
#include <linux/rbtree.h>
#include "symbol.h"
#include "string.h"

#include "../perf.h"
#include "debug.h"

#include "parse-options.h"
#include "parse-events.h"

#include "thread.h"
#include "sort.h"
#include "hist.h"

extern char *cwd;
extern int cwdlen;
extern int process_mmap_event(event_t *, unsigned long, unsigned long);
extern int process_comm_event(event_t *, unsigned long , unsigned long);

#endif /* __PROCESS_H */
64 changes: 64 additions & 0 deletions trunk/tools/perf/util/process_events.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "process_events.h"

char *cwd;
int cwdlen;

int
process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
{
struct map *map = map__new(&event->mmap, cwd, cwdlen);
struct thread *thread = threads__findnew(event->mmap.pid);

dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->mmap.pid,
event->mmap.tid,
(void *)(long)event->mmap.start,
(void *)(long)event->mmap.len,
(void *)(long)event->mmap.pgoff,
event->mmap.filename);

if (thread == NULL || map == NULL) {
dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
return 0;
}

thread__insert_map(thread, map);
total_mmap++;

return 0;
}

int
process_task_event(event_t *event, unsigned long offset, unsigned long head)
{
struct thread *thread = threads__findnew(event->fork.pid);
struct thread *parent = threads__findnew(event->fork.ppid);

dump_printf("%p [%p]: PERF_RECORD_%s: (%d:%d):(%d:%d)\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->header.type == PERF_RECORD_FORK ? "FORK" : "EXIT",
event->fork.pid, event->fork.tid,
event->fork.ppid, event->fork.ptid);

/*
* A thread clone will have the same PID for both
* parent and child.
*/
if (thread == parent)
return 0;

if (event->header.type == PERF_RECORD_EXIT)
return 0;

if (!thread || !parent || thread__fork(thread, parent)) {
dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
return -1;
}
total_fork++;

return 0;
}

35 changes: 35 additions & 0 deletions trunk/tools/perf/util/process_events.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef __PROCESS_EVENTS_H
#define __PROCESS_EVENTS_H

#include "../builtin.h"

#include "util.h"
#include "color.h"
#include <linux/list.h>
#include "cache.h"
#include <linux/rbtree.h>
#include "symbol.h"
#include "string.h"
#include "callchain.h"
#include "strlist.h"
#include "values.h"

#include "../perf.h"
#include "debug.h"
#include "header.h"

#include "parse-options.h"
#include "parse-events.h"

#include "data_map.h"
#include "thread.h"
#include "sort.h"
#include "hist.h"

extern char *cwd;
extern int cwdlen;

extern int process_mmap_event(event_t *, unsigned long , unsigned long);
extern int process_task_event(event_t *, unsigned long, unsigned long);

#endif /* __PROCESS_EVENTS_H */

0 comments on commit 854d6ba

Please sign in to comment.