[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131211141908.GC1458@ghostprotocols.net>
Date: Wed, 11 Dec 2013 11:19:08 -0300
From: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
To: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
David Ahern <dsahern@...il.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Jiri Olsa <jolsa@...hat.com>, Mike Galbraith <efault@....de>,
Namhyung Kim <namhyung@...il.com>,
Paul Mackerras <paulus@...ba.org>,
Stephane Eranian <eranian@...gle.com>,
Andi Kleen <ak@...ux.intel.com>,
Adrian Hunter <adrian.hunter@...el.com>
Subject: Re: [PATCH v0 14/71] perf tools: Add cpu to struct thread
Em Wed, Dec 11, 2013 at 02:36:26PM +0200, Alexander Shishkin escreveu:
> From: Adrian Hunter <adrian.hunter@...el.com>
>
> Tools may wish to track on which cpu a thread
> is running. Add 'cpu' to struct thread for
> that purpose. Also add machine functions to
> get / set the cpu for a tid.
>
> This will be used to determine the cpu when
> decoding a per-thread Instruction Trace.
>
>
> +++ b/tools/perf/util/machine.c
> @@ -1412,3 +1412,29 @@ pid_t machine__get_thread_pid(struct machine *machine, pid_t tid)
>
> return thread->pid_;
> }
> +
> +int machine__get_thread_cpu(struct machine *machine, pid_t tid, pid_t *pid)
> +{
> + struct thread *thread = machine__find_thread(machine, tid);
> +
> + if (!thread)
> + return -1;
> +
> + if (pid)
> + *pid = thread->pid_;
> +
> + return thread->cpu;
> +}
What is the problem with:
struct thread *thread = machine__find_thread(machine, tid);
pid_t pid = thread->pid_;
int cpu = thread->cpu;
In your case you'll have:
int pid;
int cpu = machine__get_thread_cpu(machine, tid, &pid);
Which is slightly more compact, but then we end up with a function that
from its name should just get a 'cpu' but also asks for the pid.
I think it is better to just use what we have (machine__find_thread),
have a 'thread' variable and then use any of its members, directly.
- ARnaldo
--
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