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

Cc: Frederic Weisbecker <fweis...@gmail.com>
Signed-off-by: Namhyung Kim <namhy...@kernel.org>
---
 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 2bf9b3fd9e61..3afb858eac6e 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)
 {
@@ -72,7 +72,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 0b180a885ba3..623ecc53c0c9 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 c346b331b892..10454197a508 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -447,11 +447,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,
@@ -510,13 +510,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;
 
@@ -528,7 +529,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;
 
@@ -630,7 +631,7 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, 
struct addr_location *a
         */
        he = __hists__add_entry(hists, al, iter->parent, &bi[i], NULL,
                                1, bi->flags.cycles ? bi->flags.cycles : 1,
-                               0, true);
+                               0, iter->sample->time, true);
        if (he == NULL)
                return -ENOMEM;
 
@@ -668,7 +669,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;
 
@@ -730,7 +731,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;
 
@@ -775,7 +776,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
                .hists = evsel__hists(evsel),
                .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,
@@ -804,7 +805,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 8c20a8f6b214..7fbb60857f26 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -115,7 +115,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,
                         int max_stack_depth, void *arg);
 
-- 
2.6.0

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

Reply via email to