lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150519065747.GJ21663@sejong>
Date:	Tue, 19 May 2015 15:57:47 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Jiri Olsa <jolsa@...hat.com>
Cc:	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Ingo Molnar <mingo@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	LKML <linux-kernel@...r.kernel.org>,
	David Ahern <dsahern@...il.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Andi Kleen <andi@...stfloor.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 14/40] perf tools: Introduce
 machine__find*_thread_by_time()

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?

Because the list is sorted on time - it'll see thread that has a
larger start_time first so it can ensure that a thread which satisfies
the expression first is the current thread at that time.  Later
threads in the list will satisfy the expression also but they're
already dead.

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ