Commit ca0dd44c authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

perf/core: Fix perf_event_read_value() locking

perf_event_read_value() is an external accessor, just like
perf_event_{en,dis}able() and should thus use perf_event_ctx_lock().
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: f63a8daa ("perf: Fix event->ctx locking")
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 7d9285e8
...@@ -4398,7 +4398,7 @@ static int perf_release(struct inode *inode, struct file *file) ...@@ -4398,7 +4398,7 @@ static int perf_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running) static u64 __perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
{ {
struct perf_event *child; struct perf_event *child;
u64 total = 0; u64 total = 0;
...@@ -4426,6 +4426,18 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running) ...@@ -4426,6 +4426,18 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
return total; return total;
} }
u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
{
struct perf_event_context *ctx;
u64 count;
ctx = perf_event_ctx_lock(event);
count = __perf_event_read_value(event, enabled, running);
perf_event_ctx_unlock(event, ctx);
return count;
}
EXPORT_SYMBOL_GPL(perf_event_read_value); EXPORT_SYMBOL_GPL(perf_event_read_value);
static int __perf_read_group_add(struct perf_event *leader, static int __perf_read_group_add(struct perf_event *leader,
...@@ -4528,7 +4540,7 @@ static int perf_read_one(struct perf_event *event, ...@@ -4528,7 +4540,7 @@ static int perf_read_one(struct perf_event *event,
u64 values[4]; u64 values[4];
int n = 0; int n = 0;
values[n++] = perf_event_read_value(event, &enabled, &running); values[n++] = __perf_event_read_value(event, &enabled, &running);
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
values[n++] = enabled; values[n++] = enabled;
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
......
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