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

Revert "perf/x86/intel, watchdog: Switch NMI watchdog to ref cycles on x86"

This reverts commit 2c95afc1e83d93fac3be6923465e1753c2c53b0a.

Stephane reported the following regression:

> Since Andi added:
>
> commit 2c95afc1e83d93fac3be6923465e1753c2c53b0a
> Author: Andi Kleen <ak@linux.intel.com>
> Date: Thu Jun 9 06:14:38 2016 -0700
>
> perf/x86/intel, watchdog: Switch NMI watchdog to ref cycles on x86
>
> $ perf stat -e ref-cycles ls
> <not counted> ....
>
> fails systematically because the ref-cycles is now used by the
> watchdog and given this is a system-wide pinned event, it monopolizes
> the fixed counter 2 which is the only counter able to measure this event.

Since the next merge window is near, fix the regression for now
by reverting the commit.

Reported-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

-16
-8
arch/x86/kernel/apic/hw_nmi.c
··· 18 18 #include <linux/nmi.h> 19 19 #include <linux/module.h> 20 20 #include <linux/delay.h> 21 - #include <linux/perf_event.h> 22 21 23 22 #ifdef CONFIG_HARDLOCKUP_DETECTOR 24 - int hw_nmi_get_event(void) 25 - { 26 - if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) 27 - return PERF_COUNT_HW_REF_CPU_CYCLES; 28 - return PERF_COUNT_HW_CPU_CYCLES; 29 - } 30 - 31 23 u64 hw_nmi_get_sample_period(int watchdog_thresh) 32 24 { 33 25 return (u64)(cpu_khz) * 1000 * watchdog_thresh;
-1
include/linux/nmi.h
··· 66 66 67 67 #ifdef CONFIG_LOCKUP_DETECTOR 68 68 u64 hw_nmi_get_sample_period(int watchdog_thresh); 69 - int hw_nmi_get_event(void); 70 69 extern int nmi_watchdog_enabled; 71 70 extern int soft_watchdog_enabled; 72 71 extern int watchdog_user_enabled;
-7
kernel/watchdog.c
··· 315 315 316 316 #ifdef CONFIG_HARDLOCKUP_DETECTOR 317 317 318 - /* Can be overriden by architecture */ 319 - __weak int hw_nmi_get_event(void) 320 - { 321 - return PERF_COUNT_HW_CPU_CYCLES; 322 - } 323 - 324 318 static struct perf_event_attr wd_hw_attr = { 325 319 .type = PERF_TYPE_HARDWARE, 326 320 .config = PERF_COUNT_HW_CPU_CYCLES, ··· 604 610 605 611 wd_attr = &wd_hw_attr; 606 612 wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh); 607 - wd_attr->config = hw_nmi_get_event(); 608 613 609 614 /* Try to register using hardware perf events */ 610 615 event = perf_event_create_kernel_counter(wd_attr, cpu, NULL, watchdog_overflow_callback, NULL);