[PATCH 12/28] perf tools: Save callchain info for each cumulative entry

2014-01-08 Thread Namhyung Kim
When accumulating callchain entry, also save current snapshot of the
chain so that it can show the rest of the chain.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 087d01cac1aa..5f07da10f83c 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -363,7 +363,6 @@ static int
 iter_prepare_cumulative_entry(struct hist_entry_iter *iter __maybe_unused,
  struct addr_location *al __maybe_unused)
 {
-   struct callchain_cursor_node *node;
struct hist_entry **he_cache;
 
callchain_cursor_commit(_cursor);
@@ -380,10 +379,6 @@ iter_prepare_cumulative_entry(struct hist_entry_iter *iter 
__maybe_unused,
iter->priv = he_cache;
iter->curr = 0;
 
-   node = callchain_cursor_current(_cursor);
-   if (node == NULL)
-   return 0;
-
return 0;
 }
 
@@ -404,6 +399,14 @@ iter_add_single_cumulative_entry(struct hist_entry_iter 
*iter,
 
he_cache[iter->curr++] = he;
 
+   callchain_append(he->callchain, _cursor, sample->period);
+
+   /*
+* We need to re-initialize the cursor since callchain_append()
+* advanced the cursor to the end.
+*/
+   callchain_cursor_commit(_cursor);
+
return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
 }
 
@@ -453,7 +456,6 @@ iter_next_cumulative_entry(struct hist_entry_iter *iter,
}
 
 out:
-   callchain_cursor_advance(_cursor);
return 1;
 }
 
@@ -477,6 +479,11 @@ iter_add_next_cumulative_entry(struct hist_entry_iter 
*iter,
.parent = iter->parent,
};
int i;
+   struct callchain_cursor cursor;
+
+   callchain_cursor_snapshot(, _cursor);
+
+   callchain_cursor_advance(_cursor);
 
/*
 * Check if there's duplicate entries in the callchain.
@@ -495,6 +502,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
 
he_cache[iter->curr++] = he;
 
+   callchain_append(he->callchain, , sample->period);
+
return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
 }
 
-- 
1.7.11.7

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


[PATCH 12/28] perf tools: Save callchain info for each cumulative entry

2014-01-08 Thread Namhyung Kim
When accumulating callchain entry, also save current snapshot of the
chain so that it can show the rest of the chain.

Cc: Arun Sharma asha...@fb.com
Cc: Frederic Weisbecker fweis...@gmail.com
Signed-off-by: Namhyung Kim namhy...@kernel.org
---
 tools/perf/builtin-report.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 087d01cac1aa..5f07da10f83c 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -363,7 +363,6 @@ static int
 iter_prepare_cumulative_entry(struct hist_entry_iter *iter __maybe_unused,
  struct addr_location *al __maybe_unused)
 {
-   struct callchain_cursor_node *node;
struct hist_entry **he_cache;
 
callchain_cursor_commit(callchain_cursor);
@@ -380,10 +379,6 @@ iter_prepare_cumulative_entry(struct hist_entry_iter *iter 
__maybe_unused,
iter-priv = he_cache;
iter-curr = 0;
 
-   node = callchain_cursor_current(callchain_cursor);
-   if (node == NULL)
-   return 0;
-
return 0;
 }
 
@@ -404,6 +399,14 @@ iter_add_single_cumulative_entry(struct hist_entry_iter 
*iter,
 
he_cache[iter-curr++] = he;
 
+   callchain_append(he-callchain, callchain_cursor, sample-period);
+
+   /*
+* We need to re-initialize the cursor since callchain_append()
+* advanced the cursor to the end.
+*/
+   callchain_cursor_commit(callchain_cursor);
+
return hist_entry__inc_addr_samples(he, evsel-idx, al-addr);
 }
 
@@ -453,7 +456,6 @@ iter_next_cumulative_entry(struct hist_entry_iter *iter,
}
 
 out:
-   callchain_cursor_advance(callchain_cursor);
return 1;
 }
 
@@ -477,6 +479,11 @@ iter_add_next_cumulative_entry(struct hist_entry_iter 
*iter,
.parent = iter-parent,
};
int i;
+   struct callchain_cursor cursor;
+
+   callchain_cursor_snapshot(cursor, callchain_cursor);
+
+   callchain_cursor_advance(callchain_cursor);
 
/*
 * Check if there's duplicate entries in the callchain.
@@ -495,6 +502,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
 
he_cache[iter-curr++] = he;
 
+   callchain_append(he-callchain, cursor, sample-period);
+
return hist_entry__inc_addr_samples(he, evsel-idx, al-addr);
 }
 
-- 
1.7.11.7

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