Skip to content

Commit 5ffaf03

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "Misc fixes: a handful of AUX event handling related fixes, a Sparse fix and two ABI fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/core: Fix missing static inline on perf_cgroup_switch() perf/core: Consistently fail fork on allocation failures perf/aux: Disallow aux_output for kernel events perf/core: Reattach a misplaced comment perf/aux: Fix the aux_output group inheritance fix perf/core: Disallow uncore-cgroup events
2 parents 8be636d + d00dbd2 commit 5ffaf03

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

kernel/events/core.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ perf_cgroup_set_timestamp(struct task_struct *task,
10311031
{
10321032
}
10331033

1034-
void
1034+
static inline void
10351035
perf_cgroup_switch(struct task_struct *task, struct task_struct *next)
10361036
{
10371037
}
@@ -10535,6 +10535,15 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
1053510535
goto err_ns;
1053610536
}
1053710537

10538+
/*
10539+
* Disallow uncore-cgroup events, they don't make sense as the cgroup will
10540+
* be different on other CPUs in the uncore mask.
10541+
*/
10542+
if (pmu->task_ctx_nr == perf_invalid_context && cgroup_fd != -1) {
10543+
err = -EINVAL;
10544+
goto err_pmu;
10545+
}
10546+
1053810547
if (event->attr.aux_output &&
1053910548
!(pmu->capabilities & PERF_PMU_CAP_AUX_OUTPUT)) {
1054010549
err = -EOPNOTSUPP;
@@ -11323,8 +11332,11 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
1132311332
int err;
1132411333

1132511334
/*
11326-
* Get the target context (task or percpu):
11335+
* Grouping is not supported for kernel events, neither is 'AUX',
11336+
* make sure the caller's intentions are adjusted.
1132711337
*/
11338+
if (attr->aux_output)
11339+
return ERR_PTR(-EINVAL);
1132811340

1132911341
event = perf_event_alloc(attr, cpu, task, NULL, NULL,
1133011342
overflow_handler, context, -1);
@@ -11336,6 +11348,9 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
1133611348
/* Mark owner so we could distinguish it from user events. */
1133711349
event->owner = TASK_TOMBSTONE;
1133811350

11351+
/*
11352+
* Get the target context (task or percpu):
11353+
*/
1133911354
ctx = find_get_context(event->pmu, task, event);
1134011355
if (IS_ERR(ctx)) {
1134111356
err = PTR_ERR(ctx);
@@ -11787,7 +11802,7 @@ inherit_event(struct perf_event *parent_event,
1178711802
GFP_KERNEL);
1178811803
if (!child_ctx->task_ctx_data) {
1178911804
free_event(child_event);
11790-
return NULL;
11805+
return ERR_PTR(-ENOMEM);
1179111806
}
1179211807
}
1179311808

@@ -11890,7 +11905,7 @@ static int inherit_group(struct perf_event *parent_event,
1189011905
if (IS_ERR(child_ctr))
1189111906
return PTR_ERR(child_ctr);
1189211907

11893-
if (sub->aux_event == parent_event &&
11908+
if (sub->aux_event == parent_event && child_ctr &&
1189411909
!perf_get_aux_event(child_ctr, leader))
1189511910
return -EINVAL;
1189611911
}

0 commit comments

Comments
 (0)