lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200513183932.GC3343750@krava>
Date:   Wed, 13 May 2020 20:39:32 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Andi Kleen <ak@...ux.intel.com>,
        Jin Yao <yao.jin@...ux.intel.com>,
        Leo Yan <leo.yan@...aro.org>,
        John Garry <john.garry@...wei.com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        linux-kernel@...r.kernel.org, Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf parse-events: Make add PMU verbose output clearer

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ