Patch "perf: Tighten (and fix) the grouping condition" has been added to the 3.18-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
perf: Tighten (and fix) the grouping condition
to the 3.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
perf-tighten-and-fix-the-grouping-condition.patch
and it can be found in the queue-3.18 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
c3c87e770458aa004bd7ed3f29945ff436fd6511Mon Sep 17 00:00:00 2001
From: Peter Zijlstra <[email protected]>
Date: Fri, 23 Jan 2015 11:19:48 +0100
Subject: perf: Tighten (and fix) the grouping condition
From: Peter Zijlstra <[email protected]>
commit c3c87e770458aa004bd7ed3f29945ff436fd6511 upstream.
The fix from 9fc81d87420d ("perf: Fix events installation during moving group") was incomplete in that it failed to recognise that creating a group with events for different CPUs is semantically broken -- they cannot be co-scheduled.
Furthermore, it leads to real breakage where, when we create an event for CPU Y and then migrate it to form a group on CPU X, the code gets confused where the counter is programmed -- triggered in practice as well by me via the perf fuzzer.
Fix this by tightening the rules for creating groups. Only allow grouping of counters that can be co-scheduled in the same context. This means for the same task and/or the same cpu.
--- include/linux/perf_event.h | 6 ------ kernel/events/core.c | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-)
include/linux/perf_event.h +0 -6
@@ -455,11 +455,6 @@ struct perf_event {#endif /* CONFIG_PERF_EVENTS */ }; -enum perf_event_context_type { - task_context, - cpu_context, -}; -/** * struct perf_event_context - event context structure *
@@ -467,7 +462,6 @@ enum perf_event_context_type {*/ struct perf_event_context {struct pmu *pmu; -enum perf_event_context_type type;/* * Protect the states of the events in the list, * nr_active, and the list:
kernel/events/core.c +13 -2
@@ -6803,7 +6803,6 @@ skip_type:__perf_event_init_context (&cpuctx->ctx);lockdep_set_class (&cpuctx->ctx.mutex, &cpuctx_mutex);lockdep_set_class (&cpuctx->ctx.lock, &cpuctx_lock); - cpuctx->ctx.type = cpu_context; cpuctx->ctx.pmu = pmu;__perf_cpu_hrtimer_init (cpuctx, cpu);
@@ -7445,7 +7444,19 @@ SYSCALL_DEFINE5(perf_event_open,* task or CPU context: */ if (move_group) { -if (group_leader->ctx->type != ctx->type) +/* +* Make sure we're both on the same task, or both +* per-cpu events. +*/ +if (group_leader->ctx->task != ctx->task) + goto err_context; + +/* +* Make sure we're both events for the same CPU; +* grouping events for different CPUs is broken; since +* you can never concurrently schedule them anyhow. +*/ +if (group_leader->cpu != event->cpu) goto err_context; }else {if (group_leader->ctx != ctx)
Patches currently in stable-queue which might be from [email protected] are
queue-3.18/perf-tighten-and-fix-the-grouping-condition.patch