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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 14 Apr 2020 17:21:02 +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>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Martin KaFai Lau <kafai@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Igor Lubashev <ilubashe@...mai.com>,
        Alexey Budankov <alexey.budankov@...ux.intel.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Jiwei Sun <jiwei.sun@...driver.com>,
        yuzhoujian <yuzhoujian@...ichuxing.com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Jin Yao <yao.jin@...ux.intel.com>,
        Leo Yan <leo.yan@...aro.org>,
        John Garry <john.garry@...wei.com>,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        bpf@...r.kernel.org, linux-perf-users@...r.kernel.org,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH v8 4/4] perf tools: add support for libpfm4

On Sat, Apr 11, 2020 at 12:46:31AM -0700, Ian Rogers wrote:

SNIP

>  TAG_FOLDERS= . ../lib ../include
>  TAG_FILES= ../../include/uapi/linux/perf_event.h
> diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> index 965ef017496f..7b64cd34266e 100644
> --- a/tools/perf/builtin-list.c
> +++ b/tools/perf/builtin-list.c
> @@ -18,6 +18,10 @@
>  #include <subcmd/parse-options.h>
>  #include <stdio.h>
>  
> +#ifdef HAVE_LIBPFM
> +#include "util/pfm.h"
> +#endif

so we have the HAVE_LIBPFM you could do the:

#ifdef HAVE_LIBPFM
#else
#endif

in util/pfm.h and add stubs for libpfm_initialize and others
in case HAVE_LIBPFM is not defined.. that clear out all the
#ifdefs in the change


SNIP

> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index b6322eb0f423..8b323151f22c 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -313,6 +313,15 @@ static struct test generic_tests[] = {
>  		.desc = "maps__merge_in",
>  		.func = test__maps__merge_in,
>  	},
> +	{
> +		.desc = "Test libpfm4 support",
> +		.func = test__pfm,
> +		.subtest = {
> +			.skip_if_fail	= true,
> +			.get_nr		= test__pfm_subtest_get_nr,
> +			.get_desc	= test__pfm_subtest_get_desc,
> +		}

awesome :)

SNIP

> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index d23db6755f51..83ad76d3d2be 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2447,9 +2447,15 @@ bool perf_evsel__fallback(struct evsel *evsel, int err,
>  		const char *sep = ":";
>  
>  		/* Is there already the separator in the name. */
> +#ifndef HAVE_LIBPFM
>  		if (strchr(name, '/') ||
>  		    strchr(name, ':'))
>  			sep = "";
> +#else
> +		if (strchr(name, '/') ||
> +		    (strchr(name, ':') && !evsel->is_libpfm_event))
> +			sep = "";
> +#endif


  ^^^^^^^^

>  
>  		if (asprintf(&new_name, "%s%su", name, sep) < 0)
>  			return false;
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index 53187c501ee8..397d335d5e24 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -76,6 +76,9 @@ struct evsel {
>  	bool			ignore_missing_thread;
>  	bool			forced_leader;
>  	bool			use_uncore_alias;
> +#ifdef HAVE_LIBPFM
> +	bool			is_libpfm_event;
> +#endif

perhaps we could had this one in unconditionaly,
because I think we have some members like that
for aux tracing.. and that would remove the #ifdef
above


SNIP

>  
> +#ifdef HAVE_LIBPFM
> +struct evsel *parse_events__pfm_add_event(int idx, struct perf_event_attr *attr,
> +					char *name, struct perf_pmu *pmu)
> +{
> +	return __add_event(NULL, &idx, attr, false, name, pmu, NULL, false,
> +			   NULL);
> +}
> +#endif

could you instead add parse_events__add_event and call it from pfm code?

SNIP

> +		pmu = perf_pmu__find_by_type((unsigned int)attr.type);
> +		evsel = parse_events__pfm_add_event(evlist->core.nr_entries,
> +						&attr, q, pmu);
> +		if (evsel == NULL)
> +			goto error;
> +
> +		evsel->is_libpfm_event = true;
> +
> +		evlist__add(evlist, evsel);
> +
> +		if (grp_evt == 0)
> +			grp_leader = evsel;
> +
> +		if (grp_evt > -1) {
> +			evsel->leader = grp_leader;
> +			grp_leader->core.nr_members++;
> +			grp_evt++;
> +		}
> +
> +		if (*sep == '}') {
> +			if (grp_evt < 0) {
> +				ui__error("cannot close a non-existing event group\n");
> +				goto error;
> +			}
> +			evlist->nr_groups++;
> +			grp_leader = NULL;
> +			grp_evt = -1;
> +		}
> +		evsel->is_libpfm_event = true;

seems to be set twice in here


> +	}
> +	return 0;
> +error:
> +	free(p_orig);
> +	return -1;
> +}
> +
> +static const char *srcs[PFM_ATTR_CTRL_MAX] = {
> +	[PFM_ATTR_CTRL_UNKNOWN] = "???",
> +	[PFM_ATTR_CTRL_PMU] = "PMU",
> +	[PFM_ATTR_CTRL_PERF_EVENT] = "perf_event",
> +};

SNIP

thanks,
jirka

Powered by blists - more mailing lists