[PATCH 0/4] coresight: Add ETR-PERF polling.

Leo Yan leo.yan at linaro.org
Sun May 23 01:45:52 PDT 2021


On Fri, May 14, 2021 at 02:02:25AM -0700, Denis Nikitin wrote:

[...]

> We could probably utilize the ETM strobing feature and reduce frequency
> of data collection but I see a problem when I'm using both.
> Within a minute of profiling the ETM generates a reasonable profile size
> (with strobing autofdo,preset=9 with period 0x1000 it is up to 20MB).
> But then the size grows unproportionally.
> With a 4 minute run I got a 6.3GB profile.
> I don't see such a problem with the ETR polling patch.

I found there have a potential bug in the perf tool for calculation the
buffer size for snapshot mode.

In the function cs_etm_find_snapshot of perf code [1], after the "head"
has wrapped around, it always return the "old" and "head" with the
difference "mm->len", that means the trace data will be copied with
length "mm->len".  If the buffer size is 4MB, it always copies trace
data with 4MB for every time.

This is incorrect for the snapshot with very small interval, even after
wrapped around, it still have chance to only generate very small amount
trace data (e.g. for 10ms), so I think we should fix this code like:

diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c
index d942f118d32c..8a60e65c6651 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -849,6 +849,13 @@ static int cs_etm_find_snapshot(struct auxtrace_record *itr,
 	if (!wrapped)
 		return 0;
 
+	/*
+	 * If the difference between the head and old is less than mm->len,
+	 * it means the new trace data is small so doesn't need ajust them.
+	 */
+	if (*head - *old < mm->len)
+		return 0;
+
 	/*
 	 * *head has wrapped around - adjust *head and *old to pickup the
 	 * entire content of the AUX buffer.

I will do more testing and send formal patch for this.

Thanks,
Leo

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/arch/arm/util/cs-etm.c#n853



More information about the linux-arm-kernel mailing list