From: Jiri Olsa <jolsa@redhat.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Andi Kleen <ak@linux.intel.com>,
Jin Yao <yao.jin@linux.intel.com>, Leo Yan <leo.yan@linaro.org>,
John Garry <john.garry@huawei.com>,
Kan Liang <kan.liang@linux.intel.com>,
linux-kernel@vger.kernel.org,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH] perf parse-events: Make add PMU verbose output clearer
Date: Wed, 13 May 2020 20:39:32 +0200 [thread overview]
Message-ID: <20200513183932.GC3343750@krava> (raw)
In-Reply-To: <20200513001729.21155-1-irogers@google.com>
On Tue, May 12, 2020 at 05:17:29PM -0700, Ian Rogers wrote:
SNIP
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 92bd7fafcce6..71d0290b616a 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1056,7 +1056,8 @@ static char *pmu_formats_string(struct list_head *formats)
> * Setup one of config[12] attr members based on the
> * user input data - term parameter.
> */
> -static int pmu_config_term(struct list_head *formats,
> +static int pmu_config_term(const char *pmu_name,
> + struct list_head *formats,
> struct perf_event_attr *attr,
> struct parse_events_term *term,
> struct list_head *head_terms,
> @@ -1082,16 +1083,24 @@ static int pmu_config_term(struct list_head *formats,
>
> format = pmu_find_format(formats, term->config);
> if (!format) {
> - if (verbose > 0)
> - printf("Invalid event/parameter '%s'\n", term->config);
> + char *pmu_term = pmu_formats_string(formats);
> + char *unknown_term;
> + char *help_msg;
> +
> + if (asprintf(&unknown_term,
> + "unknown term '%s' for pmu '%s'",
> + term->config, pmu_name) < 0)
> + unknown_term = strdup("unknown term");
is that really necessary? is asprintf fails, strdup will probably too,
and parse_events__handle_error checks on the !str, so we should be fine
other than that it looks ok to me
thanks,
jirka
> + help_msg = parse_events_formats_error_string(pmu_term);
> if (err) {
> - char *pmu_term = pmu_formats_string(formats);
> -
> parse_events__handle_error(err, term->err_term,
> - strdup("unknown term"),
> - parse_events_formats_error_string(pmu_term));
> - free(pmu_term);
> + unknown_term,
> + help_msg);
> + } else {
> + pr_debug("%s (%s)\n", unknown_term, help_msg);
> + free(unknown_term);
> }
> + free(pmu_term);
SNIP
prev parent reply other threads:[~2020-05-13 18:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-13 0:17 [PATCH] perf parse-events: Make add PMU verbose output clearer Ian Rogers
2020-05-13 18:39 ` Jiri Olsa [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=20200513183932.GC3343750@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=john.garry@huawei.com \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.poirier@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=yao.jin@linux.intel.com \
/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