mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC 0/4] perf tool: Adding ratios support
@ 2013-01-15 13:39 Jiri Olsa
  2013-01-15 13:39 ` [PATCH 1/4] perf tool: Remove unused 'unset' parameter from parse_events Jiri Olsa
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Jiri Olsa @ 2013-01-15 13:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Corey Ashford,
	Frederic Weisbecker, Ingo Molnar, Paul Mackerras, Peter Zijlstra,
	Andi Kleen, David Ahern, Ulrich Drepper

hi,
adding support to predefine event ratios formulas so they could
be used easily in perf.

The formulas are handed in the config file with following format:

  set {
        events = {cycles,instructions,branch-instructions}:u

        cpi {
                formula = cycles / instructions
                desc = cycles per instruction
        }

	branch-rate {
                formula = branch-instructions / instructions
                desc = branch rate
        }
  }

  The 'set' defines set of counter that share same events.
  Each 'set' defines:
    events   - event string that would go into stat/record -e option
    counters - any number of counters based on above events

  Each counter (cpi/branch-rate) defines
    formula - formula with that produce the counter number
              event names and numbers could be used
    desc    - text description of the counter

The formula can currently contain any event from the set::events
plus any number (int). There'll be support in future for outside
values runtime and other if needed.

My current thinking is to have generic formulas file(s) for architectural
events and add arch-specific ones once when we have the support for
non-architectural events (already sent RFC, v2 is on its way..).

Example:

With following formula.conf config file:
---
  cpi {
          events = {cycles,instructions}:u

          CPI {
                  formula = cycles / instructions
                  desc = cycles per instruction
          }
  }

  branch {
          events = {instructions,branch-instructions,branch-misses}:u

          branch-rate {
                  formula = branch-instructions / instructions
                  desc = branch rate
          }

          branch-miss-rate {
                  formula = branch-misses / instructions
                  desc = branch misprediction rate
          }

          branch-miss-ratio{
                  formula = branch-misses / branch-instructions
                  desc = branch misprediction ratio
          }
  }
---

You'll get following result:

  $ perf stat -f formula.conf:branch kill
  usage: kill [ -s signal | -p ] [ -a ] pid ...
         kill -l [ signal ]

   Performance counter stats for 'kill':

             184,195 instructions              #    0.00  insns per cycle
              40,907 branch-instructions
               4,815 branch-misses             #   11.77% of all branches

         0.000655767 seconds time elapsed

          0.22208529 branch-rate               #  branch rate
          0.02614077 branch-miss-rate          #  branch misprediction rate
          0.11770602 branch-miss-ratio         #  branch misprediction ratio

  $ perf stat -f formula.conf:cpi kill
  usage: kill [ -s signal | -p ] [ -a ] pid ...
         kill -l [ signal ]

   Performance counter stats for 'kill':

             356,635 cycles                    #    0.000 GHz
             187,191 instructions              #    0.52  insns per cycle

         0.001907600 seconds time elapsed

          1.90519309 CPI                       #  cycles per instruction


Available also at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/linux.git
  perf/ratios2


thanks for any ideas,
jirka

Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ulrich Drepper <drepper@gmail.com>
---
 tools/perf/Makefile                     |  11 +++
 tools/perf/builtin-stat.c               |  61 ++++++++++++++-
 tools/perf/formula.conf                 |  28 +++++++
 tools/perf/tests/evsel-roundtrip-name.c |   4 +-
 tools/perf/tests/hists_link.c           |   4 +-
 tools/perf/tests/parse-events.c         |   2 +-
 tools/perf/util/evlist.c                |  13 ++++
 tools/perf/util/evlist.h                |   4 +
 tools/perf/util/formula.c               | 387 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/formula.h               | 113 +++++++++++++++++++++++++++
 tools/perf/util/formula.l               | 119 ++++++++++++++++++++++++++++
 tools/perf/util/formula.y               | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/parse-events.c          |   5 +-
 tools/perf/util/parse-events.h          |   3 +-
 14 files changed, 991 insertions(+), 11 deletions(-)


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/4] perf tool: Remove unused 'unset' parameter from parse_events
  2013-01-15 13:39 [RFC 0/4] perf tool: Adding ratios support Jiri Olsa
@ 2013-01-15 13:39 ` Jiri Olsa
  2013-01-25 11:52   ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
  2013-01-15 13:39 ` [PATCH 2/4] perf tool: Add formula interface to interface ratio definitions Jiri Olsa
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Jiri Olsa @ 2013-01-15 13:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Namhyung Kim, Corey Ashford,
	Frederic Weisbecker, Ingo Molnar, Paul Mackerras, Peter Zijlstra,
	Andi Kleen, David Ahern, Ulrich Drepper

The 'unset' parameter is option callback leftover with
no use, removing.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ulrich Drepper <drepper@gmail.com>
---
 tools/perf/tests/evsel-roundtrip-name.c | 4 ++--
 tools/perf/tests/hists_link.c           | 4 ++--
 tools/perf/tests/parse-events.c         | 2 +-
 tools/perf/util/parse-events.c          | 5 ++---
 tools/perf/util/parse-events.h          | 3 +--
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index e61fc82..0fd99a9 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -22,7 +22,7 @@ static int perf_evsel__roundtrip_cache_name_test(void)
 			for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
 				__perf_evsel__hw_cache_type_op_res_name(type, op, i,
 									name, sizeof(name));
-				err = parse_events(evlist, name, 0);
+				err = parse_events(evlist, name);
 				if (err)
 					ret = err;
 			}
@@ -70,7 +70,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names)
                 return -ENOMEM;
 
 	for (i = 0; i < nr_names; ++i) {
-		err = parse_events(evlist, names[i], 0);
+		err = parse_events(evlist, names[i]);
 		if (err) {
 			pr_debug("failed to parse event '%s', err %d\n",
 				 names[i], err);
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 27860a0..0afd922 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -441,10 +441,10 @@ int test__hists_link(void)
 	if (evlist == NULL)
                 return -ENOMEM;
 
-	err = parse_events(evlist, "cpu-clock", 0);
+	err = parse_events(evlist, "cpu-clock");
 	if (err)
 		goto out;
-	err = parse_events(evlist, "task-clock", 0);
+	err = parse_events(evlist, "task-clock");
 	if (err)
 		goto out;
 
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index e7eb708..337424d 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1018,7 +1018,7 @@ static int test_event(struct test__event_st *e)
 	if (evlist == NULL)
 		return -ENOMEM;
 
-	ret = parse_events(evlist, e->name, 0);
+	ret = parse_events(evlist, e->name);
 	if (ret) {
 		pr_debug("failed to parse event '%s', err %d\n",
 			 e->name, ret);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 626c120..d3bf570 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -872,8 +872,7 @@ int parse_events_terms(struct list_head *terms, const char *str)
 	return ret;
 }
 
-int parse_events(struct perf_evlist *evlist, const char *str,
-		 int unset __maybe_unused)
+int parse_events(struct perf_evlist *evlist, const char *str)
 {
 	struct parse_events_data__events data = {
 		.list = LIST_HEAD_INIT(data.list),
@@ -900,7 +899,7 @@ int parse_events_option(const struct option *opt, const char *str,
 			int unset __maybe_unused)
 {
 	struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
-	int ret = parse_events(evlist, str, unset);
+	int ret = parse_events(evlist, str);
 
 	if (ret) {
 		fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index b7af80b..7c5244f 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -29,8 +29,7 @@ const char *event_type(int type);
 
 extern int parse_events_option(const struct option *opt, const char *str,
 			       int unset);
-extern int parse_events(struct perf_evlist *evlist, const char *str,
-			int unset);
+extern int parse_events(struct perf_evlist *evlist, const char *str);
 extern int parse_events_terms(struct list_head *terms, const char *str);
 extern int parse_filter(const struct option *opt, const char *str, int unset);
 
-- 
1.7.11.7


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/4] perf tool: Add formula interface to interface ratio definitions
  2013-01-15 13:39 [RFC 0/4] perf tool: Adding ratios support Jiri Olsa
  2013-01-15 13:39 ` [PATCH 1/4] perf tool: Remove unused 'unset' parameter from parse_events Jiri Olsa
@ 2013-01-15 13:39 ` Jiri Olsa
  2013-01-15 13:39 ` [PATCH 3/4] perf stat: Adding -f option to load and process ratios Jiri Olsa
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Jiri Olsa @ 2013-01-15 13:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Namhyung Kim, Corey Ashford,
	Frederic Weisbecker, Ingo Molnar, Paul Mackerras, Peter Zijlstra,
	Andi Kleen, David Ahern, Ulrich Drepper

Adding formula object to interface formula definitions like:

set {
        events = {cycles,instructions,branch-instructions}:u

        cpi {
                formula = cycles / instructions
                desc = cycles per instruction
        }

	branch-rate {
                formula = branch-instructions / instructions
                desc = branch rate
        }
}

The 'set' defines set of counter that share same events.
Each 'set' defines:
  events   - event string that would go into stat/record -e option
  counters - any number of counters based on above events

Each counter (cpi/branch-rate) defines
  formula - formula with that produce the counter number
            event names and numbers could be used
  desc    - text description of the counter

Interface:
  perf_formula__init
  - initialize perf_formula handler

  perf_formula__load
  - load file into the handler

  perf_formula__free
  - cleanup

  perf_formula__set
  - get 'set' handler

  perf_formula__evlist
  - update perf_evlist with needed events

  perf_formula__print
  - display output ratios

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ulrich Drepper <drepper@gmail.com>
---
 tools/perf/Makefile       |  11 ++
 tools/perf/util/evlist.c  |  13 ++
 tools/perf/util/evlist.h  |   4 +
 tools/perf/util/formula.c | 387 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/formula.h | 113 ++++++++++++++
 tools/perf/util/formula.l | 119 ++++++++++++++
 tools/perf/util/formula.y | 248 +++++++++++++++++++++++++++++
 7 files changed, 895 insertions(+)
 create mode 100644 tools/perf/util/formula.c
 create mode 100644 tools/perf/util/formula.h
 create mode 100644 tools/perf/util/formula.l
 create mode 100644 tools/perf/util/formula.y

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 103ed95..0f120a4 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -296,8 +296,15 @@ $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
 $(OUTPUT)util/pmu-bison.c: util/pmu.y
 	$(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c
 
+$(OUTPUT)util/formula-flex.c: util/formula.l util/formula.y $(OUTPUT)util/formula-bison.c
+	$(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/formula-flex.h $(PARSER_DEBUG_FLEX) -t util/formula.l > $(OUTPUT)util/formula-flex.c
+
+$(OUTPUT)util/formula-bison.c: util/formula.y
+	$(QUIET_BISON)$(BISON) -v util/formula.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/formula-bison.c
+
 $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
 $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
+$(OUTPUT)util/formula.o: $(OUTPUT)util/formula-flex.c $(OUTPUT)util/formula-bison.c
 
 LIB_FILE=$(OUTPUT)libperf.a
 
@@ -391,6 +398,7 @@ LIB_H += util/intlist.h
 LIB_H += util/perf_regs.h
 LIB_H += util/unwind.h
 LIB_H += util/vdso.h
+LIB_H += util/formula.h
 LIB_H += ui/helpline.h
 LIB_H += ui/progress.h
 LIB_H += ui/util.h
@@ -464,6 +472,9 @@ LIB_OBJS += $(OUTPUT)util/rblist.o
 LIB_OBJS += $(OUTPUT)util/intlist.o
 LIB_OBJS += $(OUTPUT)util/vdso.o
 LIB_OBJS += $(OUTPUT)util/stat.o
+LIB_OBJS += $(OUTPUT)util/formula.o
+LIB_OBJS += $(OUTPUT)util/formula-flex.o
+LIB_OBJS += $(OUTPUT)util/formula-bison.o
 
 LIB_OBJS += $(OUTPUT)ui/setup.o
 LIB_OBJS += $(OUTPUT)ui/helpline.o
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index dc8aee9..e1a6126 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -845,3 +845,16 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp)
 
 	return printed + fprintf(fp, "\n");;
 }
+
+struct perf_evsel*
+perf_evlist__find_evsel_name(struct perf_evlist *evlist, char *name)
+{
+	struct perf_evsel *evsel;
+
+	list_for_each_entry(evsel, &evlist->entries, node) {
+		if (!strcmp(name, perf_evsel__name(evsel)))
+			return evsel;
+	}
+
+	return NULL;
+}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 457e235..a8630f2 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -135,4 +135,8 @@ static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist)
 }
 
 size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
+
+struct perf_evsel*
+perf_evlist__find_evsel_name(struct perf_evlist *evlist, char *name);
+
 #endif /* __PERF_EVLIST_H */
diff --git a/tools/perf/util/formula.c b/tools/perf/util/formula.c
new file mode 100644
index 0000000..e9fa05b
--- /dev/null
+++ b/tools/perf/util/formula.c
@@ -0,0 +1,387 @@
+
+#include <linux/compiler.h>
+#include <stdio.h>
+#include "stat.h"
+#include "parse-events.h"
+#include "formula.h"
+#include "formula-bison.h"
+#define YY_EXTRA_TYPE int
+#include "formula-flex.h"
+
+#ifdef PARSER_DEBUG
+extern int perf_formula_debug;
+#endif
+int perf_formula_parse(void *_data, void *scanner);
+
+void perf_formula__init(struct perf_formula *f)
+{
+	memset(f, 0x0, sizeof(*f));
+	INIT_LIST_HEAD(&f->head_files);
+}
+
+static int scanner_expr(const char *str, void *data)
+{
+	YY_BUFFER_STATE buffer;
+	void *scanner;
+	int ret;
+
+	ret = perf_formula_lex_init_extra(PF_START_EXPR, &scanner);
+	if (ret)
+		return ret;
+
+	buffer = perf_formula__scan_string(str, scanner);
+
+#ifdef PARSER_DEBUG
+	perf_formula_debug = 1;
+#endif
+	ret = perf_formula_parse(data, scanner);
+
+	perf_formula__flush_buffer(buffer, scanner);
+	perf_formula__delete_buffer(buffer, scanner);
+	perf_formula_lex_destroy(scanner);
+	return ret;
+}
+
+static int scanner_config(FILE *file, void *data)
+{
+	void *scanner;
+	int ret;
+
+	ret = perf_formula_lex_init_extra(PF_START_CONFIG, &scanner);
+	if (ret)
+		return ret;
+
+	perf_formula_set_in(file, scanner);
+
+#ifdef PARSER_DEBUG
+	perf_formula_debug = 1;
+#endif
+	ret = perf_formula_parse(data, scanner);
+
+	perf_formula_lex_destroy(scanner);
+	return ret;
+}
+
+static int config_parse(struct perf_formula__file *file)
+{
+	FILE *f;
+	int ret;
+
+	f = fopen(file->path, "r");
+	if (!f)
+		return -EINVAL;
+
+	ret = scanner_config(f, file);
+
+	fclose(f);
+	return ret;
+}
+
+static int counter_init(struct perf_formula__counter *counter)
+{
+	struct perf_formula__expr expr = {
+		.test_only = true,
+	};
+
+	return scanner_expr(counter->formula, &expr);
+}
+
+static int set_init(struct perf_formula__set *set)
+{
+	struct perf_formula__counter *counter;
+	int ret = 0;
+
+	list_for_each_entry(counter, &set->head_counters, list) {
+		ret = counter_init(counter);
+		if (ret)
+			break;
+
+		counter->set = set;
+	}
+
+	return ret;
+}
+
+static int file_init(struct perf_formula__file *file)
+{
+	struct perf_formula__set *set;
+	int ret;
+
+	ret = config_parse(file);
+
+	list_for_each_entry(set, &file->head_sets, list) {
+		ret = set_init(set);
+		if (ret)
+			break;
+	}
+
+	return ret;
+}
+
+static void file_free(struct perf_formula__file *file)
+{
+	struct perf_formula__set *set;
+
+	list_for_each_entry(set, &file->head_sets, list) {
+		struct perf_formula__counter *counter;
+
+		list_for_each_entry(counter, &set->head_counters, list)
+			free(counter);
+
+		free(set);
+	}
+
+	free(file->path);
+	free(file);
+}
+
+int perf_formula__load(struct perf_formula *f, char *path)
+{
+	struct perf_formula__file *file;
+	int ret;
+
+	file = zalloc(sizeof(*file));
+	if (!file)
+		return -ENOMEM;
+
+	INIT_LIST_HEAD(&file->list);
+	INIT_LIST_HEAD(&file->head_sets);
+	file->path = strdup(path);
+
+	ret = file_init(file);
+	if (ret)
+		file_free(file);
+	else
+		list_add_tail(&file->list, &f->head_files);
+
+	return ret;
+}
+
+int perf_formula__free(struct perf_formula *f)
+{
+	struct perf_formula__file *file;
+
+	list_for_each_entry(file, &f->head_files, list)
+		file_free(file);
+
+	return 0;
+}
+
+enum {
+	CB_NEXT,
+	CB_OK,
+	CB_FAIL,
+};
+
+typedef int (*set_cb)(struct perf_formula__set *set, void *data);
+
+static int for_each_set(struct perf_formula *formula,
+			set_cb cb, void *data)
+{
+	struct perf_formula__file *file;
+
+	list_for_each_entry(file, &formula->head_files, list) {
+		struct perf_formula__set *set;
+
+		list_for_each_entry(set, &file->head_sets, list) {
+			int ret = cb(set, data);
+
+			if (ret == CB_NEXT)
+				continue;
+			else if (ret == CB_OK)
+				return 0;
+			else if (ret == CB_FAIL)
+				return -1;
+		}
+	}
+
+	return 0;
+}
+struct find_set_data {
+	struct perf_formula__set *set;
+	char *name;
+};
+
+static int find_set_cb(struct perf_formula__set *set, void *data)
+{
+	struct find_set_data *d = data;
+
+	if (strcmp(set->name, d->name))
+		return CB_NEXT;
+
+	d->set = set;
+	return CB_OK;
+}
+
+struct perf_formula__set*
+perf_formula__set(struct perf_formula *f, char *name)
+{
+	struct find_set_data data = {
+		.name = name,
+	};
+
+	if (for_each_set(f, find_set_cb, &data))
+		return NULL;
+
+	return data.set;
+}
+
+static int counter_print(FILE *out, struct perf_formula__counter *counter,
+			 struct perf_formula__expr *expr)
+{
+	int ret;
+
+	ret = scanner_expr(counter->formula, expr);
+
+	if (ret) {
+		fprintf(stderr, "failed to process counter %s\n",
+			counter->name);
+		return -1;
+	}
+
+	fprintf(out, "%'18.8F %-25s # %s\n",
+		expr->result, counter->name, counter->desc);
+
+	return ret;
+}
+
+int perf_formula__print(FILE *file,
+			struct perf_formula__set *set,
+			struct perf_evlist *evlist,
+			struct perf_formula__value **values)
+{
+	struct perf_formula__counter *counter;
+	struct perf_formula__expr expr = {
+		.evlist = evlist,
+		.values = values,
+	};
+
+	list_for_each_entry(counter, &set->head_counters, list)
+		if (counter_print(file, counter, &expr))
+			break;
+
+	fprintf(file, "\n");
+	return 0;
+}
+
+static int set_evlist(struct perf_formula__set *set,
+		      struct perf_evlist *evlist)
+{
+	struct perf_evlist *evlist_tmp = evlist;
+
+	if (set->loaded)
+		return 0;
+
+	if (parse_events(evlist_tmp, set->events))
+		return -1;
+
+	set->loaded = true;
+
+	return 0;
+}
+
+int perf_formula__evlist(struct perf_formula__set *set,
+			 struct perf_evlist *evlist)
+{
+	return set_evlist(set, evlist);
+}
+
+struct perf_formula__counter*
+perf_formula__counter_new(char *name, struct list_head *head)
+{
+	struct perf_formula__counter *counter;
+	struct perf_formula__config *config;
+
+	counter = zalloc(sizeof(*counter));
+	if (!counter)
+		return NULL;
+
+	INIT_LIST_HEAD(&counter->list);					\
+
+	list_for_each_entry(config, head, list) {
+		switch (config->type) {
+		case PERF_FORMULA__CONFIG_FORMULA:
+			counter->formula = config->formula;
+			break;
+
+		case PERF_FORMULA__CONFIG_DESC:
+			counter->desc = config->desc;
+			break;
+
+		case PERF_FORMULA__CONFIG_COUNTER:
+		case PERF_FORMULA__CONFIG_EVENTS:
+		default:
+			BUG_ON(1);
+		}
+	}
+
+	counter->name = strdup(name);
+	return counter;
+}
+
+struct perf_formula__set*
+perf_formula__set_new(char *name, struct list_head *head)
+{
+	struct perf_formula__set *set;
+	struct perf_formula__config *config;
+
+	set = zalloc(sizeof(*set));
+	if (!set)
+		return NULL;
+
+	INIT_LIST_HEAD(&set->list);
+	INIT_LIST_HEAD(&set->head_counters);
+
+	list_for_each_entry(config, head, list) {
+		struct perf_formula__counter *counter;
+
+		switch (config->type) {
+		case PERF_FORMULA__CONFIG_COUNTER:
+			counter = config->counter;
+
+			list_add_tail(&counter->list,
+				      &set->head_counters);
+			break;
+
+		case PERF_FORMULA__CONFIG_EVENTS:
+			if (set->events) {
+				free(set);
+				return NULL;
+			}
+
+			set->events = config->events;
+			break;
+
+		case PERF_FORMULA__CONFIG_FORMULA:
+		case PERF_FORMULA__CONFIG_DESC:
+		default:
+			BUG_ON(1);
+		}
+	}
+
+	set->name = strdup(name);
+	return set;
+}
+
+struct perf_stat {
+	struct stats	  res_stats[3];
+};
+
+double perf_formula__expr_resolve(struct perf_formula__expr *expr,
+				  char *name)
+{
+	struct perf_evsel *evsel;
+	double res = 0;
+
+	if (expr->test_only)
+		return 1;
+
+	evsel = perf_evlist__find_evsel_name(expr->evlist, name);
+	if (evsel) {
+		struct perf_stat *ps = evsel->priv;
+		res = avg_stats(&ps->res_stats[0]);
+	} else
+		pr_err("failed to resolve event '%s'\n", name);
+
+	return res;
+}
diff --git a/tools/perf/util/formula.h b/tools/perf/util/formula.h
new file mode 100644
index 0000000..e7d988b
--- /dev/null
+++ b/tools/perf/util/formula.h
@@ -0,0 +1,113 @@
+#ifndef __PERF_FORMULA
+#define __PERF_FORMULA
+
+/*
+ * format:
+ *
+ * IPC {
+ *    events = cycles,instructions
+ *
+ *    counter IPC {
+ *       formula = instructions/cycles
+ *       desc = krava
+ *    }
+ * }
+ *
+ */
+
+#include <linux/list.h>
+#include "evlist.h"
+
+struct perf_formula {
+	struct list_head head_files;
+};
+
+struct perf_formula__file {
+	char *path;
+
+	struct list_head head_sets;
+	struct list_head list;
+};
+
+struct perf_formula__set {
+	char *name;
+	char *events;
+	bool loaded;
+
+	struct list_head head_counters;
+	struct list_head list;
+};
+
+struct perf_formula__counter {
+	char *name;
+	char *formula;
+	char *desc;
+
+	struct perf_formula__set *set;
+
+	struct list_head list;
+};
+
+#define PERF_FORMULA__VALUE(n, p)	\
+{					\
+	.name = n,			\
+	.ptr  = p,			\
+}
+
+struct perf_formula__value {
+	char   *name;
+	double *ptr;
+};
+
+struct perf_formula__expr {
+	struct perf_evlist *evlist;
+	struct perf_formula__value **values;
+	double result;
+	bool test_only;
+};
+
+struct perf_formula__config {
+	enum {
+		PERF_FORMULA__CONFIG_COUNTER,
+		PERF_FORMULA__CONFIG_EVENTS,
+		PERF_FORMULA__CONFIG_FORMULA,
+		PERF_FORMULA__CONFIG_DESC,
+	} type;
+
+	union {
+		struct perf_formula__counter *counter;
+		char *events;
+		char *formula;
+		char *desc;
+	};
+
+	struct list_head list;
+};
+
+
+void perf_formula__init(struct perf_formula *f);
+
+int perf_formula__load(struct perf_formula *f, char *path);
+int perf_formula__free(struct perf_formula *f);
+
+struct perf_formula__set*
+perf_formula__set(struct perf_formula *f, char *name);
+
+int perf_formula__evlist(struct perf_formula__set *set,
+			 struct perf_evlist *evlist);
+
+int perf_formula__print(FILE *file,
+			struct perf_formula__set *set,
+			struct perf_evlist *evlist,
+			struct perf_formula__value **values);
+
+struct perf_formula__counter*
+perf_formula__counter_new(char *name, struct list_head *head);
+
+struct perf_formula__set*
+perf_formula__set_new(char *name, struct list_head *head);
+
+double perf_formula__expr_resolve(struct perf_formula__expr *expr,
+				  char *name);
+
+#endif /* __PERF_FORMULA */
diff --git a/tools/perf/util/formula.l b/tools/perf/util/formula.l
new file mode 100644
index 0000000..e7669a5
--- /dev/null
+++ b/tools/perf/util/formula.l
@@ -0,0 +1,119 @@
+
+%option reentrant
+%option bison-bridge
+%option prefix="perf_formula_"
+%option stack
+
+%{
+#include "formula-bison.h"
+#include "formula.h"
+
+char *perf_formula_get_text(yyscan_t yyscanner);
+YYSTYPE *perf_formula_get_lval(yyscan_t yyscanner);
+
+static int __value(YYSTYPE *yylval, char *str, int base, int token)
+{
+	double num;
+
+	errno = 0;
+	num = strtoull(str, NULL, base);
+	if (errno)
+		return PF_ERROR;
+
+	yylval->num = num;
+	return token;
+}
+
+static int value(yyscan_t scanner, int base)
+{
+	YYSTYPE *yylval = perf_formula_get_lval(scanner);
+	char *text = perf_formula_get_text(scanner);
+
+	return __value(yylval, text, base, PF_VALUE);
+}
+
+static int str(yyscan_t scanner, int token)
+{
+	YYSTYPE *yylval = perf_formula_get_lval(scanner);
+	char *text = perf_formula_get_text(scanner);
+
+	yylval->str = strdup(text);
+	return token;
+}
+
+%}
+
+num_dec		[0-9]+
+num_hex		0x[a-fA-F0-9]+
+name		[a-zA-Z_*?][a-zA-Z0-9_*?\.-]*
+
+%x config
+%x expr
+%x config_eoln_str
+
+%%
+
+%{
+	{
+		int start_token;
+
+		start_token = perf_formula_get_extra(yyscanner);
+
+		if (start_token == PF_START_CONFIG)
+			BEGIN(config);
+		else if (start_token == PF_START_EXPR)
+			BEGIN(expr);
+
+		if (start_token) {
+			perf_formula_set_extra(NULL, yyscanner);
+			return start_token;
+		}
+	}
+%}
+
+<config>{
+"{"		{ return '{'; }
+"}"		{ return '}'; }
+"="		{ return '='; }
+
+events		{ BEGIN(config_eoln_str); return PF_EVENTS; }
+formula		{ BEGIN(config_eoln_str); return PF_FORMULA; }
+desc		{ BEGIN(config_eoln_str); return PF_DESC; }
+
+{name}		{ return str(yyscanner, PF_NAME); }
+
+\n		{ }
+}
+
+<config_eoln_str>{
+[ \t]*=		{ return '='; }
+[^=\n]+		{
+			str(yyscanner, PF_EOLN_STR);
+			BEGIN(config);
+			return PF_EOLN_STR;
+                }
+
+<<EOF>>		{
+			BEGIN(config);
+		}
+}
+
+<expr>{
+"*"		{ return '*'; }
+"-"		{ return '-'; }
+"+"		{ return '+'; }
+"/"		{ return '/'; }
+
+{name}		{ return str(yyscanner, PF_NAME); }
+{num_dec}	{ return value(yyscanner, 10); }
+{num_hex}	{ return value(yyscanner, 16); }
+
+.		{ }
+}
+
+%%
+
+int perf_formula_wrap(void *scanner __maybe_unused)
+{
+	return 1;
+}
diff --git a/tools/perf/util/formula.y b/tools/perf/util/formula.y
new file mode 100644
index 0000000..42b6ebf
--- /dev/null
+++ b/tools/perf/util/formula.y
@@ -0,0 +1,248 @@
+%pure-parser
+%name-prefix "perf_formula_"
+%parse-param {void *_data}
+%parse-param {void *scanner}
+%lex-param {void* scanner}
+
+%left '+' '-' '*' '/'
+
+%{
+
+#define YYDEBUG 1
+
+#include "util.h"
+#include "formula.h"
+#include "formula-bison.h"
+
+extern int formula_lex(YYSTYPE* lvalp, void* scanner);
+
+
+#define ABORT() YYABORT
+
+#define ABORT_ON(val) \
+do { \
+	if (val) \
+		YYABORT; \
+} while (0)
+
+#define HEAD() ({						\
+	struct list_head *__head = zalloc(sizeof(*__head));	\
+	ABORT_ON(!__head);					\
+	INIT_LIST_HEAD(__head);					\
+	__head;							\
+})
+
+#define CONFIG() ({						\
+	struct perf_formula__config *__config;			\
+	__config = zalloc(sizeof(*__config));			\
+	ABORT_ON(!__config);					\
+	INIT_LIST_HEAD(&__config->list);			\
+	__config;						\
+})
+
+%}
+
+%token PF_START_CONFIG PF_START_EXPR
+%token PF_NAME
+%token PF_VALUE
+%token PF_FORMULA
+%token PF_DESC
+%token PF_EVENTS
+%token PF_EOLN_STR
+%token PF_ERROR
+
+%type <str> PF_NAME
+%type <num> PF_VALUE
+%type <str> PF_EOLN_STR
+%type <head> set_def
+%type <head> counter_def
+%type <config> set_token
+%type <config> counter_token
+%type <counter> counter
+%type <num> expr
+
+%union
+{
+	char *str;
+	double num;
+	struct list_head *head;
+	struct config *config;
+	struct perf_formula__counter *counter;
+}
+
+%%
+
+start:
+PF_START_CONFIG start_config
+|
+PF_START_EXPR start_expr
+
+start_config: sets
+
+sets:
+sets set | set
+
+set:
+PF_NAME '{' set_def '}'
+{
+	struct perf_formula__file *file = _data;
+	struct perf_formula__set *set;
+
+	set = perf_formula__set_new($1, $3);
+	ABORT_ON(!set);
+
+	list_add_tail(&set->list, &file->head_sets);
+}
+
+set_def:
+set_def set_token
+{
+	struct list_head *head = $1;
+	struct perf_formula__config *config = $2;
+
+	list_add_tail(&config->list, head);
+	$$ = head;
+}
+|
+set_token
+{
+	struct list_head *head = HEAD();
+	struct perf_formula__config *config = $1;
+
+	list_add_tail(&config->list, head);
+	$$ = head;
+}
+
+set_token:
+counter
+{
+	struct perf_formula__config *config = CONFIG();
+
+	config->type = PERF_FORMULA__CONFIG_COUNTER;
+	config->counter = $1;
+
+	$$ = config;
+}
+|
+PF_EVENTS '=' PF_EOLN_STR
+{
+	struct perf_formula__config *config = CONFIG();
+
+	config->type = PERF_FORMULA__CONFIG_EVENTS;
+	config->counter = $3;
+
+	$$ = config;
+}
+
+counter:
+PF_NAME '{' counter_def '}'
+{
+	struct perf_formula__counter *counter;
+	struct config *config;
+
+	counter = perf_formula__counter_new($1, $3);
+	ABORT_ON(!counter);
+
+	$$ = counter;
+}
+
+counter_def:
+counter_def counter_token
+{
+	struct list_head *head = $1;
+	struct perf_formula__config *config = $2;
+
+	list_add_tail(&config->list, head);
+	$$ = head;
+}
+|
+counter_token
+{
+	struct list_head *head = HEAD();
+	struct perf_formula__config *config = $1;
+
+	list_add_tail(&config->list, head);
+	$$ = head;
+}
+
+counter_token:
+PF_FORMULA '=' PF_EOLN_STR
+{
+	struct perf_formula__config *config = CONFIG();
+
+	config->type = PERF_FORMULA__CONFIG_FORMULA;
+	config->counter = $3;
+
+	$$ = config;
+}
+|
+PF_DESC '=' PF_EOLN_STR
+{
+	struct perf_formula__config *config = CONFIG();
+
+	config->type = PERF_FORMULA__CONFIG_DESC;
+	config->counter = $3;
+
+	$$ = config;
+}
+
+start_expr:
+expr
+{
+	struct perf_formula__expr *expr = _data;
+
+	expr->result = $1;
+}
+
+expr:
+PF_VALUE
+{
+	$$ = $1;
+}
+|
+PF_NAME
+{
+	$$ = perf_formula__expr_resolve(_data, $1);
+}
+|
+'-' expr
+{
+	$$ = - $2;
+}
+|
+expr '+' expr
+{
+	$$ = $1 + $3;
+}
+|
+expr '-' expr
+{
+	$$ = $1 - $3;
+}
+|
+expr '*' expr
+{
+	$$ = $1 * $3;
+}
+|
+expr '/' expr
+{
+	if (!$3) {
+		pr_err("division by zero\n");
+		ABORT();
+	}
+
+	$$ = $1 / $3;
+}
+|
+'(' expr ')'
+{
+}
+
+%%
+
+void perf_formula_error(void *data __maybe_unused,
+			void *scanner __maybe_unused,
+			char const *msg __maybe_unused)
+{
+}
-- 
1.7.11.7


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/4] perf stat: Adding -f option to load and process ratios
  2013-01-15 13:39 [RFC 0/4] perf tool: Adding ratios support Jiri Olsa
  2013-01-15 13:39 ` [PATCH 1/4] perf tool: Remove unused 'unset' parameter from parse_events Jiri Olsa
  2013-01-15 13:39 ` [PATCH 2/4] perf tool: Add formula interface to interface ratio definitions Jiri Olsa
@ 2013-01-15 13:39 ` Jiri Olsa
  2013-01-15 13:39 ` [PATCH 4/4] perf tool: Adding formula.conf file for testing Jiri Olsa
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Jiri Olsa @ 2013-01-15 13:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Namhyung Kim, Corey Ashford,
	Frederic Weisbecker, Ingo Molnar, Paul Mackerras, Peter Zijlstra,
	Andi Kleen, David Ahern, Ulrich Drepper

Adding -f option to specify the formula definition to use.
Its value needs to be specified in following form:
  'file:set'

where 'file' is the formula definition file and the 'set'
is the name of the set to use for output.

With following formula.conf config file:
---
  cpi {
          events = {cycles,instructions}:u

          CPI {
                  formula = cycles / instructions
                  desc = cycles per instruction
          }
  }

  branch {
          events = {instructions,branch-instructions,branch-misses}:u

          branch-rate {
                  formula = branch-instructions / instructions
                  desc = branch rate
          }

          branch-miss-rate {
                  formula = branch-misses / instructions
                  desc = branch misprediction rate
          }

          branch-miss-ratio{
                  formula = branch-misses / branch-instructions
                  desc = branch misprediction ratio
          }
  }
---

You'll get following result:

  $ perf stat -f formula.conf:branch kill
  usage: kill [ -s signal | -p ] [ -a ] pid ...
         kill -l [ signal ]

   Performance counter stats for 'kill':

             184,195 instructions              #    0.00  insns per cycle
              40,907 branch-instructions
               4,815 branch-misses             #   11.77% of all branches

         0.000655767 seconds time elapsed

          0.22208529 branch-rate               #  branch rate
          0.02614077 branch-miss-rate          #  branch misprediction rate
          0.11770602 branch-miss-ratio         #  branch misprediction ratio

  $ perf stat -f formula.conf:cpi kill
  usage: kill [ -s signal | -p ] [ -a ] pid ...
         kill -l [ signal ]

   Performance counter stats for 'kill':

             356,635 cycles                    #    0.000 GHz
             187,191 instructions              #    0.52  insns per cycle

         0.001907600 seconds time elapsed

          1.90519309 CPI                       #  cycles per instruction

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ulrich Drepper <drepper@gmail.com>
---
 tools/perf/builtin-stat.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1c2ac14..06f79e5 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -56,6 +56,7 @@
 #include "util/cpumap.h"
 #include "util/thread.h"
 #include "util/thread_map.h"
+#include "util/formula.h"
 
 #include <stdlib.h>
 #include <sys/prctl.h>
@@ -67,6 +68,9 @@
 
 static struct perf_evlist	*evsel_list;
 
+static struct perf_formula	 formula;
+static struct perf_formula__set	*formula_set;
+
 static struct perf_target	target = {
 	.uid	= UINT_MAX,
 };
@@ -1065,6 +1069,42 @@ static int add_default_attributes(void)
 	return perf_evlist__add_default_attrs(evsel_list, very_very_detailed_attrs);
 }
 
+static int formula_option(const struct option *opt __maybe_unused,
+			  const char *str, int unset __maybe_unused)
+{
+	char *name;
+
+	if (no_aggr) {
+		pr_err("failed to run formulas with no aggr mode\n");
+		return -1;
+	}
+
+	name = strrchr(str, ':');
+	if (!name) {
+		pr_err("need to specify set name\n");
+		return -1;
+	}
+
+	*name++ = 0x0;
+
+	pr_debug("formula file '%s', name '%s'\n", str, name);
+
+	perf_formula__init(&formula);
+
+	if (perf_formula__load(&formula, (char *) str)) {
+		pr_err("failed to load formula file '%s'\n", str);
+		return -1;
+	}
+
+	formula_set = perf_formula__set(&formula, name);
+	if (!formula_set) {
+		pr_err("failed to find formula counter '%s'\n", name);
+		return -1;
+	}
+
+	return 0;
+}
+
 int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 	bool append_file = false;
@@ -1076,6 +1116,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 		     parse_events_option),
 	OPT_CALLBACK(0, "filter", &evsel_list, "filter",
 		     "event filter", parse_filter),
+	OPT_CALLBACK('f', "formula", NULL, "formula",
+		     "counters formula, file[:name]",
+		     formula_option),
 	OPT_BOOLEAN('i', "no-inherit", &no_inherit,
 		    "child tasks do not inherit counters"),
 	OPT_STRING('p', "pid", &target.pid, "pid",
@@ -1134,6 +1177,12 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	argc = parse_options(argc, argv, options, stat_usage,
 		PARSE_OPT_STOP_AT_NON_OPTION);
 
+	if (formula_set &&
+	    perf_formula__evlist(formula_set, evsel_list)) {
+		fprintf(stderr, "failed to load formula events\n");
+		usage_with_options(stat_usage, options);
+	}
+
 	output = stderr;
 	if (output_name && strcmp(output_name, "-"))
 		output = NULL;
@@ -1242,13 +1291,23 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 		status = run_perf_stat(argc, argv);
 	}
 
-	if (status != -1)
+	if (status != -1) {
 		print_stat(argc, argv);
+
+		if (formula_set)
+			perf_formula__print(output, formula_set,
+					    evsel_list, NULL);
+	}
+
 out_free_fd:
 	list_for_each_entry(pos, &evsel_list->entries, node)
 		perf_evsel__free_stat_priv(pos);
 	perf_evlist__delete_maps(evsel_list);
 out:
 	perf_evlist__delete(evsel_list);
+
+	if (formula_set)
+		perf_formula__free(&formula);
+
 	return status;
 }
-- 
1.7.11.7


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4/4] perf tool: Adding formula.conf file for testing
  2013-01-15 13:39 [RFC 0/4] perf tool: Adding ratios support Jiri Olsa
                   ` (2 preceding siblings ...)
  2013-01-15 13:39 ` [PATCH 3/4] perf stat: Adding -f option to load and process ratios Jiri Olsa
@ 2013-01-15 13:39 ` Jiri Olsa
  2013-01-16 13:13 ` [RFC 0/4] perf tool: Adding ratios support Will Deacon
  2013-01-16 14:00 ` Ulrich Drepper
  5 siblings, 0 replies; 16+ messages in thread
From: Jiri Olsa @ 2013-01-15 13:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Namhyung Kim, Corey Ashford,
	Frederic Weisbecker, Ingo Molnar, Paul Mackerras, Peter Zijlstra,
	Andi Kleen, David Ahern, Ulrich Drepper

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ulrich Drepper <drepper@gmail.com>
---
 tools/perf/formula.conf | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 tools/perf/formula.conf

diff --git a/tools/perf/formula.conf b/tools/perf/formula.conf
new file mode 100644
index 0000000..852cb9a
--- /dev/null
+++ b/tools/perf/formula.conf
@@ -0,0 +1,28 @@
+
+cpi {
+	events = {cycles,instructions}:u
+
+	CPI {
+		formula = cycles / instructions
+		desc = cycles per instruction
+	}
+}
+
+branch {
+	events = {instructions,branch-instructions,branch-misses}:u
+
+	branch-rate {
+		formula = branch-instructions / instructions
+		desc = branch rate
+	}
+
+	branch-miss-rate {
+		formula = branch-misses / instructions
+		desc = branch misprediction rate
+	}
+
+	branch-miss-ratio{
+		formula = branch-misses / branch-instructions
+		desc = branch misprediction ratio
+	}
+}
-- 
1.7.11.7


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-15 13:39 [RFC 0/4] perf tool: Adding ratios support Jiri Olsa
                   ` (3 preceding siblings ...)
  2013-01-15 13:39 ` [PATCH 4/4] perf tool: Adding formula.conf file for testing Jiri Olsa
@ 2013-01-16 13:13 ` Will Deacon
  2013-01-16 13:30   ` Jiri Olsa
  2013-01-16 14:00 ` Ulrich Drepper
  5 siblings, 1 reply; 16+ messages in thread
From: Will Deacon @ 2013-01-16 13:13 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Namhyung Kim,
	Corey Ashford, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
	Peter Zijlstra

On Tue, Jan 15, 2013 at 01:39:50PM +0000, Jiri Olsa wrote:
> hi,

Hi Jiri,

> adding support to predefine event ratios formulas so they could
> be used easily in perf.
> 
> The formulas are handed in the config file with following format:
> 
>   set {
>         events = {cycles,instructions,branch-instructions}:u
> 
>         cpi {
>                 formula = cycles / instructions
>                 desc = cycles per instruction
>         }
> 
> 	branch-rate {
>                 formula = branch-instructions / instructions
>                 desc = branch rate
>         }
>   }
> 
>   The 'set' defines set of counter that share same events.
>   Each 'set' defines:
>     events   - event string that would go into stat/record -e option
>     counters - any number of counters based on above events
> 
>   Each counter (cpi/branch-rate) defines
>     formula - formula with that produce the counter number
>               event names and numbers could be used
>     desc    - text description of the counter
> 
> The formula can currently contain any event from the set::events
> plus any number (int). There'll be support in future for outside
> values runtime and other if needed.

Just to say that I *really* like this idea! If we extended it to include
other operators then it would help us on ARM, where we often have events
like 'cache accesses' and 'cache misses' but not 'cache hits'.

> My current thinking is to have generic formulas file(s) for architectural
> events and add arch-specific ones once when we have the support for
> non-architectural events (already sent RFC, v2 is on its way..).

Would the architectural formula files also be in userspace, or is there any
merit to including useful PMU-specific formulae in sysfs, along with the
other PMU files?

Cheers,

Will

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-16 13:13 ` [RFC 0/4] perf tool: Adding ratios support Will Deacon
@ 2013-01-16 13:30   ` Jiri Olsa
  2013-01-17 10:23     ` Will Deacon
  0 siblings, 1 reply; 16+ messages in thread
From: Jiri Olsa @ 2013-01-16 13:30 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Namhyung Kim,
	Corey Ashford, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
	Peter Zijlstra

On Wed, Jan 16, 2013 at 01:13:18PM +0000, Will Deacon wrote:
> On Tue, Jan 15, 2013 at 01:39:50PM +0000, Jiri Olsa wrote:
> > hi,
> 
> Hi Jiri,
> 
> > adding support to predefine event ratios formulas so they could
> > be used easily in perf.
> > 
> > The formulas are handed in the config file with following format:
> > 
> >   set {
> >         events = {cycles,instructions,branch-instructions}:u
> > 
> >         cpi {
> >                 formula = cycles / instructions
> >                 desc = cycles per instruction
> >         }
> > 
> > 	branch-rate {
> >                 formula = branch-instructions / instructions
> >                 desc = branch rate
> >         }
> >   }
> > 
> >   The 'set' defines set of counter that share same events.
> >   Each 'set' defines:
> >     events   - event string that would go into stat/record -e option
> >     counters - any number of counters based on above events
> > 
> >   Each counter (cpi/branch-rate) defines
> >     formula - formula with that produce the counter number
> >               event names and numbers could be used
> >     desc    - text description of the counter
> > 
> > The formula can currently contain any event from the set::events
> > plus any number (int). There'll be support in future for outside
> > values runtime and other if needed.
> 
> Just to say that I *really* like this idea! If we extended it to include
> other operators then it would help us on ARM, where we often have events
> like 'cache accesses' and 'cache misses' but not 'cache hits'.

great, thanks for sharing this

The current operators set is just basic one to show the idea,
it can/will be expanded.

> 
> > My current thinking is to have generic formulas file(s) for architectural
> > events and add arch-specific ones once when we have the support for
> > non-architectural events (already sent RFC, v2 is on its way..).
> 
> Would the architectural formula files also be in userspace, or is there any
> merit to including useful PMU-specific formulae in sysfs, along with the
> other PMU files?

hum, isn't this too specific for sysfs files?

I think that's going to be the perf tool specific info.. so it's going
to be placed in its configuration files.


jirka

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-15 13:39 [RFC 0/4] perf tool: Adding ratios support Jiri Olsa
                   ` (4 preceding siblings ...)
  2013-01-16 13:13 ` [RFC 0/4] perf tool: Adding ratios support Will Deacon
@ 2013-01-16 14:00 ` Ulrich Drepper
  2013-01-16 14:25   ` Jiri Olsa
  5 siblings, 1 reply; 16+ messages in thread
From: Ulrich Drepper @ 2013-01-16 14:00 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Linux Kernel Mailing List, Arnaldo Carvalho de Melo,
	Namhyung Kim, Corey Ashford, Frederic Weisbecker, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Andi Kleen, David Ahern

On Tue, Jan 15, 2013 at 8:39 AM, Jiri Olsa <jolsa@redhat.com> wrote:
>   $ perf stat -f formula.conf:cpi kill
>   usage: kill [ -s signal | -p ] [ -a ] pid ...
>          kill -l [ signal ]

I do like this proposal.  The only comment I have is that perhaps the
command line syntax isn't ideal.  What you use above is tied to the
ratios be defined in the config file.  I would imagine that at least
over time (for some ratios probably right away) they become available
by default and don't require a config file.  Also, users might want to
put individualized ratio definitions in a config file which is read by
default.

How about the formulas becoming available whenever the config file is
read.  Maybe this means a few more keywords in the config file (ratio,
ratio-set, ...).  E.g.:

ratio-set branch {
          events = {instructions,branch-instructions,branch-misses}:u

          ratio branch-rate {
                  formula = branch-instructions / instructions
                  desc = branch rate
          }

          ratio branch-miss-rate {
                  formula = branch-misses / instructions
                  desc = branch misprediction rate
          }

          ratio branch-miss-ratio{
                  formula = branch-misses / branch-instructions
                  desc = branch misprediction ratio
          }
  }

You get the idea.  Maybe substitute "ratio":with "formula". Then allow
such a ratio/formula to be used just like a normal event, perhaps with
a special suffix/prefix to designate it.  This should then also mark
the events as part of a group so that the underlying counters are
scheduled in together.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-16 14:00 ` Ulrich Drepper
@ 2013-01-16 14:25   ` Jiri Olsa
  2013-01-16 15:12     ` Ulrich Drepper
  0 siblings, 1 reply; 16+ messages in thread
From: Jiri Olsa @ 2013-01-16 14:25 UTC (permalink / raw)
  To: Ulrich Drepper
  Cc: Linux Kernel Mailing List, Arnaldo Carvalho de Melo,
	Namhyung Kim, Corey Ashford, Frederic Weisbecker, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Andi Kleen, David Ahern

On Wed, Jan 16, 2013 at 09:00:07AM -0500, Ulrich Drepper wrote:
> On Tue, Jan 15, 2013 at 8:39 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> >   $ perf stat -f formula.conf:cpi kill
> >   usage: kill [ -s signal | -p ] [ -a ] pid ...
> >          kill -l [ signal ]
> 
> I do like this proposal.  The only comment I have is that perhaps the
> command line syntax isn't ideal.  What you use above is tied to the
> ratios be defined in the config file.  I would imagine that at least
> over time (for some ratios probably right away) they become available
> by default and don't require a config file.  Also, users might want to
> put individualized ratio definitions in a config file which is read by
> default.
> 
> How about the formulas becoming available whenever the config file is
> read.  Maybe this means a few more keywords in the config file (ratio,
> ratio-set, ...).  E.g.:
> 
> ratio-set branch {
>           events = {instructions,branch-instructions,branch-misses}:u
> 
>           ratio branch-rate {
>                   formula = branch-instructions / instructions
>                   desc = branch rate
>           }
> 
>           ratio branch-miss-rate {
>                   formula = branch-misses / instructions
>                   desc = branch misprediction rate
>           }
> 
>           ratio branch-miss-ratio{
>                   formula = branch-misses / branch-instructions
>                   desc = branch misprediction ratio
>           }
>   }

I was thinking having config files (global and arch specific)
comming with perf having predefined formulas.

Plus adding the possibility to load extra config file via command
line option.

> 
> You get the idea.  Maybe substitute "ratio":with "formula". Then allow
> such a ratio/formula to be used just like a normal event, perhaps with
> a special suffix/prefix to designate it.  This should then also mark

I like the idea of having ratios handled within event definitions
maybe even in a similar way like aliases are handled today.. like:

1)  -e 'ratio/branch-rate/'  # special event class
2)  -e 'ratio-branch-rate'   # 'ratio-' prefix
3)  -e cpu/branch-rate/      # handled like aliases, ratio name would need to be unique 
  ... ?

ideas?

Having both 2) with 3) seems good to me

> the events as part of a group so that the underlying counters are
> scheduled in together.

the 'events' definitions could be put into group by default,
meanwhile I used 'events = { ... }'

thanks,
jirka

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-16 14:25   ` Jiri Olsa
@ 2013-01-16 15:12     ` Ulrich Drepper
  2013-01-17  1:03       ` Namhyung Kim
  0 siblings, 1 reply; 16+ messages in thread
From: Ulrich Drepper @ 2013-01-16 15:12 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Linux Kernel Mailing List, Arnaldo Carvalho de Melo,
	Namhyung Kim, Corey Ashford, Frederic Weisbecker, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Andi Kleen, David Ahern

On Wed, Jan 16, 2013 at 9:25 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> I was thinking having config files (global and arch specific)
> comming with perf having predefined formulas.

All the more reason to not mention the file name or really any source
for the definition of the formula in the name,


> 1)  -e 'ratio/branch-rate/'  # special event class
> 2)  -e 'ratio-branch-rate'   # 'ratio-' prefix
> 3)  -e cpu/branch-rate/      # handled like aliases, ratio name would need to be unique
>   ... ?

I think 3 is the most extensible.  Perhaps use the syntax used in
other places.  We have these :u suffixes etc.  Perhaps have :r or :R
or whatever.

Given the other comments, we might want to avoid right away "ratio".
If the mechanism is generalized it could be used to express "counter1
- counter2" for events which cannot be expressed with a single counter
but are not really ratios.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-16 15:12     ` Ulrich Drepper
@ 2013-01-17  1:03       ` Namhyung Kim
  2013-01-17 16:05         ` Jiri Olsa
  0 siblings, 1 reply; 16+ messages in thread
From: Namhyung Kim @ 2013-01-17  1:03 UTC (permalink / raw)
  To: Ulrich Drepper
  Cc: Jiri Olsa, Linux Kernel Mailing List, Arnaldo Carvalho de Melo,
	Corey Ashford, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
	Peter Zijlstra, Andi Kleen, David Ahern

Hi,

On Wed, 16 Jan 2013 10:12:14 -0500, Ulrich Drepper wrote:
> On Wed, Jan 16, 2013 at 9:25 AM, Jiri Olsa <jolsa@redhat.com> wrote:
>> I was thinking having config files (global and arch specific)
>> comming with perf having predefined formulas.
>
> All the more reason to not mention the file name or really any source
> for the definition of the formula in the name,
>
>
>> 1)  -e 'ratio/branch-rate/'  # special event class
>> 2)  -e 'ratio-branch-rate'   # 'ratio-' prefix
>> 3)  -e cpu/branch-rate/      # handled like aliases, ratio name would need to be unique
>>   ... ?
>
> I think 3 is the most extensible.  Perhaps use the syntax used in
> other places.  We have these :u suffixes etc.  Perhaps have :r or :R
> or whatever.

I don't think it's a good idea.  The ':r' syntax is for modifiers to the
existing events so it doesn't match to this case IMHO.

I prefer a special event class like 1 since it's possible to include
non-cpu events to a ratio/formular.  In that case, using 'cpu' in the
PMU name can be misleading.

>
> Given the other comments, we might want to avoid right away "ratio".
> If the mechanism is generalized it could be used to express "counter1
> - counter2" for events which cannot be expressed with a single counter
> but are not really ratios.

Agreed.  Looks like "formular" is better.

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-16 13:30   ` Jiri Olsa
@ 2013-01-17 10:23     ` Will Deacon
  2013-01-21 19:13       ` Jiri Olsa
  0 siblings, 1 reply; 16+ messages in thread
From: Will Deacon @ 2013-01-17 10:23 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Namhyung Kim,
	Corey Ashford, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
	Peter Zijlstra

On Wed, Jan 16, 2013 at 01:30:33PM +0000, Jiri Olsa wrote:
> On Wed, Jan 16, 2013 at 01:13:18PM +0000, Will Deacon wrote:
> > On Tue, Jan 15, 2013 at 01:39:50PM +0000, Jiri Olsa wrote:
> > > The formula can currently contain any event from the set::events
> > > plus any number (int). There'll be support in future for outside
> > > values runtime and other if needed.
> > 
> > Just to say that I *really* like this idea! If we extended it to include
> > other operators then it would help us on ARM, where we often have events
> > like 'cache accesses' and 'cache misses' but not 'cache hits'.
> 
> great, thanks for sharing this
> 
> The current operators set is just basic one to show the idea,
> it can/will be expanded.

Makes sense.

> > > My current thinking is to have generic formulas file(s) for architectural
> > > events and add arch-specific ones once when we have the support for
> > > non-architectural events (already sent RFC, v2 is on its way..).
> > 
> > Would the architectural formula files also be in userspace, or is there any
> > merit to including useful PMU-specific formulae in sysfs, along with the
> > other PMU files?
> 
> hum, isn't this too specific for sysfs files?
> 
> I think that's going to be the perf tool specific info.. so it's going
> to be placed in its configuration files.

Understood. It would just be nice if the ARM perf backend could implement
more of the generic events, which would be possible if the kernel could
expose these formulae for those. Plumbing that together probably still
requires userspace changes though, in which case it's not worth it.

Will

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-17  1:03       ` Namhyung Kim
@ 2013-01-17 16:05         ` Jiri Olsa
  0 siblings, 0 replies; 16+ messages in thread
From: Jiri Olsa @ 2013-01-17 16:05 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ulrich Drepper, Linux Kernel Mailing List,
	Arnaldo Carvalho de Melo, Corey Ashford, Frederic Weisbecker,
	Ingo Molnar, Paul Mackerras, Peter Zijlstra, Andi Kleen,
	David Ahern

On Thu, Jan 17, 2013 at 10:03:32AM +0900, Namhyung Kim wrote:
> Hi,
> 
> On Wed, 16 Jan 2013 10:12:14 -0500, Ulrich Drepper wrote:
> > On Wed, Jan 16, 2013 at 9:25 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> >> I was thinking having config files (global and arch specific)
> >> comming with perf having predefined formulas.
> >
> > All the more reason to not mention the file name or really any source
> > for the definition of the formula in the name,
> >
> >
> >> 1)  -e 'ratio/branch-rate/'  # special event class
> >> 2)  -e 'ratio-branch-rate'   # 'ratio-' prefix
> >> 3)  -e cpu/branch-rate/      # handled like aliases, ratio name would need to be unique
> >>   ... ?
> >
> > I think 3 is the most extensible.  Perhaps use the syntax used in
> > other places.  We have these :u suffixes etc.  Perhaps have :r or :R
> > or whatever.
> 
> I don't think it's a good idea.  The ':r' syntax is for modifiers to the
> existing events so it doesn't match to this case IMHO.
> 
> I prefer a special event class like 1 since it's possible to include
> non-cpu events to a ratio/formular.  In that case, using 'cpu' in the
> PMU name can be misleading.
> 
> >
> > Given the other comments, we might want to avoid right away "ratio".
> > If the mechanism is generalized it could be used to express "counter1
> > - counter2" for events which cannot be expressed with a single counter
> > but are not really ratios.
> 
> Agreed.  Looks like "formular" is better.

agreed, I think I wouldn't touch modifiers for this
also, 'ratio' is not good choice, formula seems better

jirka

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-17 10:23     ` Will Deacon
@ 2013-01-21 19:13       ` Jiri Olsa
  2013-01-22  9:45         ` Will Deacon
  0 siblings, 1 reply; 16+ messages in thread
From: Jiri Olsa @ 2013-01-21 19:13 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Namhyung Kim,
	Corey Ashford, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
	Peter Zijlstra

On Thu, Jan 17, 2013 at 10:23:26AM +0000, Will Deacon wrote:
> On Wed, Jan 16, 2013 at 01:30:33PM +0000, Jiri Olsa wrote:
> > On Wed, Jan 16, 2013 at 01:13:18PM +0000, Will Deacon wrote:
> > > On Tue, Jan 15, 2013 at 01:39:50PM +0000, Jiri Olsa wrote:
> > > > The formula can currently contain any event from the set::events
> > > > plus any number (int). There'll be support in future for outside
> > > > values runtime and other if needed.
> > > 
> > > Just to say that I *really* like this idea! If we extended it to include
> > > other operators then it would help us on ARM, where we often have events
> > > like 'cache accesses' and 'cache misses' but not 'cache hits'.
> > 
> > great, thanks for sharing this
> > 
> > The current operators set is just basic one to show the idea,
> > it can/will be expanded.
> 
> Makes sense.

any particular operators you'd like to see in?

jirka

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC 0/4] perf tool: Adding ratios support
  2013-01-21 19:13       ` Jiri Olsa
@ 2013-01-22  9:45         ` Will Deacon
  0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2013-01-22  9:45 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Namhyung Kim,
	Corey Ashford, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
	Peter Zijlstra

On Mon, Jan 21, 2013 at 07:13:25PM +0000, Jiri Olsa wrote:
> On Thu, Jan 17, 2013 at 10:23:26AM +0000, Will Deacon wrote:
> > On Wed, Jan 16, 2013 at 01:30:33PM +0000, Jiri Olsa wrote:
> > > On Wed, Jan 16, 2013 at 01:13:18PM +0000, Will Deacon wrote:
> > > > On Tue, Jan 15, 2013 at 01:39:50PM +0000, Jiri Olsa wrote:
> > > > > The formula can currently contain any event from the set::events
> > > > > plus any number (int). There'll be support in future for outside
> > > > > values runtime and other if needed.
> > > > 
> > > > Just to say that I *really* like this idea! If we extended it to include
> > > > other operators then it would help us on ARM, where we often have events
> > > > like 'cache accesses' and 'cache misses' but not 'cache hits'.
> > > 
> > > great, thanks for sharing this
> > > 
> > > The current operators set is just basic one to show the idea,
> > > it can/will be expanded.
> > 
> > Makes sense.
> 
> any particular operators you'd like to see in?

I think the basic: add, subtract, divide operators are the most useful to
start with.

Cheers,

Will

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tip:perf/core] perf tools: Remove unused 'unset' parameter from parse_events
  2013-01-15 13:39 ` [PATCH 1/4] perf tool: Remove unused 'unset' parameter from parse_events Jiri Olsa
@ 2013-01-25 11:52   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Jiri Olsa @ 2013-01-25 11:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, andi, a.p.zijlstra,
	namhyung, jolsa, drepper, fweisbec, dsahern, tglx, cjashfor,
	mingo

Commit-ID:  d8f7bbc947afb59c68a8574d1fe99b20cff2b1be
Gitweb:     http://git.kernel.org/tip/d8f7bbc947afb59c68a8574d1fe99b20cff2b1be
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Tue, 15 Jan 2013 14:39:51 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 24 Jan 2013 16:40:40 -0300

perf tools: Remove unused 'unset' parameter from parse_events

The 'unset' parameter is option callback leftover with no use, removing.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ulrich Drepper <drepper@gmail.com>
Link: http://lkml.kernel.org/r/1358257194-8204-2-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/evsel-roundtrip-name.c | 4 ++--
 tools/perf/tests/hists_link.c           | 4 ++--
 tools/perf/tests/parse-events.c         | 2 +-
 tools/perf/util/parse-events.c          | 5 ++---
 tools/perf/util/parse-events.h          | 3 +--
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index e61fc82..0fd99a9 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -22,7 +22,7 @@ static int perf_evsel__roundtrip_cache_name_test(void)
 			for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
 				__perf_evsel__hw_cache_type_op_res_name(type, op, i,
 									name, sizeof(name));
-				err = parse_events(evlist, name, 0);
+				err = parse_events(evlist, name);
 				if (err)
 					ret = err;
 			}
@@ -70,7 +70,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names)
                 return -ENOMEM;
 
 	for (i = 0; i < nr_names; ++i) {
-		err = parse_events(evlist, names[i], 0);
+		err = parse_events(evlist, names[i]);
 		if (err) {
 			pr_debug("failed to parse event '%s', err %d\n",
 				 names[i], err);
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 27860a0..0afd922 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -441,10 +441,10 @@ int test__hists_link(void)
 	if (evlist == NULL)
                 return -ENOMEM;
 
-	err = parse_events(evlist, "cpu-clock", 0);
+	err = parse_events(evlist, "cpu-clock");
 	if (err)
 		goto out;
-	err = parse_events(evlist, "task-clock", 0);
+	err = parse_events(evlist, "task-clock");
 	if (err)
 		goto out;
 
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index e7eb708..337424d 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1018,7 +1018,7 @@ static int test_event(struct test__event_st *e)
 	if (evlist == NULL)
 		return -ENOMEM;
 
-	ret = parse_events(evlist, e->name, 0);
+	ret = parse_events(evlist, e->name);
 	if (ret) {
 		pr_debug("failed to parse event '%s', err %d\n",
 			 e->name, ret);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 626c120..d3bf570 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -872,8 +872,7 @@ int parse_events_terms(struct list_head *terms, const char *str)
 	return ret;
 }
 
-int parse_events(struct perf_evlist *evlist, const char *str,
-		 int unset __maybe_unused)
+int parse_events(struct perf_evlist *evlist, const char *str)
 {
 	struct parse_events_data__events data = {
 		.list = LIST_HEAD_INIT(data.list),
@@ -900,7 +899,7 @@ int parse_events_option(const struct option *opt, const char *str,
 			int unset __maybe_unused)
 {
 	struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
-	int ret = parse_events(evlist, str, unset);
+	int ret = parse_events(evlist, str);
 
 	if (ret) {
 		fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index b7af80b..7c5244f 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -29,8 +29,7 @@ const char *event_type(int type);
 
 extern int parse_events_option(const struct option *opt, const char *str,
 			       int unset);
-extern int parse_events(struct perf_evlist *evlist, const char *str,
-			int unset);
+extern int parse_events(struct perf_evlist *evlist, const char *str);
 extern int parse_events_terms(struct list_head *terms, const char *str);
 extern int parse_filter(const struct option *opt, const char *str, int unset);
 

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-01-25 11:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-15 13:39 [RFC 0/4] perf tool: Adding ratios support Jiri Olsa
2013-01-15 13:39 ` [PATCH 1/4] perf tool: Remove unused 'unset' parameter from parse_events Jiri Olsa
2013-01-25 11:52   ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
2013-01-15 13:39 ` [PATCH 2/4] perf tool: Add formula interface to interface ratio definitions Jiri Olsa
2013-01-15 13:39 ` [PATCH 3/4] perf stat: Adding -f option to load and process ratios Jiri Olsa
2013-01-15 13:39 ` [PATCH 4/4] perf tool: Adding formula.conf file for testing Jiri Olsa
2013-01-16 13:13 ` [RFC 0/4] perf tool: Adding ratios support Will Deacon
2013-01-16 13:30   ` Jiri Olsa
2013-01-17 10:23     ` Will Deacon
2013-01-21 19:13       ` Jiri Olsa
2013-01-22  9:45         ` Will Deacon
2013-01-16 14:00 ` Ulrich Drepper
2013-01-16 14:25   ` Jiri Olsa
2013-01-16 15:12     ` Ulrich Drepper
2013-01-17  1:03       ` Namhyung Kim
2013-01-17 16:05         ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome