diff options
Diffstat (limited to 'Documentation/perf_counter/builtin-report.c')
-rw-r--r-- | Documentation/perf_counter/builtin-report.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index e837bb983dca..33b3b15fb014 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c | |||
@@ -229,6 +229,7 @@ static int thread__set_comm(struct thread *self, const char *comm) | |||
229 | } | 229 | } |
230 | 230 | ||
231 | static struct rb_root threads; | 231 | static struct rb_root threads; |
232 | static struct thread *last_match; | ||
232 | 233 | ||
233 | static struct thread *threads__findnew(pid_t pid) | 234 | static struct thread *threads__findnew(pid_t pid) |
234 | { | 235 | { |
@@ -236,12 +237,22 @@ static struct thread *threads__findnew(pid_t pid) | |||
236 | struct rb_node *parent = NULL; | 237 | struct rb_node *parent = NULL; |
237 | struct thread *th; | 238 | struct thread *th; |
238 | 239 | ||
240 | /* | ||
241 | * Font-end cache - PID lookups come in blocks, | ||
242 | * so most of the time we dont have to look up | ||
243 | * the full rbtree: | ||
244 | */ | ||
245 | if (last_match && last_match->pid == pid) | ||
246 | return last_match; | ||
247 | |||
239 | while (*p != NULL) { | 248 | while (*p != NULL) { |
240 | parent = *p; | 249 | parent = *p; |
241 | th = rb_entry(parent, struct thread, rb_node); | 250 | th = rb_entry(parent, struct thread, rb_node); |
242 | 251 | ||
243 | if (th->pid == pid) | 252 | if (th->pid == pid) { |
253 | last_match = th; | ||
244 | return th; | 254 | return th; |
255 | } | ||
245 | 256 | ||
246 | if (pid < th->pid) | 257 | if (pid < th->pid) |
247 | p = &(*p)->rb_left; | 258 | p = &(*p)->rb_left; |
@@ -253,7 +264,9 @@ static struct thread *threads__findnew(pid_t pid) | |||
253 | if (th != NULL) { | 264 | if (th != NULL) { |
254 | rb_link_node(&th->rb_node, parent, p); | 265 | rb_link_node(&th->rb_node, parent, p); |
255 | rb_insert_color(&th->rb_node, &threads); | 266 | rb_insert_color(&th->rb_node, &threads); |
267 | last_match = th; | ||
256 | } | 268 | } |
269 | |||
257 | return th; | 270 | return th; |
258 | } | 271 | } |
259 | 272 | ||