Re: [PATCH RFC 1/8] perf/core: Add *group_leader to perf_event_create_kernel_counter()

Ravi Bangoria
2022-12-14T03:52:51Z

> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 7f04f995c975..f671b1a9a691 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -12674,12 +12674,14 @@ SYSCALL_DEFINE5(perf_event_open,
> * @attr: attributes of the counter to create
> * @cpu: cpu in which the counter is bound
> * @task: task to profile (NULL for percpu)
> + * @group_leader: event group leader
> * @overflow_handler: callback to trigger when we hit the event
> * @context: context data could be used in overflow_handler callback
> */
> struct perf_event *
> perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
> struct task_struct *task,
> + struct perf_event *group_leader,
> perf_overflow_handler_t overflow_handler,
> void *context)
> {
> @@ -12694,7 +12696,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
> if (attr->aux_output)
> return ERR_PTR(-EINVAL);
>
> - event = perf_event_alloc(attr, cpu, task, NULL, NULL,
> + event = perf_event_alloc(attr, cpu, task, group_leader, NULL,
> overflow_handler, context, -1);

Grouping involves lot of complexities. Setting group_leader won't be sufficient.
Please see perf_event_open() syscall code for more detail.

Thanks,
Ravi