From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754224AbbERT4k (ORCPT ); Mon, 18 May 2015 15:56:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52431 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754089AbbERT4j (ORCPT ); Mon, 18 May 2015 15:56:39 -0400 Date: Mon, 18 May 2015 21:56:05 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , David Ahern , Adrian Hunter , Andi Kleen , Frederic Weisbecker , Stephane Eranian Subject: Re: [PATCH 14/40] perf tools: Introduce machine__find*_thread_by_time() Message-ID: <20150518195441.GA26932@krava.redhat.com> References: <1431909055-21442-1-git-send-email-namhyung@kernel.org> <1431909055-21442-15-git-send-email-namhyung@kernel.org> <20150518195006.GD12169@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150518195006.GD12169@krava> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 18, 2015 at 09:50:06PM +0200, Jiri Olsa wrote: > 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? should we store exit_time for dead threads? jirka