int __init op_nmi_init(struct oprofile_operations *ops) { __u8 vendor = boot_cpu_data.x86_vendor; __u8 family = boot_cpu_data.x86; char *cpu_type = NULL; int ret = 0; if (!cpu_has_apic) return -ENODEV; if (force_cpu_type == timer) return -ENODEV; switch (vendor) { case X86_VENDOR_AMD: /* Needs to be at least an Athlon (or hammer in 32bit mode) */ switch (family) { case 6: cpu_type = "i386/athlon"; break; case 0xf: /* * Actually it could be i386/hammer too, but * give user space an consistent name. */ cpu_type = "x86-64/hammer"; break; case 0x10: cpu_type = "x86-64/family10"; break; case 0x11: cpu_type = "x86-64/family11h"; break; case 0x12: cpu_type = "x86-64/family12h"; break; case 0x14: cpu_type = "x86-64/family14h"; break; case 0x15: cpu_type = "x86-64/family15h"; break; default: return -ENODEV; } model = &op_amd_spec; break; case X86_VENDOR_INTEL: switch (family) { /* Pentium IV */ case 0xf: p4_init(&cpu_type); break; /* A P6-class processor */ case 6: ppro_init(&cpu_type); break; default: break; } if (cpu_type) break; if (!cpu_has_arch_perfmon) return -ENODEV; /* use arch perfmon as fallback */ cpu_type = "i386/arch_perfmon"; model = &op_arch_perfmon_spec; break; default: return -ENODEV; } /* default values, can be overwritten by model */ ops->create_files = nmi_create_files; ops->setup = nmi_setup; ops->shutdown = nmi_shutdown; ops->start = nmi_start; ops->stop = nmi_stop; ops->cpu_type = cpu_type; if (model->init) ret = model->init(ops); if (ret) return ret; if (!model->num_virt_counters) { pax_open_kernel(); *(unsigned int *)&model->num_virt_counters = model->num_counters; pax_close_kernel(); } mux_init(ops); init_suspend_resume(); printk(KERN_INFO "oprofile: using NMI interrupt.\n"); return 0; }
int __init op_nmi_init(struct oprofile_operations *ops) { __u8 vendor = boot_cpu_data.x86_vendor; __u8 family = boot_cpu_data.x86; char *cpu_type = NULL; int ret = 0; if (!cpu_has_apic) return -ENODEV; if (force_cpu_type == timer) return -ENODEV; switch (vendor) { case X86_VENDOR_AMD: switch (family) { case 6: cpu_type = "i386/athlon"; break; case 0xf: cpu_type = "x86-64/hammer"; break; case 0x10: cpu_type = "x86-64/family10"; break; case 0x11: cpu_type = "x86-64/family11h"; break; case 0x12: cpu_type = "x86-64/family12h"; break; case 0x14: cpu_type = "x86-64/family14h"; break; case 0x15: cpu_type = "x86-64/family15h"; break; default: return -ENODEV; } model = &op_amd_spec; break; case X86_VENDOR_INTEL: switch (family) { case 0xf: p4_init(&cpu_type); break; case 6: ppro_init(&cpu_type); break; default: break; } if (cpu_type) break; if (!cpu_has_arch_perfmon) return -ENODEV; cpu_type = "i386/arch_perfmon"; model = &op_arch_perfmon_spec; break; default: return -ENODEV; } /* default values, can be overwritten by model */ ops->create_files = nmi_create_files; ops->setup = nmi_setup; ops->shutdown = nmi_shutdown; ops->start = nmi_start; ops->stop = nmi_stop; ops->cpu_type = cpu_type; if (model->init) ret = model->init(ops); if (ret) return ret; if (!model->num_virt_counters) model->num_virt_counters = model->num_counters; mux_init(ops); init_suspend_resume(); printk(KERN_INFO "oprofile: using NMI interrupt.\n"); return 0; }