perf/core: Accumulate lost samples in inherited group reads
PATCH 1/1 perf/core: Accumulate lost samples in inherited group reads
__perf_read_group_add() accumulates event counts from inherited child events, but overwrites the PERF_FORMAT_LOST fields. A child reporting no losses therefore hides nonzero parent losses while it is alive.
Accumulate lost_samples for the group leader and siblings so group reads preserve losses across inherited events.
--- kernel/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/core.c +2 -2
@@ -6163,14 +6163,14 @@ static int __perf_read_group_add(struct perf_event *leader,if (read_format &PERF_FORMAT_ID ) values[n++] =primary_event_id (leader);if (read_format &PERF_FORMAT_LOST ) - values[n++] =atomic64_read (&leader->lost_samples); + values[n++] +=atomic64_read (&leader->lost_samples);for_each_sibling_event (sub, leader) { values[n++] +=perf_event_count (sub, false);if (read_format &PERF_FORMAT_ID ) values[n++] =primary_event_id (sub);if (read_format &PERF_FORMAT_LOST ) - values[n++] =atomic64_read (&sub->lost_samples); + values[n++] +=atomic64_read (&sub->lost_samples); } unlock:
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 10 lines
__perf_read_group_add()accumulates event counts from inherited child events, but overwrites thePERF_FORMAT_LOSTfields. A child reporting no losses therefore hides nonzero parent losses while it is alive.Accumulate
lost_samplesfor the group leader and siblings so group reads preserve losses across inherited events.Fixes 119a784c8127 ("perf/core: Add a new read format to get a number of lost samples")Signed-off-by Avi Weiss <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1