Re: [PATCH] perf: Add support for creating offline events

From: Jiri Olsa
Date: Mon Feb 12 2018 - 04:44:13 EST


On Fri, Feb 09, 2018 at 03:07:00PM -0800, Raghavendra Rao Ananta wrote:

SNIP

>
> if (!task) {
> +#if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC_CORE
> + struct perf_cpu_context *cpuctx =
> + container_of(ctx, struct perf_cpu_context, ctx);
> +
> + if (!cpuctx->online) {
> + perf_prepare_install_in_context(event);
> + return;
> + }
> +#endif
> cpu_function_call(cpu, __perf_install_in_context, event);
> return;
> }
> @@ -2421,6 +2443,43 @@ static int __perf_install_in_context(void *info)
> raw_spin_unlock_irq(&ctx->lock);
> }
>
> +#if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC_CORE
> +static void perf_deferred_install_in_context(int cpu)
> +{
> + struct perf_event *event, *tmp;
> + struct perf_event_context *ctx;
> +
> + /* This function is called twice while coming online. Once for
> + * CPUHP_PERF_PREPARE and the other for CPUHP_AP_PERF_ONLINE.
> + * Only during the CPUHP_AP_PERF_ONLINE state, we can confirm
> + * that CPU PMU is ready and can be installed to.
> + */
> + if (!cpu_online(cpu))
> + return;
> +
> + spin_lock(&dormant_event_list_lock);
> + list_for_each_entry_safe(event, tmp, &dormant_event_list,
> + dormant_entry) {
> + if (cpu != event->cpu)
> + continue;

I wonder having per cpu lists would be better here,
could be quite busy for big number of CPUs

jirka