perf stat: Update or print per-thread stats
authorJin Yao <yao.jin@linux.intel.com>
Tue, 5 Dec 2017 14:03:08 +0000 (22:03 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 27 Dec 2017 15:15:46 +0000 (12:15 -0300)
If the stats pointer in stat_config structure is not null, it will
update the per-thread stats or print the per-thread stats on this
buffer.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1512482591-4646-9-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c
tools/perf/util/stat.c

index 4c492ac3ac07171b8d3f41d01cee2018b2a3641d..f4129a5fbb01ba2281245def0a97ca6929fcab21 100644 (file)
@@ -1372,8 +1372,13 @@ static void print_aggr_thread(struct perf_evsel *counter, char *prefix)
                        fprintf(output, "%s", prefix);
 
                uval = val * counter->scale;
-               printout(thread, 0, counter, uval, prefix, run, ena, 1.0,
-                        &rt_stat);
+
+               if (stat_config.stats)
+                       printout(thread, 0, counter, uval, prefix, run, ena,
+                                1.0, &stat_config.stats[thread]);
+               else
+                       printout(thread, 0, counter, uval, prefix, run, ena,
+                                1.0, &rt_stat);
                fputc('\n', output);
        }
 }
index 78abfd40b135cf1c22f28f33e867aac3a2bcd40b..32235657c1ac5699bc75c946495157a8270d609e 100644 (file)
@@ -280,9 +280,14 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel
                if (config->aggr_mode == AGGR_NONE)
                        perf_stat__update_shadow_stats(evsel, count->val, cpu,
                                                       &rt_stat);
-               if (config->aggr_mode == AGGR_THREAD)
-                       perf_stat__update_shadow_stats(evsel, count->val, 0,
-                                                      &rt_stat);
+               if (config->aggr_mode == AGGR_THREAD) {
+                       if (config->stats)
+                               perf_stat__update_shadow_stats(evsel,
+                                       count->val, 0, &config->stats[thread]);
+                       else
+                               perf_stat__update_shadow_stats(evsel,
+                                       count->val, 0, &rt_stat);
+               }
                break;
        case AGGR_GLOBAL:
                aggr->val += count->val;