Commit baf1b12a authored by Song Liu's avatar Song Liu Committed by Peter Zijlstra

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: 09f5e7dc ("perf: Fix perf_event_read_local() time")
Signed-off-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/r/20230313171608.298734-1-song@kernel.org
parent eb81a2ed
...@@ -3872,7 +3872,7 @@ ctx_sched_in(struct perf_event_context *ctx, enum event_type_t event_type) ...@@ -3872,7 +3872,7 @@ ctx_sched_in(struct perf_event_context *ctx, enum event_type_t event_type)
if (likely(!ctx->nr_events)) if (likely(!ctx->nr_events))
return; return;
if (is_active ^ EVENT_TIME) { if (!(is_active & EVENT_TIME)) {
/* start ctx time */ /* start ctx time */
__update_context_time(ctx, false); __update_context_time(ctx, false);
perf_cgroup_set_timestamp(cpuctx); perf_cgroup_set_timestamp(cpuctx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment