Commit 159a80b2142df709416ab369113de7d511c48331

Authored by Robert Richter
1 parent 97f7f8189f

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>

Showing 2 changed files with 24 additions and 6 deletions Side-by-side Diff

Documentation/kernel-parameters.txt
... ... @@ -1848,6 +1848,9 @@
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
arch/x86/oprofile/nmi_int.c
... ... @@ -613,24 +613,36 @@
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 /*
... ... @@ -695,6 +707,9 @@
695 707 int ret = 0;
696 708  
697 709 if (!cpu_has_apic)
  710 + return -ENODEV;
  711 +
  712 + if (force_cpu_type == timer)
698 713 return -ENODEV;
699 714  
700 715 switch (vendor) {