Skip to content

Commit baf1b12

Browse files
liu-song-6Peter Zijlstra
authored andcommitted
perf: fix perf_event_context->time
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Namhyung Kim <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent eb81a2e commit baf1b12

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3872,7 +3872,7 @@ ctx_sched_in(struct perf_event_context *ctx, enum event_type_t event_type)
38723872
if (likely(!ctx->nr_events))
38733873
return;
38743874

3875-
if (is_active ^ EVENT_TIME) {
3875+
if (!(is_active & EVENT_TIME)) {
38763876
/* start ctx time */
38773877
__update_context_time(ctx, false);
38783878
perf_cgroup_set_timestamp(cpuctx);

0 commit comments

Comments
 (0)