lkml.org 
[lkml]   [2015]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 14/40] perf tools: Introduce machine__find*_thread_by_time()
On Mon, May 18, 2015 at 09:30:29AM +0900, Namhyung Kim wrote:

SNIP

> +static struct thread *
> +__machine__findnew_thread_by_time(struct machine *machine, pid_t pid, pid_t tid,
> + u64 timestamp, bool create)
> +{
> + struct thread *curr, *pos, *new;
> + struct thread *th = NULL;
> + struct rb_node **p;
> + struct rb_node *parent = NULL;
> +
> + if (!perf_has_index)
> + return ____machine__findnew_thread(machine, pid, tid, create);
> +
> + /* lookup current thread first */
> + curr = ____machine__findnew_thread(machine, pid, tid, false);
> + if (curr && timestamp >= curr->start_time)
> + return curr;
> +
> + /* and then check dead threads tree & list */
> + p = &machine->dead_threads.rb_node;
> + while (*p != NULL) {
> + parent = *p;
> + th = rb_entry(parent, struct thread, rb_node);
> +
> + if (th->tid == tid) {
> + list_for_each_entry(pos, &th->tid_node, tid_node) {
> + if (timestamp >= pos->start_time &&
> + pos->start_time > th->start_time) {
> + th = pos;
> + break;
> + }

hum, how do we know, there's not another thread on the list
fitting the timestamp >= pos->start_time condition as well?

jirka


\
 
 \ /
  Last update: 2015-05-18 22:21    [W:0.545 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site