Re: [PATCH] perf tools: Allow multiple threads or processes in record,stat, top

From: David Ahern
Date: Thu Feb 09 2012 - 01:04:10 EST


On 02/08/2012 10:36 PM, Namhyung Kim wrote:
> Oh, I meant this:
>
> static struct thread_map *thread_map__new_by_pid_str(const char *pid_str)
> {
> ...
> while (*str) {
> ...
> tmp = thread_map__new_by_pid(pid);
> ...
> }
> ...
> }
>
> static struct thread_map *thread_map__new_by_tid_str(const char *tid_str)
> {
> ...
> while (*str) {
> ...
> tmp = thread_map__new_by_tid(tid);
> ...
> }
> ...
> }


I'm still not seeing the code simplification here. For example,
new_by_tid(tid) allocates threads, sets the first element (it only
supports one) and returns it. In new_by_tid_str we loop over a CSV,
allocating/re-allocating on additional and then setting the current i-th
tid as opposed to the 0th element.

Similarly, for pid.

Personally, I liked my first patch better which dropped the current
tid/pid functions; they are only used by perf-test and it can be updated
to convert getpid() to a string and use the new API.

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