Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147634
b: refs/heads/master
c: eed4dcd
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Jun 3, 2009
1 parent efc90d6 commit ca986f9
Show file tree
Hide file tree
Showing 2 changed files with 15 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: 44db76c8553c328f4ae02481d77bb3a88ca17645
refs/heads/master: eed4dcd443da7a46131ef37c7a389b444905960e
15 changes: 14 additions & 1 deletion trunk/Documentation/perf_counter/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,30 @@ static int thread__set_comm(struct thread *self, const char *comm)
}

static struct rb_root threads;
static struct thread *last_match;

static struct thread *threads__findnew(pid_t pid)
{
struct rb_node **p = &threads.rb_node;
struct rb_node *parent = NULL;
struct thread *th;

/*
* Font-end cache - PID lookups come in blocks,
* so most of the time we dont have to look up
* the full rbtree:
*/
if (last_match && last_match->pid == pid)
return last_match;

while (*p != NULL) {
parent = *p;
th = rb_entry(parent, struct thread, rb_node);

if (th->pid == pid)
if (th->pid == pid) {
last_match = th;
return th;
}

if (pid < th->pid)
p = &(*p)->rb_left;
Expand All @@ -253,7 +264,9 @@ static struct thread *threads__findnew(pid_t pid)
if (th != NULL) {
rb_link_node(&th->rb_node, parent, p);
rb_insert_color(&th->rb_node, &threads);
last_match = th;
}

return th;
}

Expand Down

0 comments on commit ca986f9

Please sign in to comment.