Skip to content

Commit 47f661e

Browse files
melverPeter Zijlstra
authored andcommitted
perf: Apply PERF_EVENT_IOC_MODIFY_ATTRIBUTES to children
As with other ioctls (such as PERF_EVENT_IOC_{ENABLE,DISABLE}), fix up handling of PERF_EVENT_IOC_MODIFY_ATTRIBUTES to also apply to children. Suggested-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Marco Elver <elver@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Link: https://lkml.kernel.org/r/20210408103605.1676875-3-elver@google.com
1 parent ef54c1a commit 47f661e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

kernel/events/core.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3200,16 +3200,36 @@ static int perf_event_modify_breakpoint(struct perf_event *bp,
32003200
static int perf_event_modify_attr(struct perf_event *event,
32013201
struct perf_event_attr *attr)
32023202
{
3203+
int (*func)(struct perf_event *, struct perf_event_attr *);
3204+
struct perf_event *child;
3205+
int err;
3206+
32033207
if (event->attr.type != attr->type)
32043208
return -EINVAL;
32053209

32063210
switch (event->attr.type) {
32073211
case PERF_TYPE_BREAKPOINT:
3208-
return perf_event_modify_breakpoint(event, attr);
3212+
func = perf_event_modify_breakpoint;
3213+
break;
32093214
default:
32103215
/* Place holder for future additions. */
32113216
return -EOPNOTSUPP;
32123217
}
3218+
3219+
WARN_ON_ONCE(event->ctx->parent_ctx);
3220+
3221+
mutex_lock(&event->child_mutex);
3222+
err = func(event, attr);
3223+
if (err)
3224+
goto out;
3225+
list_for_each_entry(child, &event->child_list, child_list) {
3226+
err = func(child, attr);
3227+
if (err)
3228+
goto out;
3229+
}
3230+
out:
3231+
mutex_unlock(&event->child_mutex);
3232+
return err;
32133233
}
32143234

32153235
static void ctx_sched_out(struct perf_event_context *ctx,

0 commit comments

Comments
 (0)