Lines Matching refs:nd_pmu
122 struct nvdimm_pmu *nd_pmu; in nvdimm_pmu_cpumask_show() local
124 nd_pmu = container_of(pmu, struct nvdimm_pmu, pmu); in nvdimm_pmu_cpumask_show()
126 return cpumap_print_to_pagebuf(true, buf, cpumask_of(nd_pmu->cpu)); in nvdimm_pmu_cpumask_show()
131 struct nvdimm_pmu *nd_pmu; in nvdimm_pmu_cpu_offline() local
136 nd_pmu = hlist_entry_safe(node, struct nvdimm_pmu, node); in nvdimm_pmu_cpu_offline()
139 cpumask_test_and_clear_cpu(cpu, &nd_pmu->arch_cpumask); in nvdimm_pmu_cpu_offline()
145 if (cpu != nd_pmu->cpu) in nvdimm_pmu_cpu_offline()
149 target = cpumask_any(&nd_pmu->arch_cpumask); in nvdimm_pmu_cpu_offline()
160 nd_pmu->cpu = target; in nvdimm_pmu_cpu_offline()
164 perf_pmu_migrate_context(&nd_pmu->pmu, cpu, target); in nvdimm_pmu_cpu_offline()
171 struct nvdimm_pmu *nd_pmu; in nvdimm_pmu_cpu_online() local
173 nd_pmu = hlist_entry_safe(node, struct nvdimm_pmu, node); in nvdimm_pmu_cpu_online()
175 if (nd_pmu->cpu >= nr_cpu_ids) in nvdimm_pmu_cpu_online()
176 nd_pmu->cpu = cpu; in nvdimm_pmu_cpu_online()
181 static int create_cpumask_attr_group(struct nvdimm_pmu *nd_pmu) in create_cpumask_attr_group() argument
213 nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR] = nvdimm_pmu_cpumask_group; in create_cpumask_attr_group()
217 static int nvdimm_pmu_cpu_hotplug_init(struct nvdimm_pmu *nd_pmu) in nvdimm_pmu_cpu_hotplug_init() argument
228 if (!cpumask_empty(&nd_pmu->arch_cpumask)) { in nvdimm_pmu_cpu_hotplug_init()
229 nd_pmu->cpu = cpumask_any(&nd_pmu->arch_cpumask); in nvdimm_pmu_cpu_hotplug_init()
232 nodeid = dev_to_node(nd_pmu->dev); in nvdimm_pmu_cpu_hotplug_init()
234 nd_pmu->cpu = cpumask_any(cpumask); in nvdimm_pmu_cpu_hotplug_init()
243 nd_pmu->cpuhp_state = rc; in nvdimm_pmu_cpu_hotplug_init()
246 rc = cpuhp_state_add_instance_nocalls(nd_pmu->cpuhp_state, &nd_pmu->node); in nvdimm_pmu_cpu_hotplug_init()
248 cpuhp_remove_multi_state(nd_pmu->cpuhp_state); in nvdimm_pmu_cpu_hotplug_init()
253 rc = create_cpumask_attr_group(nd_pmu); in nvdimm_pmu_cpu_hotplug_init()
255 cpuhp_state_remove_instance_nocalls(nd_pmu->cpuhp_state, &nd_pmu->node); in nvdimm_pmu_cpu_hotplug_init()
256 cpuhp_remove_multi_state(nd_pmu->cpuhp_state); in nvdimm_pmu_cpu_hotplug_init()
263 static void nvdimm_pmu_free_hotplug_memory(struct nvdimm_pmu *nd_pmu) in nvdimm_pmu_free_hotplug_memory() argument
265 cpuhp_state_remove_instance_nocalls(nd_pmu->cpuhp_state, &nd_pmu->node); in nvdimm_pmu_free_hotplug_memory()
266 cpuhp_remove_multi_state(nd_pmu->cpuhp_state); in nvdimm_pmu_free_hotplug_memory()
268 if (nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]) in nvdimm_pmu_free_hotplug_memory()
269 kfree(nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]->attrs); in nvdimm_pmu_free_hotplug_memory()
270 kfree(nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]); in nvdimm_pmu_free_hotplug_memory()
273 int register_nvdimm_pmu(struct nvdimm_pmu *nd_pmu, struct platform_device *pdev) in register_nvdimm_pmu() argument
277 if (!nd_pmu || !pdev) in register_nvdimm_pmu()
281 if (WARN_ON_ONCE(!(nd_pmu->pmu.event_init && nd_pmu->pmu.add && in register_nvdimm_pmu()
282 nd_pmu->pmu.del && nd_pmu->pmu.read && nd_pmu->pmu.name))) in register_nvdimm_pmu()
285 nd_pmu->pmu.attr_groups = kzalloc((NVDIMM_PMU_NULL_ATTR + 1) * in register_nvdimm_pmu()
287 if (!nd_pmu->pmu.attr_groups) in register_nvdimm_pmu()
294 nd_pmu->dev = &pdev->dev; in register_nvdimm_pmu()
297 nd_pmu->pmu.attr_groups[NVDIMM_PMU_FORMAT_ATTR] = &nvdimm_pmu_format_group; in register_nvdimm_pmu()
298 nd_pmu->pmu.attr_groups[NVDIMM_PMU_EVENT_ATTR] = &nvdimm_pmu_events_group; in register_nvdimm_pmu()
299 nd_pmu->pmu.attr_groups[NVDIMM_PMU_NULL_ATTR] = NULL; in register_nvdimm_pmu()
302 rc = nvdimm_pmu_cpu_hotplug_init(nd_pmu); in register_nvdimm_pmu()
304 pr_info("cpu hotplug feature failed for device: %s\n", nd_pmu->pmu.name); in register_nvdimm_pmu()
305 kfree(nd_pmu->pmu.attr_groups); in register_nvdimm_pmu()
309 rc = perf_pmu_register(&nd_pmu->pmu, nd_pmu->pmu.name, -1); in register_nvdimm_pmu()
311 nvdimm_pmu_free_hotplug_memory(nd_pmu); in register_nvdimm_pmu()
312 kfree(nd_pmu->pmu.attr_groups); in register_nvdimm_pmu()
317 nd_pmu->pmu.name); in register_nvdimm_pmu()
323 void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu) in unregister_nvdimm_pmu() argument
325 perf_pmu_unregister(&nd_pmu->pmu); in unregister_nvdimm_pmu()
326 nvdimm_pmu_free_hotplug_memory(nd_pmu); in unregister_nvdimm_pmu()
327 kfree(nd_pmu->pmu.attr_groups); in unregister_nvdimm_pmu()
328 kfree(nd_pmu); in unregister_nvdimm_pmu()