|
@@ -159,6 +159,7 @@ struct stats runtime_cycles_stats[MAX_NR_CPUS];
|
|
|
struct stats runtime_stalled_cycles_stats[MAX_NR_CPUS];
|
|
|
struct stats runtime_branches_stats[MAX_NR_CPUS];
|
|
|
struct stats runtime_cacherefs_stats[MAX_NR_CPUS];
|
|
|
+struct stats runtime_l1_dcache_stats[MAX_NR_CPUS];
|
|
|
struct stats walltime_nsecs_stats;
|
|
|
|
|
|
static int create_perf_stat_counter(struct perf_evsel *evsel)
|
|
@@ -211,6 +212,8 @@ static void update_shadow_stats(struct perf_evsel *counter, u64 *count)
|
|
|
update_stats(&runtime_branches_stats[0], count[0]);
|
|
|
else if (perf_evsel__match(counter, HARDWARE, HW_CACHE_REFERENCES))
|
|
|
update_stats(&runtime_cacherefs_stats[0], count[0]);
|
|
|
+ else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_L1D))
|
|
|
+ update_stats(&runtime_l1_dcache_stats[0], count[0]);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -473,6 +476,29 @@ static void print_branch_misses(int cpu, struct perf_evsel *evsel __used, double
|
|
|
fprintf(stderr, " of all branches ");
|
|
|
}
|
|
|
|
|
|
+static void print_l1_dcache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
|
|
|
+{
|
|
|
+ double total, ratio = 0.0;
|
|
|
+ const char *color;
|
|
|
+
|
|
|
+ total = avg_stats(&runtime_l1_dcache_stats[cpu]);
|
|
|
+
|
|
|
+ if (total)
|
|
|
+ ratio = avg / total * 100.0;
|
|
|
+
|
|
|
+ color = PERF_COLOR_NORMAL;
|
|
|
+ if (ratio > 20.0)
|
|
|
+ color = PERF_COLOR_RED;
|
|
|
+ else if (ratio > 10.0)
|
|
|
+ color = PERF_COLOR_MAGENTA;
|
|
|
+ else if (ratio > 5.0)
|
|
|
+ color = PERF_COLOR_YELLOW;
|
|
|
+
|
|
|
+ fprintf(stderr, " # ");
|
|
|
+ color_fprintf(stderr, color, "%5.2f%%", ratio);
|
|
|
+ fprintf(stderr, " of all L1-dcache hits ");
|
|
|
+}
|
|
|
+
|
|
|
static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
|
|
|
{
|
|
|
double total, ratio = 0.0;
|
|
@@ -519,6 +545,13 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
|
|
|
} else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) &&
|
|
|
runtime_branches_stats[cpu].n != 0) {
|
|
|
print_branch_misses(cpu, evsel, avg);
|
|
|
+ } else if (
|
|
|
+ evsel->attr.type == PERF_TYPE_HW_CACHE &&
|
|
|
+ evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1D |
|
|
|
+ ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
|
|
|
+ ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
|
|
|
+ runtime_branches_stats[cpu].n != 0) {
|
|
|
+ print_l1_dcache_misses(cpu, evsel, avg);
|
|
|
} else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES) &&
|
|
|
runtime_cacherefs_stats[cpu].n != 0) {
|
|
|
total = avg_stats(&runtime_cacherefs_stats[cpu]);
|