Skip to content

Commit

Permalink
perf: Apply PERF_EVENT_IOC_MODIFY_ATTRIBUTES to children
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Marco Elver authored and Peter Zijlstra committed Apr 16, 2021
1 parent ef54c1a commit 47f661e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3200,16 +3200,36 @@ static int perf_event_modify_breakpoint(struct perf_event *bp,
static int perf_event_modify_attr(struct perf_event *event,
struct perf_event_attr *attr)
{
int (*func)(struct perf_event *, struct perf_event_attr *);
struct perf_event *child;
int err;

if (event->attr.type != attr->type)
return -EINVAL;

switch (event->attr.type) {
case PERF_TYPE_BREAKPOINT:
return perf_event_modify_breakpoint(event, attr);
func = perf_event_modify_breakpoint;
break;
default:
/* Place holder for future additions. */
return -EOPNOTSUPP;
}

WARN_ON_ONCE(event->ctx->parent_ctx);

mutex_lock(&event->child_mutex);
err = func(event, attr);
if (err)
goto out;
list_for_each_entry(child, &event->child_list, child_list) {
err = func(child, attr);
if (err)
goto out;
}
out:
mutex_unlock(&event->child_mutex);
return err;
}

static void ctx_sched_out(struct perf_event_context *ctx,
Expand Down

0 comments on commit 47f661e

Please sign in to comment.