Skip to content

Commit d496185

Browse files
liu-song-6gregkh
authored andcommitted
perf: fix perf_event_context->time
[ Upstream commit baf1b12 ] Time readers rely on perf_event_context->[time|timestamp|timeoffset] to get accurate time_enabled and time_running for an event. The difference between ctx->timestamp and ctx->time is the among of time when the context is not enabled. __update_context_time(ctx, false) is used to increase timestamp, but not time. Therefore, it should only be called in ctx_sched_in() when EVENT_TIME was not enabled. Fixes: 09f5e7d ("perf: Fix perf_event_read_local() time") Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/r/20230313171608.298734-1-song@kernel.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ff81377 commit d496185

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3830,7 +3830,7 @@ ctx_sched_in(struct perf_event_context *ctx,
38303830
if (likely(!ctx->nr_events))
38313831
return;
38323832

3833-
if (is_active ^ EVENT_TIME) {
3833+
if (!(is_active & EVENT_TIME)) {
38343834
/* start ctx time */
38353835
__update_context_time(ctx, false);
38363836
perf_cgroup_set_timestamp(cpuctx);

0 commit comments

Comments
 (0)