Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169526
b: refs/heads/master
c: bbe2987
h: refs/heads/master
v: v3
  • Loading branch information
Arjan van de Ven authored and Ingo Molnar committed Oct 20, 2009
1 parent d38c0ea commit f1a817f
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 5 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: c258449bc9d286e2ee6546c9cdf911e96cbc126a
refs/heads/master: bbe2987bea26a684ff11d887dfc4cf39b22c27a2
5 changes: 4 additions & 1 deletion trunk/tools/perf/Documentation/perf-timechart.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ OPTIONS
-w::
--width=::
Select the width of the SVG file (default: 1000)
-p::
-P::
--power-only::
Only output the CPU power section of the diagram
-p::
--process::
Select the processes to display, by name or PID


SEE ALSO
Expand Down
105 changes: 102 additions & 3 deletions trunk/tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ static struct wake_event *wake_events;

struct sample_wrapper *all_samples;


struct process_filter;
struct process_filter {
char *name;
int pid;
struct process_filter *next;
};

static struct process_filter *process_filter;


static struct per_pid *find_create_pid(int pid)
{
struct per_pid *cursor = all_data;
Expand Down Expand Up @@ -763,11 +774,11 @@ static void draw_wakeups(void)
c = p->all;
while (c) {
if (c->Y && c->start_time <= we->time && c->end_time >= we->time) {
if (p->pid == we->waker) {
if (p->pid == we->waker && !from) {
from = c->Y;
task_from = strdup(c->comm);
}
if (p->pid == we->wakee) {
if (p->pid == we->wakee && !to) {
to = c->Y;
task_to = strdup(c->comm);
}
Expand Down Expand Up @@ -882,12 +893,89 @@ static void draw_process_bars(void)
}
}

static void add_process_filter(const char *string)
{
struct process_filter *filt;
int pid;

pid = strtoull(string, NULL, 10);
filt = malloc(sizeof(struct process_filter));
if (!filt)
return;

filt->name = strdup(string);
filt->pid = pid;
filt->next = process_filter;

process_filter = filt;
}

static int passes_filter(struct per_pid *p, struct per_pidcomm *c)
{
struct process_filter *filt;
if (!process_filter)
return 1;

filt = process_filter;
while (filt) {
if (filt->pid && p->pid == filt->pid)
return 1;
if (strcmp(filt->name, c->comm) == 0)
return 1;
filt = filt->next;
}
return 0;
}

static int determine_display_tasks_filtered(void)
{
struct per_pid *p;
struct per_pidcomm *c;
int count = 0;

p = all_data;
while (p) {
p->display = 0;
if (p->start_time == 1)
p->start_time = first_time;

/* no exit marker, task kept running to the end */
if (p->end_time == 0)
p->end_time = last_time;

c = p->all;

while (c) {
c->display = 0;

if (c->start_time == 1)
c->start_time = first_time;

if (passes_filter(p, c)) {
c->display = 1;
p->display = 1;
count++;
}

if (c->end_time == 0)
c->end_time = last_time;

c = c->next;
}
p = p->next;
}
return count;
}

static int determine_display_tasks(u64 threshold)
{
struct per_pid *p;
struct per_pidcomm *c;
int count = 0;

if (process_filter)
return determine_display_tasks_filtered();

p = all_data;
while (p) {
p->display = 0;
Expand Down Expand Up @@ -1153,15 +1241,26 @@ static int __cmd_record(int argc, const char **argv)
return cmd_record(i, rec_argv, NULL);
}

static int
parse_process(const struct option *opt __used, const char *arg, int __used unset)
{
if (arg)
add_process_filter(arg);
return 0;
}

static const struct option options[] = {
OPT_STRING('i', "input", &input_name, "file",
"input file name"),
OPT_STRING('o', "output", &output_name, "file",
"output file name"),
OPT_INTEGER('w', "width", &svg_page_width,
"page width"),
OPT_BOOLEAN('p', "power-only", &power_only,
OPT_BOOLEAN('P', "power-only", &power_only,
"output power data only"),
OPT_CALLBACK('p', "process", NULL, "process",
"process selector. Pass a pid or process name.",
parse_process),
OPT_END()
};

Expand Down

0 comments on commit f1a817f

Please sign in to comment.