Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

oprofile, x86: Add kernel parameter oprofile.cpu_type=timer

We need this to better test x86 NMI timer mode. Otherwise it is very
hard to setup systems with NMI timer enabled, but we have this e.g. in
virtual machine environments.

Signed-off-by: Robert Richter <robert.richter@amd.com>

+24 -6
+3
Documentation/kernel-parameters.txt
··· 1848 1848 arch_perfmon: [X86] Force use of architectural 1849 1849 perfmon on Intel CPUs instead of the 1850 1850 CPU specific event set. 1851 + timer: [X86] Force use of architectural NMI 1852 + timer mode (see also oprofile.timer 1853 + for generic hr timer mode) 1851 1854 1852 1855 oops=panic Always panic on oopses. Default is to just kill the 1853 1856 process, but there is a small probability of
+21 -6
arch/x86/oprofile/nmi_int.c
··· 613 613 return 0; 614 614 } 615 615 616 - static int force_arch_perfmon; 617 - static int force_cpu_type(const char *str, struct kernel_param *kp) 616 + enum __force_cpu_type { 617 + reserved = 0, /* do not force */ 618 + timer, 619 + arch_perfmon, 620 + }; 621 + 622 + static int force_cpu_type; 623 + 624 + static int set_cpu_type(const char *str, struct kernel_param *kp) 618 625 { 619 - if (!strcmp(str, "arch_perfmon")) { 620 - force_arch_perfmon = 1; 626 + if (!strcmp(str, "timer")) { 627 + force_cpu_type = timer; 628 + printk(KERN_INFO "oprofile: forcing NMI timer mode\n"); 629 + } else if (!strcmp(str, "arch_perfmon")) { 630 + force_cpu_type = arch_perfmon; 621 631 printk(KERN_INFO "oprofile: forcing architectural perfmon\n"); 632 + } else { 633 + force_cpu_type = 0; 622 634 } 623 635 624 636 return 0; 625 637 } 626 - module_param_call(cpu_type, force_cpu_type, NULL, NULL, 0); 638 + module_param_call(cpu_type, set_cpu_type, NULL, NULL, 0); 627 639 628 640 static int __init ppro_init(char **cpu_type) 629 641 { 630 642 __u8 cpu_model = boot_cpu_data.x86_model; 631 643 struct op_x86_model_spec *spec = &op_ppro_spec; /* default */ 632 644 633 - if (force_arch_perfmon && cpu_has_arch_perfmon) 645 + if (force_cpu_type == arch_perfmon && cpu_has_arch_perfmon) 634 646 return 0; 635 647 636 648 /* ··· 707 695 int ret = 0; 708 696 709 697 if (!cpu_has_apic) 698 + return -ENODEV; 699 + 700 + if (force_cpu_type == timer) 710 701 return -ENODEV; 711 702 712 703 switch (vendor) {