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

perf/core: Fix __perf_read_group_add() locking

Event timestamps are serialized using ctx->lock, make sure to hold it
over reading all values.
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>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 0ee098c9
...@@ -4453,6 +4453,8 @@ static int __perf_read_group_add(struct perf_event *leader, ...@@ -4453,6 +4453,8 @@ static int __perf_read_group_add(struct perf_event *leader,
if (ret) if (ret)
return ret; return ret;
raw_spin_lock_irqsave(&ctx->lock, flags);
/* /*
* Since we co-schedule groups, {enabled,running} times of siblings * Since we co-schedule groups, {enabled,running} times of siblings
* will be identical to those of the leader, so we only publish one * will be identical to those of the leader, so we only publish one
...@@ -4475,8 +4477,6 @@ static int __perf_read_group_add(struct perf_event *leader, ...@@ -4475,8 +4477,6 @@ static int __perf_read_group_add(struct perf_event *leader,
if (read_format & PERF_FORMAT_ID) if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(leader); values[n++] = primary_event_id(leader);
raw_spin_lock_irqsave(&ctx->lock, flags);
list_for_each_entry(sub, &leader->sibling_list, group_entry) { list_for_each_entry(sub, &leader->sibling_list, group_entry) {
values[n++] += perf_event_count(sub); values[n++] += perf_event_count(sub);
if (read_format & PERF_FORMAT_ID) if (read_format & PERF_FORMAT_ID)
......
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