Skip to contentSkip to conversation

perf/urgent fixes

GIT PULL In review Arnaldo Carvalho de Melo 4 participants 14 messages Mar 30, 2012 – Mar 31, 2012 perf events

lore
Share & tools
lore
#0 lore raw

Hi Ingo,

Please consider pulling.

But please test the bison/flex thing, it was a bit tricky to make it
work with/without O=, and also to make it work on at least RHEL6.2, Fedora 14 and Ubuntu 10.04 LTS.

I know that bison barfs on Fedora 8, but left the fix for later.

- Arnaldo

The following changes since commit b01c3a0010aabadf745f3e7fdb9cab682e0a28a2:

perf: Move mmap page data_head offset assertion out of header (2012-03-24 08:46:59 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf/urgent

for you to fetch changes up to 65f3e56e0c81d1f581c4bdef7646ae5a8d51f494:

perf tools: Remove auto-generated bison/flex files (2012-03-30 12:43:17 -0300)

----------------------------------------------------------------
perf/urgent Fixes

. Assorted fixes from David Miller

. Fix display of first level of callchains, from Frederic Weisbecker

. Remove auto-generated bison/flex files, from Ingo Molnar and me

. Add missing ref-cycles event back to event parser, from Namhyung Kim

. Ignore DWARF decl tags to properly resolve function name do address,
from Prashanth Nageshappa

. Fix bug in raw sample parsing bug introduced in the branch stack patches,
from Stephane Eranian

----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
perf annotate: Fix off by one symbol hist size allocation and hit accounting

David Miller (3):
perf symbols: Do not include libgen.h
perf symbols: Handle NULL dso in dso__name_len
perf annotate: addr2line wants addresses in same format as objdump

Frederic Weisbecker (1):
perf tools: Fix display of first level of callchains

Ingo Molnar (1):
perf tools: Remove auto-generated bison/flex files

Namhyung Kim (1):
perf tools: Add missing ref-cycles event back to event parser

Prashanth Nageshappa (1):
perf probe: Finder fails to resolve function name to address

Stephane Eranian (1):
perf tools: Fix bug in raw sample parsing

 tools/perf/Makefile                  |   47 +-
 tools/perf/util/annotate.c           |    8 +-
 tools/perf/util/evsel.c              |    2 +
 tools/perf/util/hist.c               |  157 ++-
 tools/perf/util/parse-events-bison.c | 1917 ----------------------------
 tools/perf/util/parse-events-bison.h |   81 --
 tools/perf/util/parse-events-flex.c  | 2272 ----------------------------------
 tools/perf/util/parse-events-flex.h  |  316 -----
 tools/perf/util/parse-events.l       |    1 +
 tools/perf/util/pmu-bison.c          | 1663 -------------------------
 tools/perf/util/pmu-bison.h          |   73 --
 tools/perf/util/pmu-flex.c           | 1821 ---------------------------
 tools/perf/util/pmu-flex.h           |  316 -----
 tools/perf/util/probe-finder.c       |    4 +-
 tools/perf/util/symbol.c             |    3 +-
 15 files changed, 135 insertions(+), 8546 deletions(-)
 delete mode 100644 tools/perf/util/parse-events-bison.c
 delete mode 100644 tools/perf/util/parse-events-bison.h
 delete mode 100644 tools/perf/util/parse-events-flex.c
 delete mode 100644 tools/perf/util/parse-events-flex.h
 delete mode 100644 tools/perf/util/pmu-bison.c
 delete mode 100644 tools/perf/util/pmu-bison.h
 delete mode 100644 tools/perf/util/pmu-flex.c
 delete mode 100644 tools/perf/util/pmu-flex.h
#1 lore raw

PATCH 1/9 perf tools: Fix display of first level of callchains

From: Frederic Weisbecker <[email protected]>

The callchain stdio mode display was written using a sorted by symbol report. In this mode we have only one callchain root per hist so we forgot to handle cases where we have multiple callchain root, as in per dso sorting for example.

Fix this by handling these roots like any other branch, with the hist as the parent.

Before:

     1.97%  libpthread-2.12.1.so
            |
            --- __libc_write
                create_worker
                bench_sched_messaging
                cmd_bench
                run_builtin
                main
                __libc_start_main

            |
            --- __libc_read
                create_worker
                bench_sched_messaging
                cmd_bench
                run_builtin
                main
                __libc_start_main

After:

     1.97%  libpthread-2.12.1.so
            |
            |--36.97%-- __libc_write
            |          create_worker
            |          bench_sched_messaging
            |          cmd_bench
            |          run_builtin
            |          main
            |          __libc_start_main
            |
            |--31.47%-- __libc_read
            |          create_worker
            |          bench_sched_messaging
            |          cmd_bench
            |          run_builtin
            |          main
            |          __libc_start_main
           ...

Single roots keep their entry without percentage because they have the same overhead than the hist they refer to. ie: 100% in fractal mode and the percentage of the hist in graph mode:

     0.00%  [k] reschedule_interrupt
            |
            --- default_idle
                amd_e400_idle
                cpu_idle
                start_secondary
---
 tools/perf/util/hist.c |  157 ++++++++++++++++++++++++++++--------------------
 1 file changed, 93 insertions(+), 64 deletions(-)
tools/perf/util/hist.c +93 -64
index c61235f..2ec4b60 100644
@@ -607,7 +607,7 @@ static void init_rem_hits(void)
 	rem_hits.ms.sym = rem_sq_bracket;
 }
 
-static size_t __callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
+static size_t __callchain__fprintf_graph(FILE *fp, struct rb_root *root,
 					 u64 total_samples, int depth,
 					 int depth_mask, int left_margin)
 {
@@ -615,21 +615,16 @@ static size_t __callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
 	struct callchain_node *child;
 	struct callchain_list *chain;
 	int new_depth_mask = depth_mask;
-	u64 new_total;
 	u64 remaining;
 	size_t ret = 0;
 	int i;
 	uint entries_printed = 0;
 
-	if (callchain_param.mode == CHAIN_GRAPH_REL)
-		new_total = self->children_hit;
-	else
-		new_total = total_samples;
-
-	remaining = new_total;
+	remaining = total_samples;
 
-	node = rb_first(&self->rb_root);
+	node = rb_first(root);
 	while (node) {
+		u64 new_total;
 		u64 cumul;
 
 		child = rb_entry(node, struct callchain_node, rb_node);
@@ -657,11 +652,17 @@ static size_t __callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
 		list_for_each_entry(chain, &child->val, list) {
 			ret += ipchain__fprintf_graph(fp, chain, depth,
 						      new_depth_mask, i++,
-						      new_total,
+						      total_samples,
 						      cumul,
 						      left_margin);
 		}
-		ret += __callchain__fprintf_graph(fp, child, new_total,
+
+		if (callchain_param.mode == CHAIN_GRAPH_REL)
+			new_total = child->children_hit;
+		else
+			new_total = total_samples;
+
+		ret += __callchain__fprintf_graph(fp, &child->rb_root, new_total,
 						  depth + 1,
 						  new_depth_mask | (1 << depth),
 						  left_margin);
@@ -671,61 +672,75 @@ static size_t __callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
 	}
 
 	if (callchain_param.mode == CHAIN_GRAPH_REL &&
-		remaining && remaining != new_total) {
+		remaining && remaining != total_samples) {
 
 		if (!rem_sq_bracket)
 			return ret;
 
 		new_depth_mask &= ~(1 << (depth - 1));
-
 		ret += ipchain__fprintf_graph(fp, &rem_hits, depth,
-					      new_depth_mask, 0, new_total,
+					      new_depth_mask, 0, total_samples,
 					      remaining, left_margin);
 	}
 
 	return ret;
 }
 
-static size_t callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
+static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
 				       u64 total_samples, int left_margin)
 {
+	struct callchain_node *cnode;
 	struct callchain_list *chain;
+	u32 entries_printed = 0;
 	bool printed = false;
+	struct rb_node *node;
 	int i = 0;
-	int ret = 0;
-	u32 entries_printed = 0;
-
-	list_for_each_entry(chain, &self->val, list) {
-		if (!i++ && sort__first_dimension == SORT_SYM)
-			continue;
-
-		if (!printed) {
-			ret += callchain__fprintf_left_margin(fp, left_margin);
-			ret += fprintf(fp, "|\n");
-			ret += callchain__fprintf_left_margin(fp, left_margin);
-			ret += fprintf(fp, "---");
-
-			left_margin += 3;
-			printed = true;
-		} else
-			ret += callchain__fprintf_left_margin(fp, left_margin);
+	int ret;
 
-		if (chain->ms.sym)
-			ret += fprintf(fp, " %s\n", chain->ms.sym->name);
-		else
-			ret += fprintf(fp, " %p\n", (void *)(long)chain->ip);
+	/*
+	 * If have one single callchain root, don't bother printing
+	 * its percentage (100 % in fractal mode and the same percentage
+	 * than the hist in graph mode). This also avoid one level of column.
+	 */
+	node = rb_first(root);
+	if (node && !rb_next(node)) {
+		cnode = rb_entry(node, struct callchain_node, rb_node);
+		list_for_each_entry(chain, &cnode->val, list) {
+			/*
+			 * If we sort by symbol, the first entry is the same than
+			 * the symbol. No need to print it otherwise it appears as
+			 * displayed twice.
+			 */
+			if (!i++ && sort__first_dimension == SORT_SYM)
+				continue;
+			if (!printed) {
+				ret += callchain__fprintf_left_margin(fp, left_margin);
+				ret += fprintf(fp, "|\n");
+				ret += callchain__fprintf_left_margin(fp, left_margin);
+				ret += fprintf(fp, "---");
+				left_margin += 3;
+				printed = true;
+			} else
+				ret += callchain__fprintf_left_margin(fp, left_margin);
+
+			if (chain->ms.sym)
+				ret += fprintf(fp, " %s\n", chain->ms.sym->name);
+			else
+				ret += fprintf(fp, " %p\n", (void *)(long)chain->ip);
 
-		if (++entries_printed == callchain_param.print_limit)
-			break;
+			if (++entries_printed == callchain_param.print_limit)
+				break;
+		}
+		root = &cnode->rb_root;
 	}
 
-	ret += __callchain__fprintf_graph(fp, self, total_samples, 1, 1, left_margin);
-
-	return ret;
+	return __callchain__fprintf_graph(fp, root, total_samples,
+					  1, 1, left_margin);
 }
 
-static size_t callchain__fprintf_flat(FILE *fp, struct callchain_node *self,
-				      u64 total_samples)
+static size_t __callchain__fprintf_flat(FILE *fp,
+					struct callchain_node *self,
+					u64 total_samples)
 {
 	struct callchain_list *chain;
 	size_t ret = 0;
@@ -733,7 +748,7 @@ static size_t callchain__fprintf_flat(FILE *fp, struct callchain_node *self,
 	if (!self)
 		return 0;
 
-	ret += callchain__fprintf_flat(fp, self->parent, total_samples);
+	ret += __callchain__fprintf_flat(fp, self->parent, total_samples);
 
 
 	list_for_each_entry(chain, &self->val, list) {
@@ -749,44 +764,58 @@ static size_t callchain__fprintf_flat(FILE *fp, struct callchain_node *self,
 	return ret;
 }
 
-static size_t hist_entry_callchain__fprintf(struct hist_entry *he,
-					    u64 total_samples, int left_margin,
-					    FILE *fp)
+static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *self,
+				      u64 total_samples)
 {
-	struct rb_node *rb_node;
-	struct callchain_node *chain;
 	size_t ret = 0;
 	u32 entries_printed = 0;
+	struct rb_node *rb_node;
+	struct callchain_node *chain;
 
-	rb_node = rb_first(&he->sorted_chain);
+	rb_node = rb_first(self);
 	while (rb_node) {
 		double percent;
 
 		chain = rb_entry(rb_node, struct callchain_node, rb_node);
 		percent = chain->hit * 100.0 / total_samples;
-		switch (callchain_param.mode) {
-		case CHAIN_FLAT:
-			ret += percent_color_fprintf(fp, "           %6.2f%%\n",
-						     percent);
-			ret += callchain__fprintf_flat(fp, chain, total_samples);
-			break;
-		case CHAIN_GRAPH_ABS: /* Falldown */
-		case CHAIN_GRAPH_REL:
-			ret += callchain__fprintf_graph(fp, chain, total_samples,
-							left_margin);
-		case CHAIN_NONE:
-		default:
-			break;
-		}
+
+		ret = percent_color_fprintf(fp, "           %6.2f%%\n", percent);
+		ret += __callchain__fprintf_flat(fp, chain, total_samples);
 		ret += fprintf(fp, "\n");
 		if (++entries_printed == callchain_param.print_limit)
 			break;
+
 		rb_node = rb_next(rb_node);
 	}
 
 	return ret;
 }
 
+static size_t hist_entry_callchain__fprintf(struct hist_entry *he,
+					    u64 total_samples, int left_margin,
+					    FILE *fp)
+{
+	switch (callchain_param.mode) {
+	case CHAIN_GRAPH_REL:
+		return callchain__fprintf_graph(fp, &he->sorted_chain, he->period,
+						left_margin);
+		break;
+	case CHAIN_GRAPH_ABS:
+		return callchain__fprintf_graph(fp, &he->sorted_chain, total_samples,
+						left_margin);
+		break;
+	case CHAIN_FLAT:
+		return callchain__fprintf_flat(fp, &he->sorted_chain, total_samples);
+		break;
+	case CHAIN_NONE:
+		break;
+	default:
+		pr_err("Bad callchain mode\n");
+	}
+
+	return 0;
+}
+
 void hists__output_recalc_col_len(struct hists *hists, int max_rows)
 {
 	struct rb_node *next = rb_first(&hists->entries);
Signature · 1 line
1.7.9.2.358.g22243
#2 lore raw

PATCH 2/9 perf tools: Fix bug in raw sample parsing

In reply to Arnaldo Carvalho de Melo

From: Stephane Eranian <[email protected]>

In perf_event__parse_sample(), the array variable was not incremented by the amount of data used by the raw_data.

That was okay until we added PERF_SAMPLE_BRANCH_STACK which depends on the array variable pointing to the beginning of the branch stack data.

But that was not the case if branch stack was combined with raw mode sampling. That led to bogus branch stack addresses and count.

The bug would show up with:

$ perf record -R -b foo

This patch fixes the problem by correctly moving the array pointer forward for RAW samples.

Cc David Ahern <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
[ committer note: Fix also later submitted by Jiri Olsa ]
---
 tools/perf/util/evsel.c |    2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/evsel.c +2 -0
index d9da62a..8c13dbc 100644
@@ -580,6 +580,8 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
 			return -EFAULT;
 
 		data->raw_data = (void *) pdata;
+
+		array = (void *)array + data->raw_size + sizeof(u32);
 	}
 
 	if (type & PERF_SAMPLE_BRANCH_STACK) {
Signature · 1 line
1.7.9.2.358.g22243
#3 lore raw

PATCH 3/9 perf symbols: Do not include libgen.h

In reply to Arnaldo Carvalho de Melo

From: David Miller <[email protected]>

That causes us to end up using the XPG version of basename which can modify it's argument.

---
 tools/perf/util/symbol.c |    1 -
 1 file changed, 1 deletion(-)
tools/perf/util/symbol.c +0 -1
index 5dd83c3..d9e995b 100644
@@ -1,6 +1,5 @@
 #include <dirent.h>
 #include <errno.h>
-#include <libgen.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
Signature · 1 line
1.7.9.2.358.g22243
#4 lore raw

PATCH 4/9 perf symbols: Handle NULL dso in dso__name_len

In reply to Arnaldo Carvalho de Melo

From: David Miller <[email protected]>

We should use "[unknown]" in this case, in concert with the code in _hist_entry__dso_snprintf().

Otherwise we'll crash when recomputing the histogram column lengths in hists__calc_col_len().

---
 tools/perf/util/symbol.c |    2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/symbol.c +2 -0
index d9e995b..c0a028c 100644
@@ -50,6 +50,8 @@ struct symbol_conf symbol_conf = {
 
 int dso__name_len(const struct dso *dso)
 {
+	if (!dso)
+		return strlen("[unknown]");
 	if (verbose)
 		return dso->long_name_len;
 
Signature · 1 line
1.7.9.2.358.g22243
#5 lore raw

PATCH 5/9 perf probe: Finder fails to resolve function name to address

In reply to Arnaldo Carvalho de Melo

From: Prashanth Nageshappa <[email protected]>

If DIE entries corresponding to declarations appear before definition entry, probe finder returns error instead of continuing to look further for a definition entry.

This patch ensures we reach to the DIE entry corresponding to the definition and get the function address.

V2: A simpler solution based on Masami's suggestion.

---
 tools/perf/util/probe-finder.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/probe-finder.c +3 -1
index 2cc162d..d448984 100644
@@ -972,10 +972,12 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data)
 	struct dwarf_callback_param *param = data;
 	struct probe_finder *pf = param->data;
 	struct perf_probe_point *pp = &pf->pev->point;
+	Dwarf_Attribute attr;
 
 	/* Check tag and diename */
 	if (dwarf_tag(sp_die) != DW_TAG_subprogram ||
-	    !die_compare_name(sp_die, pp->function))
+	    !die_compare_name(sp_die, pp->function) ||
+	    dwarf_attr(sp_die, DW_AT_declaration, &attr))
 		return DWARF_CB_OK;
 
 	/* Check declared file */
Signature · 1 line
1.7.9.2.358.g22243
#6 lore raw

PATCH 6/9 perf annotate: addr2line wants addresses in same format as objdump

In reply to Arnaldo Carvalho de Melo

From: David Miller <[email protected]>

Therefore, in symbol__get_source_line(), use map__rip_2objdump instead of calling map->unmap_ip() unconditionally.

---
 tools/perf/util/annotate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
index e5a462f..31ba2a2 100644
@@ -408,7 +408,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
 	if (!notes->src->lines)
 		return -1;
 
-	start = map->unmap_ip(map, sym->start);
+	start = map__rip_2objdump(map, sym->start);
 
 	for (i = 0; i < len; i++) {
 		char *path = NULL;
Signature · 1 line
1.7.9.2.358.g22243
#7 lore raw

PATCH 7/9 perf tools: Add missing ref-cycles event back to event parser

In reply to Arnaldo Carvalho de Melo

From: Namhyung Kim <[email protected]>

The commit 89812fc81f8d ("perf tools: Add parser generator for events parsing") changed event parsing engine but missed the ref-cycles event. Add it.

---
 tools/perf/util/parse-events.l |    1 +
 1 file changed, 1 insertion(+)
tools/perf/util/parse-events.l +1 -0
index ab9eca1..05d766e 100644
@@ -67,6 +67,7 @@ cache-misses					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); }
 branch-instructions|branches			{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); }
 branch-misses					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); }
 bus-cycles					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); }
+ref-cycles					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); }
 cpu-clock					{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); }
 task-clock					{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); }
 page-faults|faults				{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); }
Signature · 1 line
1.7.9.2.358.g22243
#8 lore raw

PATCH 8/9 perf annotate: Fix off by one symbol hist size allocation and hit accounting

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

We were not noticing it because symbol__inc_addr_samples was erroneously dropping samples that hit the last byte in a function.

Working on a fix for a problem reported by David Miller, Stephane Eranian and Sorin Dumitru, where addresses < sym->start were causing problems, I noticed this other problem.

Cc David Ahern <[email protected]>
Cc David Miller <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Sorin Dumitru <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/annotate.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/annotate.c +3 -3
index 31ba2a2..199f69e 100644
@@ -28,8 +28,8 @@ int symbol__annotate_init(struct map *map __used, struct symbol *sym)
 int symbol__alloc_hist(struct symbol *sym)
 {
 	struct annotation *notes = symbol__annotation(sym);
-	size_t sizeof_sym_hist = (sizeof(struct sym_hist) +
-				  (sym->end - sym->start) * sizeof(u64));
+	const size_t size = sym->end - sym->start + 1;
+	size_t sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64));
 
 	notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist);
 	if (notes->src == NULL)
@@ -64,7 +64,7 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
 
 	pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
 
-	if (addr >= sym->end)
+	if (addr > sym->end)
 		return 0;
 
 	offset = addr - sym->start;
Signature · 1 line
1.7.9.2.358.g22243
#9 lore raw

PATCH 9/9 perf tools: Remove auto-generated bison/flex files

In reply to Arnaldo Carvalho de Melo

From: Ingo Molnar <[email protected]>

These should not be in the Git history - they are auto-generated.

Extend the Makefile rules of the parser files to include the generation run.

Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
[ committer note: Fixed up O= handling ]
---
 tools/perf/Makefile                  |   47 +-
 tools/perf/util/parse-events-bison.c | 1917 ----------------------------
 tools/perf/util/parse-events-bison.h |   81 --
 tools/perf/util/parse-events-flex.c  | 2272 ----------------------------------
 tools/perf/util/parse-events-flex.h  |  316 -----
 tools/perf/util/pmu-bison.c          | 1663 -------------------------
 tools/perf/util/pmu-bison.h          |   73 --
 tools/perf/util/pmu-flex.c           | 1821 ---------------------------
 tools/perf/util/pmu-flex.h           |  316 -----
 9 files changed, 30 insertions(+), 8476 deletions(-)
 delete mode 100644 tools/perf/util/parse-events-bison.c
 delete mode 100644 tools/perf/util/parse-events-bison.h
 delete mode 100644 tools/perf/util/parse-events-flex.c
 delete mode 100644 tools/perf/util/parse-events-flex.h
 delete mode 100644 tools/perf/util/pmu-bison.c
 delete mode 100644 tools/perf/util/pmu-bison.h
 delete mode 100644 tools/perf/util/pmu-flex.c
 delete mode 100644 tools/perf/util/pmu-flex.h
tools/perf/Makefile +30 -17
index b492e3a..3e61c6f 100644
@@ -61,8 +61,6 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
 
 CC = $(CROSS_COMPILE)gcc
 AR = $(CROSS_COMPILE)ar
-FLEX = $(CROSS_COMPILE)flex
-BISON= $(CROSS_COMPILE)bison
 
 # Additional ARCH settings for x86
 ifeq ($(ARCH),i386)
@@ -184,7 +182,7 @@ endif
 
 ### --- END CONFIGURATION SECTION ---
 
-BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
+BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)/util -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
 BASIC_LDFLAGS =
 
 # Guard against environment variables
@@ -236,6 +234,25 @@ endif
 
 export PERL_PATH
 
+FLEX = $(CROSS_COMPILE)flex
+BISON= $(CROSS_COMPILE)bison
+
+event-parser:
+	$(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o $(OUTPUT)util/parse-events-bison.c
+	$(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
+
+$(OUTPUT)util/parse-events-flex.c: event-parser
+$(OUTPUT)util/parse-events-bison.c: event-parser
+
+pmu-parser:
+	$(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c
+	$(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c
+
+$(OUTPUT)util/pmu-flex.c: pmu-parser
+$(OUTPUT)util/pmu-bison.c: pmu-parser
+
+$(OUTPUT)util/parse-events.o: event-parser pmu-parser
+
 LIB_FILE=$(OUTPUT)libperf.a
 
 LIB_H += ../../include/linux/perf_event.h
@@ -754,6 +771,15 @@ $(OUTPUT)perf.o perf.spec \
 .SUFFIXES:
 .SUFFIXES: .o .c .S .s
 
+# These two need to be here so that when O= is not used they take precedence
+# over the general rule for .o
+
+$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Iutil/ -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $<
+
+$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -Iutil/ -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $<
+
 $(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
 $(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS
@@ -790,12 +816,6 @@ $(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
 $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
 
-$(OUTPUT)util/parse-events-flex.o: util/parse-events-flex.c $(OUTPUT)PERF-CFLAGS
-	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $<
-
-$(OUTPUT)util/pmu-flex.o: util/pmu-flex.c $(OUTPUT)PERF-CFLAGS
-	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $<
-
 $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
 
@@ -883,14 +903,6 @@ cscope:
 	$(RM) cscope*
 	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
 
-event-parser:
-	$(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o util/parse-events-bison.c
-	$(QUIET_FLEX)$(FLEX) --header-file=util/parse-events-flex.h -t util/parse-events.l > util/parse-events-flex.c
-
-pmu-parser:
-	$(QUIET_BISON)$(BISON) -v util/pmu.y -d -o util/pmu-bison.c
-	$(QUIET_FLEX)$(FLEX) --header-file=util/pmu-flex.h -t util/pmu.l > util/pmu-flex.c
-
 ### Detect prefix changes
 TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
              $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
@@ -978,6 +990,7 @@ clean:
 	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
 	$(MAKE) -C Documentation/ clean
 	$(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS
+	$(RM) $(OUTPUT)util/*-{bison,flex}*
 	$(python-clean)
 
 .PHONY: all install clean strip
tools/perf/util/parse-events-bison.c deleted +0 -1917

1,917 lines not on this page · raw message

tools/perf/util/parse-events-bison.h deleted +0 -81

81 lines not on this page · raw message

tools/perf/util/parse-events-flex.c deleted +0 -2272

913 lines not on this page · raw message

tools/perf/util/parse-events-flex.h deleted +0 -316

316 lines not on this page · raw message

tools/perf/util/pmu-bison.c deleted +0 -1663

1,663 lines not on this page · raw message

tools/perf/util/pmu-bison.h deleted +0 -73

73 lines not on this page · raw message

tools/perf/util/pmu-flex.c deleted +0 -1821

1,821 lines not on this page · raw message

tools/perf/util/pmu-flex.h deleted +0 -316

316 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.2.358.g22243

Part of the diff is not shown here. View the raw message.

#10 lore raw

Re: [PATCH 9/9] perf tools: Remove auto-generated bison/flex files

Hi,

Quoted 57 lines · Arnaldo Carvalho de Melo

From: Ingo Molnar <[email protected]>

These should not be in the Git history - they are auto-generated.

Extend the Makefile rules of the parser files to include the generation run.

Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
[ committer note: Fixed up O= handling ]
---
 tools/perf/Makefile                  |   47 +-
 tools/perf/util/parse-events-bison.c | 1917 ----------------------------
 tools/perf/util/parse-events-bison.h |   81 --
 tools/perf/util/parse-events-flex.c  | 2272 ----------------------------------
 tools/perf/util/parse-events-flex.h  |  316 -----
 tools/perf/util/pmu-bison.c          | 1663 -------------------------
 tools/perf/util/pmu-bison.h          |   73 --
 tools/perf/util/pmu-flex.c           | 1821 ---------------------------
 tools/perf/util/pmu-flex.h           |  316 -----
 9 files changed, 30 insertions(+), 8476 deletions(-)
 delete mode 100644 tools/perf/util/parse-events-bison.c
 delete mode 100644 tools/perf/util/parse-events-bison.h
 delete mode 100644 tools/perf/util/parse-events-flex.c
 delete mode 100644 tools/perf/util/parse-events-flex.h
 delete mode 100644 tools/perf/util/pmu-bison.c
 delete mode 100644 tools/perf/util/pmu-bison.h
 delete mode 100644 tools/perf/util/pmu-flex.c
 delete mode 100644 tools/perf/util/pmu-flex.h
tools/perf/Makefile +1 -3
index b492e3a..3e61c6f 100644
@@ -61,8 +61,6 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
 
 CC = $(CROSS_COMPILE)gcc
 AR = $(CROSS_COMPILE)ar
-FLEX = $(CROSS_COMPILE)flex
-BISON= $(CROSS_COMPILE)bison
 
 # Additional ARCH settings for x86
 ifeq ($(ARCH),i386)
@@ -184,7 +182,7 @@ endif
 
 ### --- END CONFIGURATION SECTION ---
 
-BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
+BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)/util -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
 BASIC_LDFLAGS =
 
 # Guard against environment variables

tools/perf/Makefile endif · line 238

Quoted 5 lines
tools/perf/Makefile +2 -0
@@ -236,6 +234,25 @@ endif
 
 export PERL_PATH
 
+FLEX = $(CROSS_COMPILE)flex
+BISON= $(CROSS_COMPILE)bison

Just out of curiousity, is this $(CROSS_COMPILE) prefix really needed for flex/bison?

Thanks,
Namhyung

#11 lore raw

Re: [PATCH 9/9] perf tools: Remove auto-generated bison/flex files

Quoted 11 lines · Namhyung Kim

Hi,

Quoted 8 lines · Arnaldo Carvalho de Melo

From: Ingo Molnar<[email protected]>

These should not be in the Git history - they are auto-generated.

Extend the Makefile rules of the parser files to include the generation run.

[...]

Quoted 7 lines

tools/perf/Makefile endif · line 238

Quoted 3 lines
tools/perf/Makefile +2 -0
+FLEX = $(CROSS_COMPILE)flex
+BISON= $(CROSS_COMPILE)bison

Just out of curiousity, is this $(CROSS_COMPILE) prefix really needed for flex/bison?

I think not. Actually, I think it is actively incorrect.

I have done quite a bit of cross building of things requiring either bison or flex, and have never encountered $(CROSS_COMPILE)bison, so I would think that it is unlikely that many people have one. On the other hand the native tools work fine.

David Daney

#12 lore raw

Re: [PATCH 9/9] perf tools: Remove auto-generated bison/flex files

In reply to Namhyung Kim

Em Sat, Mar 31, 2012 at 01:43:13AM +0900, Namhyung Kim escreveu:

Quoted 6 lines

tools/perf/Makefile endif · line 238

Quoted 2 lines · Arnaldo Carvalho de Melo
tools/perf/Makefile +2 -0
+FLEX = $(CROSS_COMPILE)flex
+BISON= $(CROSS_COMPILE)bison

Just out of curiousity, is this $(CROSS_COMPILE) prefix really needed for flex/bison?

Possibly no, I just left it there when making Ingo's patch to get rid of the pre-generated bison/flex files.

- Arnaldo

#13 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 83 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling.

But please test the bison/flex thing, it was a bit tricky to make it
work with/without O=, and also to make it work on at least RHEL6.2, Fedora 14 and Ubuntu 10.04 LTS.

I know that bison barfs on Fedora 8, but left the fix for later.

- Arnaldo

The following changes since commit b01c3a0010aabadf745f3e7fdb9cab682e0a28a2:

perf: Move mmap page data_head offset assertion out of header (2012-03-24 08:46:59 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf/urgent

for you to fetch changes up to 65f3e56e0c81d1f581c4bdef7646ae5a8d51f494:

perf tools: Remove auto-generated bison/flex files (2012-03-30 12:43:17 -0300)

----------------------------------------------------------------
perf/urgent Fixes

. Assorted fixes from David Miller

. Fix display of first level of callchains, from Frederic Weisbecker

. Remove auto-generated bison/flex files, from Ingo Molnar and me

. Add missing ref-cycles event back to event parser, from Namhyung Kim

. Ignore DWARF decl tags to properly resolve function name do address,
from Prashanth Nageshappa

. Fix bug in raw sample parsing bug introduced in the branch stack patches,
from Stephane Eranian

----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
perf annotate: Fix off by one symbol hist size allocation and hit accounting

David Miller (3):
perf symbols: Do not include libgen.h
perf symbols: Handle NULL dso in dso__name_len
perf annotate: addr2line wants addresses in same format as objdump

Frederic Weisbecker (1):
perf tools: Fix display of first level of callchains

Ingo Molnar (1):
perf tools: Remove auto-generated bison/flex files

Namhyung Kim (1):
perf tools: Add missing ref-cycles event back to event parser

Prashanth Nageshappa (1):
perf probe: Finder fails to resolve function name to address

Stephane Eranian (1):
perf tools: Fix bug in raw sample parsing

 tools/perf/Makefile                  |   47 +-
 tools/perf/util/annotate.c           |    8 +-
 tools/perf/util/evsel.c              |    2 +
 tools/perf/util/hist.c               |  157 ++-
 tools/perf/util/parse-events-bison.c | 1917 ----------------------------
 tools/perf/util/parse-events-bison.h |   81 --
 tools/perf/util/parse-events-flex.c  | 2272 ----------------------------------
 tools/perf/util/parse-events-flex.h  |  316 -----
 tools/perf/util/parse-events.l       |    1 +
 tools/perf/util/pmu-bison.c          | 1663 -------------------------
 tools/perf/util/pmu-bison.h          |   73 --
 tools/perf/util/pmu-flex.c           | 1821 ---------------------------
 tools/perf/util/pmu-flex.h           |  316 -----
 tools/perf/util/probe-finder.c       |    4 +-
 tools/perf/util/symbol.c             |    3 +-
 15 files changed, 135 insertions(+), 8546 deletions(-)
Quoted 8 lines
 delete mode 100644 tools/perf/util/parse-events-bison.c
 delete mode 100644 tools/perf/util/parse-events-bison.h
 delete mode 100644 tools/perf/util/parse-events-flex.c
 delete mode 100644 tools/perf/util/parse-events-flex.h
 delete mode 100644 tools/perf/util/pmu-bison.c
 delete mode 100644 tools/perf/util/pmu-bison.h
 delete mode 100644 tools/perf/util/pmu-flex.c
 delete mode 100644 tools/perf/util/pmu-flex.h

Pulled, thanks a lot Arnaldo!

It's working fine on all my test-boxes.

Thanks,

Ingo