From: David Ahern <daahern@cisco.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
mingo@elte.hu, peterz@infradead.org, fweisbec@gmail.com
Subject: Re: [PATCH] perf script: improve validation of sample attributes for output fields
Date: Wed, 06 Apr 2011 13:16:27 -0600 [thread overview]
Message-ID: <4D9CBC0B.5050602@cisco.com> (raw)
In-Reply-To: <20110406185827.GD4987@ghostprotocols.net>
On 04/06/11 12:58, Arnaldo Carvalho de Melo wrote:
> Em Sun, Apr 03, 2011 at 08:35:00AM -0600, David Ahern escreveu:
>> +++ b/tools/perf/builtin-script.c
>> @@ -94,41 +95,111 @@ static bool output_set_by_user(void)
>> +static const char *output_field2str(enum perf_output_field field)
>> +{
>> + int i, imax = sizeof(all_output_options) / sizeof(struct output_option);
>
> Use ARRAY_SIZE(all_output_options)
>
>> + for (i = 0; i < imax; ++i) {
>> + if (all_output_options[i].field == field) {
>> + str = all_output_options[i].str;
>> + break;
>
>> +static int perf_attr__check_stype(struct perf_event_attr *attr,
>> + u64 sample_type, const char *sample_msg,
>> + enum perf_output_field field)
>
> s/perf_attr__check_stype/perf_event_attr__check_stype/g
>
>> + /* user did not ask for it explicitly so remove from the default list */
>> + output[type].fields &= ~field;
>> + evname = __event_name(attr->type, attr->config);
>> + pr_debug("Samples for '%s' event do not have %s attribute set. "
>> + "Skipping '%s' field.\n",
>> + evname, sample_msg, output_field2str(field));
>
> pr_warning?
In this case, it seems more like a debug. You have default options which
are not available for the specific perf.data file.
>
>> +static int perf_evsel__check_attr(struct perf_session *session,
>> + struct perf_evsel *evsel)
>
> for consistency, please make evsel the first parameter.
>
>> +/* verify all user requested events exist and the samples
>> + * have the expected data
>> + */
>> +static int perf_session__check_output_opt(struct perf_session *session)
>> +{
>> + int j;
>> + struct perf_evsel *evsel;
>> +
>> + for (j = 0; j < PERF_TYPE_MAX; ++j) {
>> + evsel = perf_session__find_event(session, j);
>
> You're nog finding an specific event, you're looking for the first event
> of type j, so I think perf_session__find_first_evtype is clearer.
>
>> +
>> + /* even if fields is set to 0 (ie., show nothing) event must
>> + * exist if user explicitly includes it on the command line
>> + */
>
> Please use:
>
> /*
> * even if fields is set to 0 (ie., show nothing) event must
> * exist if user explicitly includes it on the command line
> */
>
> There are other places like this, please fix those too.
Ok, I'll make the changes and resend.
David
>
> - Arnaldo
prev parent reply other threads:[~2011-04-06 19:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-03 14:35 [PATCH] perf script: improve validation of sample attributes for output fields David Ahern
2011-04-06 18:58 ` Arnaldo Carvalho de Melo
2011-04-06 19:16 ` David Ahern [this message]
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=4D9CBC0B.5050602@cisco.com \
--to=daahern@cisco.com \
--cc=acme@ghostprotocols.net \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
/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).