[PATCH 12/40] perf tools: Use thread__comm_by_time() when adding hist entries

From: Namhyung Kim
Date: Sun May 17 2015 - 20:41:50 EST


Now thread->comm can be handled with time properly, use it to find
correct comm when adding hist entries.

Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/builtin-annotate.c | 5 +++--
tools/perf/builtin-diff.c | 8 ++++----
tools/perf/tests/hists_link.c | 4 ++--
tools/perf/util/hist.c | 19 ++++++++++---------
tools/perf/util/hist.h | 2 +-
5 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index b57a027fb200..761f902473b7 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -47,7 +47,7 @@ struct perf_annotate {
};

static int perf_evsel__add_sample(struct perf_evsel *evsel,
- struct perf_sample *sample __maybe_unused,
+ struct perf_sample *sample,
struct addr_location *al,
struct perf_annotate *ann)
{
@@ -67,7 +67,8 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return 0;
}

- he = __hists__add_entry(hists, al, NULL, NULL, NULL, 1, 1, 0, true);
+ he = __hists__add_entry(hists, al, NULL, NULL, NULL, 1, 1, 0,
+ sample->time, true);
if (he == NULL)
return -ENOMEM;

diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index daaa7dca9c3b..0fe54a633a5e 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -312,10 +312,10 @@ static int formula_fprintf(struct hist_entry *he, struct hist_entry *pair,

static int hists__add_entry(struct hists *hists,
struct addr_location *al, u64 period,
- u64 weight, u64 transaction)
+ u64 weight, u64 transaction, u64 timestamp)
{
if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight,
- transaction, true) != NULL)
+ transaction, timestamp, true) != NULL)
return 0;
return -ENOMEM;
}
@@ -336,8 +336,8 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
return -1;
}

- if (hists__add_entry(hists, &al, sample->period,
- sample->weight, sample->transaction)) {
+ if (hists__add_entry(hists, &al, sample->period, sample->weight,
+ sample->transaction, sample->time)) {
pr_warning("problem incrementing symbol period, skipping event\n");
goto out_put;
}
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 8c102b011424..27bae90c9a95 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -90,7 +90,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
goto out;

he = __hists__add_entry(hists, &al, NULL,
- NULL, NULL, 1, 1, 0, true);
+ NULL, NULL, 1, 1, 0, -1, true);
if (he == NULL) {
addr_location__put(&al);
goto out;
@@ -116,7 +116,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
goto out;

he = __hists__add_entry(hists, &al, NULL,
- NULL, NULL, 1, 1, 0, true);
+ NULL, NULL, 1, 1, 0, -1, true);
if (he == NULL) {
addr_location__put(&al);
goto out;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 338770679863..f13993e53e4e 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -442,11 +442,11 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
struct branch_info *bi,
struct mem_info *mi,
u64 period, u64 weight, u64 transaction,
- bool sample_self)
+ u64 timestamp, bool sample_self)
{
struct hist_entry entry = {
.thread = al->thread,
- .comm = thread__comm(al->thread),
+ .comm = thread__comm_by_time(al->thread, timestamp),
.ms = {
.map = al->map,
.sym = al->sym,
@@ -504,13 +504,14 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, struct addr_location *al
{
u64 cost;
struct mem_info *mi = iter->priv;
+ struct perf_sample *sample = iter->sample;
struct hists *hists = evsel__hists(iter->evsel);
struct hist_entry *he;

if (mi == NULL)
return -EINVAL;

- cost = iter->sample->weight;
+ cost = sample->weight;
if (!cost)
cost = 1;

@@ -522,7 +523,7 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, struct addr_location *al
* and the he_stat__add_period() function.
*/
he = __hists__add_entry(hists, al, iter->parent, NULL, mi,
- cost, cost, 0, true);
+ cost, cost, 0, sample->time, true);
if (!he)
return -ENOMEM;

@@ -623,7 +624,7 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *a
* and not events sampled. Thus we use a pseudo period of 1.
*/
he = __hists__add_entry(hists, al, iter->parent, &bi[i], NULL,
- 1, 1, 0, true);
+ 1, 1, 0, iter->sample->time, true);
if (he == NULL)
return -ENOMEM;

@@ -661,7 +662,7 @@ iter_add_single_normal_entry(struct hist_entry_iter *iter, struct addr_location

he = __hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL,
sample->period, sample->weight,
- sample->transaction, true);
+ sample->transaction, sample->time, true);
if (he == NULL)
return -ENOMEM;

@@ -723,7 +724,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter *iter,

he = __hists__add_entry(hists, al, iter->parent, NULL, NULL,
sample->period, sample->weight,
- sample->transaction, true);
+ sample->transaction, sample->time, true);
if (he == NULL)
return -ENOMEM;

@@ -767,7 +768,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
struct hist_entry he_tmp = {
.cpu = al->cpu,
.thread = al->thread,
- .comm = thread__comm(al->thread),
+ .comm = thread__comm_by_time(al->thread, sample->time),
.ip = al->addr,
.ms = {
.map = al->map,
@@ -796,7 +797,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,

he = __hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL,
sample->period, sample->weight,
- sample->transaction, false);
+ sample->transaction, sample->time, false);
if (he == NULL)
return -ENOMEM;

diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 9f31b89a527a..43ffe62e25d2 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -109,7 +109,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
struct branch_info *bi,
struct mem_info *mi, u64 period,
u64 weight, u64 transaction,
- bool sample_self);
+ u64 timestamp, bool sample_self);
int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al,
struct perf_evsel *evsel, struct perf_sample *sample,
int max_stack_depth, void *arg);
--
2.4.0

--
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/