tools/perf: Correctly calculate sample period for inherited SAMPLE_READ values
authorBen Gainey <ben.gainey@arm.com>
Tue, 1 Oct 2024 12:15:04 +0000 (13:15 +0100)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 2 Oct 2024 21:58:03 +0000 (14:58 -0700)
commit80c281fca252827facd05875b8d9d36d7aad0f8d
treed02d7bfcc2fc1666581898ffae5c08d7af29bf3d
parentad321b19d2bb6ed0380ad53a06972ea7f4e7d7b1
tools/perf: Correctly calculate sample period for inherited SAMPLE_READ values

Sample period calculation in deliver_sample_value is updated to
calculate the per-thread period delta for events that are inherit +
PERF_SAMPLE_READ. When the sampling event has this configuration, the
read_format.id is used with the tid from the sample to lookup the
storage of the previously accumulated counter total before calculating
the delta. All existing valid configurations where read_format.value
represents some global value continue to use just the read_format.id to
locate the storage of the previously accumulated total.

perf_sample_id is modified to support tracking per-thread
values, along with the existing global per-id values. In the
per-thread case, values are stored in a hash by tid within the
perf_sample_id, and are dynamically allocated as the number is not known
ahead of time.

Signed-off-by: Ben Gainey <ben.gainey@arm.com>
Cc: james.clark@arm.com
Link: https://lore.kernel.org/r/20241001121505.1009685-2-ben.gainey@arm.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/lib/perf/evsel.c
tools/lib/perf/include/internal/evsel.h
tools/perf/util/session.c