linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
	peterz@infradead.org, fweisbec@gmail.com, paulus@samba.org,
	tglx@linutronix.de
Subject: Re: [PATCH] perf tools: Allow multiple threads or processes in record, stat, top
Date: Fri, 10 Feb 2012 12:46:40 -0700	[thread overview]
Message-ID: <4F357420.6030603@gmail.com> (raw)
In-Reply-To: <20120210193429.GL2526@infradead.org>



On 02/10/2012 12:34 PM, Arnaldo Carvalho de Melo wrote:
> Em Fri, Feb 10, 2012 at 12:32:09PM -0700, David Ahern escreveu:
>>
>>
>> On 02/10/2012 12:24 PM, Arnaldo Carvalho de Melo wrote:
>>> Em Wed, Feb 08, 2012 at 09:32:52AM -0700, David Ahern escreveu:
>>>> Allow a user to collect events for multiple threads or processes
>>>> using a comma separated list.
>>>>
>>>> e.g., collect data on a VM and its vhost thread:
>>>>   perf top -p 21483,21485
>>>>   perf stat -p 21483,21485 -ddd
>>>>   perf record -p 21483,21485
>>>>
>>>> or monitoring vcpu threads
>>>>   perf top -t 21488,21489
>>>>   perf stat -t 21488,21489 -ddd
>>>>   perf record -t 21488,21489
>>>
>>> I found some problems below:
>>>  
>>>> diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
>>>> index 3d4b6c5..e793c16 100644
>>>> --- a/tools/perf/util/thread_map.c
>>>> +++ b/tools/perf/util/thread_map.c
>>>> +static struct thread_map *thread_map__new_by_pid_str(const char *pid_str)
>>>> +{
>>>> +	struct thread_map *threads = NULL;
>>> <SNIP>
>>>> +		if (threads)
>>>> +			threads = realloc(threads,
>>>> +					  sizeof(*threads) + sizeof(pid_t)*total_tasks);
>>>> +		else
>>>> +			threads = malloc(sizeof(*threads) + sizeof(pid_t)*items);
>>>
>>> If realloc fails and threads was allocated before... we leak memory.
>>
>> ok.
>>
>>>
>>> We don't need to use this if clause, realloc handles threads == NULL
>>> just fines and then works as malloc.
>>
>> ok.
>>
>>>
>>> Also I didn't use ctype altogether + that CSV parsing routine, we have
>>> strlist for that, it even will allow us to trow away duplicate pids/tids
>>> and also supports passing a file with a list of threads to monitor, for
>>> free.
>>
>> Interesting. I did look at strlist before going with the string parsing.
>> It was not obvious to me how to use it for this case.
>>
>>>
>>> Take a look at the modified patch below, if you're ok with it I can keep
>>> your autorship and put a [committer note: use strlist] or take autorship
>>> and state that it was based on a patch made by you, definetely your
>>> call. I'd go for the committer note.
>>
>> I'm fine with either one. Patch below looks fine. If needed:
>>
>> Acked-by: David Ahern <dsahern@gmail.com>
> 
> I assume you tested it in a few scenarios (I know I did, but hey, more
> testing is always good) and that I can add another stamp, a Tested-by:
> ya, right?
> 
> - Arnaldo

Hmmm... that was a radical idea. Build breaks on Fedora 16, x86_64:

util/thread_map.c: In function ‘thread_map__new_by_pid_str’:
util/thread_map.c:164:2: error: overflow in implicit constant conversion
[-Werror=overflow]
util/thread_map.c:175:3: error: comparison is always false due to
limited range of data type [-Werror=type-limits]
util/thread_map.c:175:3: error: comparison is always false due to
limited range of data type [-Werror=type-limits]
util/thread_map.c: In function ‘thread_map__new_by_tid_str’:
util/thread_map.c:223:2: error: overflow in implicit constant conversion
[-Werror=overflow]
util/thread_map.c:245:3: error: comparison is always false due to
limited range of data type [-Werror=type-limits]
util/thread_map.c:245:3: error: comparison is always false due to
limited range of data type [-Werror=type-limits]
cc1: all warnings being treated as errors


I think you want INT_MAX not LONG_MAX.

  reply	other threads:[~2012-02-10 19:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-08 16:32 [PATCH] perf tools: Allow multiple threads or processes in record, stat, top David Ahern
2012-02-09  1:19 ` Namhyung Kim
2012-02-09  2:52   ` David Ahern
2012-02-09  5:36     ` Namhyung Kim
2012-02-09  6:04       ` David Ahern
2012-02-09  7:37     ` Ingo Molnar
2012-02-09 14:34       ` Arnaldo Carvalho de Melo
2012-02-09 14:44         ` Arnaldo Carvalho de Melo
2012-02-10  5:42           ` Namhyung Kim
2012-02-10 14:28             ` Arnaldo Carvalho de Melo
2012-02-12 10:45               ` [PATCH] perf tools: Fix build dependency of perf python extension Namhyung Kim
2012-02-17  9:44                 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-02-10 19:24 ` [PATCH] perf tools: Allow multiple threads or processes in record, stat, top Arnaldo Carvalho de Melo
2012-02-10 19:32   ` David Ahern
2012-02-10 19:34     ` Arnaldo Carvalho de Melo
2012-02-10 19:46       ` David Ahern [this message]
2012-02-10 19:58         ` Arnaldo Carvalho de Melo
2012-02-17  9:46 ` [tip:perf/core] " tip-bot for David Ahern
2012-03-02 10:56   ` Ingo Molnar
2012-03-02 14:21     ` David Ahern
2012-03-02 14:52     ` David Ahern
2012-03-03  7:42       ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F357420.6030603@gmail.com \
    --to=dsahern@gmail.com \
    --cc=acme@ghostprotocols.net \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).