-#ifdef CONFIG_HOTPLUG_CPU
- field->u.perf_counter.nb.notifier_call =
- lttng_perf_counter_cpu_hp_callback;
- field->u.perf_counter.nb.priority = 0;
- register_cpu_notifier(&field->u.perf_counter.nb);
-#endif
-
- get_online_cpus();
- for_each_online_cpu(cpu) {
- events[cpu] = perf_event_create_kernel_counter(attr,
- cpu, NULL, overflow_callback);
- if (!events[cpu] || IS_ERR(events[cpu])) {
- ret = -EINVAL;
- goto counter_error;
- }
- }
- put_online_cpus();
+ perf_field->cpuhp_prepare.component = LTTNG_CONTEXT_PERF_COUNTERS;
+ ret = cpuhp_state_add_instance(lttng_hp_prepare,
+ &perf_field->cpuhp_prepare.node);
+ if (ret)
+ goto cpuhp_prepare_error;
+
+ perf_field->cpuhp_online.component = LTTNG_CONTEXT_PERF_COUNTERS;
+ ret = cpuhp_state_add_instance(lttng_hp_online,
+ &perf_field->cpuhp_online.node);
+ if (ret)
+ goto cpuhp_online_error;