int __init oprofile_perf_init(struct oprofile_operations *ops) { int cpu, ret = 0; ret = init_driverfs(); if (ret) return ret; memset(&perf_events, 0, sizeof(perf_events)); num_counters = perf_num_counters(); if (num_counters <= 0) { pr_info("oprofile: no performance counters\n"); ret = -ENODEV; goto out; } counter_config = kcalloc(num_counters, sizeof(struct op_counter_config), GFP_KERNEL); if (!counter_config) { pr_info("oprofile: failed to allocate %d " "counters\n", num_counters); ret = -ENOMEM; num_counters = 0; goto out; } for_each_possible_cpu(cpu) { perf_events[cpu] = kcalloc(num_counters, sizeof(struct perf_event *), GFP_KERNEL); if (!perf_events[cpu]) { pr_info("oprofile: failed to allocate %d perf events " "for cpu %d\n", num_counters, cpu); ret = -ENOMEM; goto out; } } ops->create_files = oprofile_perf_create_files; ops->setup = oprofile_perf_setup; ops->start = oprofile_perf_start; ops->stop = oprofile_perf_stop; ops->shutdown = oprofile_perf_stop; ops->cpu_type = op_name_from_perf_id(); if (!ops->cpu_type) ret = -ENODEV; else pr_info("oprofile: using %s\n", ops->cpu_type); out: if (ret) oprofile_perf_exit(); return ret; }
void oprofile_arch_exit(void) { oprofile_perf_exit(); }
void __exit oprofile_arch_exit(void) { oprofile_perf_exit(); kfree(sh_pmu_op_name); }