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:	Thu, 3 May 2012 12:56:55 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	"Yan, Zheng" <zheng.z.yan@...el.com>
Cc:	a.p.zijlstra@...llo.nl, mingo@...e.hu, andi@...stfloor.org,
	eranian@...gle.com, ming.m.lin@...el.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 9/9] perf tool: Add pmu event alias support

On Wed, May 02, 2012 at 10:07:20AM +0800, Yan, Zheng wrote:
> From: "Yan, Zheng" <zheng.z.yan@...el.com>
> 
> The definition of pmu event alias is located at:
>   ${sysfs_mount}/bus/event_source/devices/${pmu}/events/
> 
> Each file in the 'events' directory defines a event alias. Its contents
> is like:
>   config=1,config1=2
> 
> Using pmu event alias, event could be now specified like:
>   uncore/CLOCKTICKS/
> 
> Signed-off-by: Zheng Yan <zheng.z.yan@...el.com>
> ---
>  tools/perf/util/parse-events.c |   24 ++++++++-
>  tools/perf/util/parse-events.y |    2 +-
>  tools/perf/util/pmu.c          |  117 ++++++++++++++++++++++++++++++++++++++++
>  tools/perf/util/pmu.h          |   10 +++-
>  4 files changed, 149 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index c587ae8..764b2c31 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -653,8 +653,12 @@ int parse_events_add_numeric(struct list_head *list, int *idx,
>  int parse_events_add_pmu(struct list_head *list, int *idx,
>  			 char *name, struct list_head *head_config)
>  {
> +	LIST_HEAD(event);
>  	struct perf_event_attr attr;
>  	struct perf_pmu *pmu;
> +	const char *config;
> +	char *str;
> +	int ret;
>  
>  	pmu = perf_pmu__find(name);
>  	if (!pmu)
> @@ -668,10 +672,26 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
>  	 */
>  	config_attr(&attr, head_config, 0);
>  
> -	if (perf_pmu__config(pmu, &attr, head_config))
> +	ret = perf_pmu__config(pmu, &attr, head_config);
> +	if (!ret)
> +		return add_event(list, idx, &attr, (char *) "pmu");
> +
> +	config = perf_pmu__alias(pmu, head_config);
> +	if (!config)
>  		return -EINVAL;
hi,
could we have the interface with string only:
	config = perf_pmu__alias(pmu, alias);

and AFAICS check if there's only single term and it's string,
then check for alias


I've got an idea for another approach, that would not need reentrant
parser and might be more gentle to the sysfs file rule

- in sysfs you would have directory with aliases (now called 'events')
- each alias is sysfs dir, with file attrs:
	file name = term name, file value = term value
  eg.:
	events/
		CAS_COUNT_RD/
			# files:
			config  - value 1
			config1 - value 2
			mask	- value ...

- on init you read all aliases and load its terms
  so each alias is defined by list of terms
- in parse_events_add_pmu before you run perf_pmu__config,
  you check if any term matches any defined alias
  and replace that term with all the terms defined for the alias
- run perf_pmu__config with new set of terms..

this way it's also possible to add extra terms to existing alias
in command line if needed... might be handy

thoughts?
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ