diff options
author | Peter Zijlstra <peterz@infradead.org> | 2017-09-05 13:38:24 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-10-27 10:31:57 +0200 |
commit | a9cd8194e1e6bd09619954721dfaf0f94fe2003e (patch) | |
tree | 960eefc8af70349f91914c2b4410cf2e8b8e96ff /kernel/events | |
parent | 0ee098c97a6ebe163180e74b740c0a37bcdaa173 (diff) | |
download | linux-stable-a9cd8194e1e6bd09619954721dfaf0f94fe2003e.tar.gz linux-stable-a9cd8194e1e6bd09619954721dfaf0f94fe2003e.tar.bz2 linux-stable-a9cd8194e1e6bd09619954721dfaf0f94fe2003e.zip |
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: Peter 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: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 5fae98626b15..0f34f2a47eb6 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4453,6 +4453,8 @@ static int __perf_read_group_add(struct perf_event *leader, if (ret) return ret; + raw_spin_lock_irqsave(&ctx->lock, flags); + /* * Since we co-schedule groups, {enabled,running} times of siblings * 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, if (read_format & PERF_FORMAT_ID) values[n++] = primary_event_id(leader); - raw_spin_lock_irqsave(&ctx->lock, flags); - list_for_each_entry(sub, &leader->sibling_list, group_entry) { values[n++] += perf_event_count(sub); if (read_format & PERF_FORMAT_ID) |