[PATCH/RFC 07/16] perf hists: Pass hists struct to hist_entry_iter struct

From: Namhyung Kim
Date: Thu Dec 10 2015 - 02:54:45 EST


This is a preparation for multi-thread support in perf tools. When
multi-thread is enable, each thread will have its own hists during the
sample processing.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/builtin-report.c | 1 +
tools/perf/builtin-top.c | 1 +
tools/perf/tests/hists_cumulate.c | 1 +
tools/perf/tests/hists_filter.c | 1 +
tools/perf/tests/hists_output.c | 1 +
tools/perf/util/hist.c | 22 ++++++++--------------
tools/perf/util/hist.h | 1 +
7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index af5db885ea9c..c681064f2e18 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -144,6 +144,7 @@ static int process_sample_event(struct perf_tool *tool,
struct addr_location al;
struct hist_entry_iter iter = {
.evsel = evsel,
+ .hists = evsel__hists(evsel),
.sample = sample,
.hide_unresolved = symbol_conf.hide_unresolved,
.add_entry_cb = hist_iter__report_callback,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 24a5434e8a0b..b62665ce5ea6 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -893,6 +893,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
struct hists *hists = evsel__hists(evsel);
struct hist_entry_iter iter = {
.evsel = evsel,
+ .hists = evsel__hists(evsel),
.sample = sample,
.add_entry_cb = hist_iter__top_callback,
};
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index 8292948bc5f9..fd0d5d955612 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -88,6 +88,7 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)
};
struct hist_entry_iter iter = {
.evsel = evsel,
+ .hists = evsel__hists(evsel),
.sample = &sample,
.hide_unresolved = false,
};
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index ccb5b4921f25..c57ed8755e34 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -65,6 +65,7 @@ static int add_hist_entries(struct perf_evlist *evlist,
};
struct hist_entry_iter iter = {
.evsel = evsel,
+ .hists = evsel__hists(evsel),
.sample = &sample,
.ops = &hist_iter_normal,
.hide_unresolved = false,
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index 248beec1d917..86e9d374cd7f 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -58,6 +58,7 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)
};
struct hist_entry_iter iter = {
.evsel = evsel,
+ .hists = evsel__hists(evsel),
.sample = &sample,
.ops = &hist_iter_normal,
.hide_unresolved = false,
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 56e97f5af598..d534ed76164b 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -525,7 +525,7 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, struct addr_location *al
{
u64 cost;
struct mem_info *mi = iter->priv;
- struct hists *hists = evsel__hists(iter->evsel);
+ struct hists *hists = iter->hists;
struct hist_entry *he;

if (mi == NULL)
@@ -555,8 +555,7 @@ static int
iter_finish_mem_entry(struct hist_entry_iter *iter,
struct addr_location *al __maybe_unused)
{
- struct perf_evsel *evsel = iter->evsel;
- struct hists *hists = evsel__hists(evsel);
+ struct hists *hists = iter->hists;
struct hist_entry *he = iter->he;
int err = -EINVAL;

@@ -628,8 +627,7 @@ static int
iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *al)
{
struct branch_info *bi;
- struct perf_evsel *evsel = iter->evsel;
- struct hists *hists = evsel__hists(evsel);
+ struct hists *hists = iter->hists;
struct hist_entry *he = NULL;
int i = iter->curr;
int err = 0;
@@ -677,11 +675,10 @@ iter_prepare_normal_entry(struct hist_entry_iter *iter __maybe_unused,
static int
iter_add_single_normal_entry(struct hist_entry_iter *iter, struct addr_location *al)
{
- struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
struct hist_entry *he;

- he = __hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL,
+ he = __hists__add_entry(iter->hists, al, iter->parent, NULL, NULL,
sample->period, sample->weight,
sample->transaction, true);
if (he == NULL)
@@ -696,7 +693,6 @@ iter_finish_normal_entry(struct hist_entry_iter *iter,
struct addr_location *al __maybe_unused)
{
struct hist_entry *he = iter->he;
- struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;

if (he == NULL)
@@ -704,7 +700,7 @@ iter_finish_normal_entry(struct hist_entry_iter *iter,

iter->he = NULL;

- hists__inc_nr_samples(evsel__hists(evsel), he->filtered);
+ hists__inc_nr_samples(iter->hists, he->filtered);

return hist_entry__append_callchain(he, sample);
}
@@ -736,8 +732,7 @@ static int
iter_add_single_cumulative_entry(struct hist_entry_iter *iter,
struct addr_location *al)
{
- struct perf_evsel *evsel = iter->evsel;
- struct hists *hists = evsel__hists(evsel);
+ struct hists *hists = iter->hists;
struct perf_sample *sample = iter->sample;
struct hist_entry **he_cache = iter->priv;
struct hist_entry *he;
@@ -782,12 +777,11 @@ static int
iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
struct addr_location *al)
{
- struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
struct hist_entry **he_cache = iter->priv;
struct hist_entry *he;
struct hist_entry he_tmp = {
- .hists = evsel__hists(evsel),
+ .hists = iter->hists,
.cpu = al->cpu,
.thread = al->thread,
.comm = thread__comm(al->thread),
@@ -817,7 +811,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
}
}

- he = __hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL,
+ he = __hists__add_entry(iter->hists, al, iter->parent, NULL, NULL,
sample->period, sample->weight,
sample->transaction, false);
if (he == NULL)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index a48a2078d288..47ae7e6b1de8 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -93,6 +93,7 @@ struct hist_entry_iter {
bool hide_unresolved;
int max_stack;

+ struct hists *hists;
struct perf_evsel *evsel;
struct perf_sample *sample;
struct hist_entry *he;
--
2.6.2

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