Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dcd9936a authored by Ingo Molnar's avatar Ingo Molnar
Browse files

perf stat: Factor our shadow stats



Create update_shadow_stats() which is then used in both read_counter_aggr()
and read_counter().

This not only simplifies the code but also fixes a bug: HW_CACHE_REFERENCES
was not updated in read_counter().

Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/n/tip-9uc55z3g88r47exde7zxjm6p@git.kernel.org


Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 749141d9
Loading
Loading
Loading
Loading
+19 −14
Original line number Original line Diff line number Diff line
@@ -193,6 +193,23 @@ static inline int nsec_counter(struct perf_evsel *evsel)
	return 0;
	return 0;
}
}


/*
 * Update various tracking values we maintain to print
 * more semantic information such as miss/hit ratios,
 * instruction rates, etc:
 */
static void update_shadow_stats(struct perf_evsel *counter, u64 *count)
{
	if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK))
		update_stats(&runtime_nsecs_stats[0], count[0]);
	else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
		update_stats(&runtime_cycles_stats[0], count[0]);
	else if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS))
		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]);
}

/*
/*
 * Read out the results of a single counter:
 * Read out the results of a single counter:
 * aggregate counts across CPUs in system-wide mode
 * aggregate counts across CPUs in system-wide mode
@@ -218,14 +235,7 @@ static int read_counter_aggr(struct perf_evsel *counter)
	/*
	/*
	 * Save the full runtime - to allow normalization during printout:
	 * Save the full runtime - to allow normalization during printout:
	 */
	 */
	if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK))
	update_shadow_stats(counter, count);
		update_stats(&runtime_nsecs_stats[0], count[0]);
	else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
		update_stats(&runtime_cycles_stats[0], count[0]);
	else if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS))
		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]);


	return 0;
	return 0;
}
}
@@ -245,12 +255,7 @@ static int read_counter(struct perf_evsel *counter)


		count = counter->counts->cpu[cpu].values;
		count = counter->counts->cpu[cpu].values;


		if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK))
		update_shadow_stats(counter, count);
			update_stats(&runtime_nsecs_stats[cpu], count[0]);
		if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
			update_stats(&runtime_cycles_stats[cpu], count[0]);
		if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS))
			update_stats(&runtime_branches_stats[cpu], count[0]);
	}
	}


	return 0;
	return 0;