Switch NMI watchdog to ref cycles on x86
Subsystems (2)
PATCH 2/2 perf stat: Remove nmi watchdog check code again
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
Now that the NMI watchdog runs with reference cycles, and does not conflict with TopDown anymore, we don't need to check that the NMI watchdog is off in perf stat --topdown.
Remove the code that does this and always use a group unconditionally.
--- tools/perf/Documentation/perf-stat.txt | 6 ------ tools/perf/arch/x86/util/Build | 1 - tools/perf/arch/x86/util/group.c | 27 --------------------------- tools/perf/builtin-stat.c | 18 +----------------- tools/perf/util/group.h | 7 ------- 5 files changed, 1 insertion(+), 58 deletions(-) delete mode 100644 tools/perf/arch/x86/util/group.c delete mode 100644 tools/perf/util/group.h
tools/perf/Documentation/perf-stat.txt +0 -6
@@ -225,12 +225,6 @@ CPU thread. Per core mode is automatically enabled and -a (global monitoring) is needed, requiring root rights or perf.perf_event_paranoid=-1. -Topdown uses the full Performance Monitoring Unit, and needs -disabling of the NMI watchdog (as root): -echo 0 > /proc/sys/kernel/nmi_watchdog -for best results. Otherwise the bottlenecks may be inconsistent -on workload with changing phases. - This enables --metric-only, unless overriden with --no-metric-only. To interpret the results it is usually needed to know on which
tools/perf/arch/x86/util/Build +0 -1
@@ -3,7 +3,6 @@ libperf-y += tsc.o libperf-y += pmu.o libperf-y += kvm-stat.o libperf-y += perf_regs.o -libperf-y += group.o libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_BPF_PROLOGUE) += dwarf-regs.o
tools/perf/arch/x86/util/group.c deleted +0 -27
@@ -1,27 +0,0 @@ -#include <stdio.h> -#include "api/fs/fs.h" -#include "util/group.h" - -/* -* Check whether we can use a group for top down. -* Without a group may get bad results due to multiplexing. -*/ -bool arch_topdown_check_group (bool *warn) -{ -int n; - -if (sysctl__read_int ("kernel/nmi_watchdog" , &n) <0 ) -return false; -if (n >0 ) { - *warn = true; -return false; - } -return true; -} - -void arch_topdown_group_warn (void ) -{ -fprintf (stderr, -"nmi_watchdog enabled with topdown. May give wrong results.\n" -"Disable with echo 0 > /proc/sys/kernel/nmi_watchdog\n" ); -}
tools/perf/builtin-stat.c +1 -17
@@ -59,10 +59,8 @@#include "util/thread.h" #include "util/thread_map.h" #include "util/counts.h" -#include "util/group.h" #include "util/session.h" #include "util/tool.h" -#include "util/group.h" #include "asm/bug.h" #include <api/fs/fs.h>
@@ -1861,16 +1859,6 @@ static int topdown_filter_events(const char **attr, char **str, bool use_group)return 0 ; } -__weak bool arch_topdown_check_group (bool *warn) -{ - *warn = false; -return false; -} - -__weak void arch_topdown_group_warn (void ) -{ -} -/* * Add default attributes, if there were no attributes specified or * if -d/--detailed, -d -d or -d -d -d is used:
@@ -2010,7 +1998,6 @@ static int add_default_attributes(void)if (topdown_run) {char *str =NULL ; -bool warn = false;if (stat_config.aggr_mode !=AGGR_GLOBAL && stat_config.aggr_mode !=AGGR_CORE ) {
@@ -2025,14 +2012,11 @@ static int add_default_attributes(void)if (!force_metric_only) metric_only = true; -if (topdown_filter_events (topdown_attrs, &str, -arch_topdown_check_group (&warn)) <0 ) { +if (topdown_filter_events (topdown_attrs, &str, true) <0 ) {pr_err ("Out of memory\n" );return -1 ; }if (topdown_attrs[0 ] && str) { -if (warn) -arch_topdown_group_warn (); err =parse_events (evsel_list, str,NULL );if (err) { fprintf(stderr,
tools/perf/util/group.h deleted +0 -7
@@ -1,7 +0,0 @@ -#ifndef GROUP_H -#define GROUP_H 1 - -bool arch_topdown_check_group (bool *warn); -void arch_topdown_group_warn (void ); - -#endif
Signature · 1 line
2.5.5
PATCH 1/2 Switch NMI watchdog to ref cycles on x86
From: Andi Kleen <[email protected]>
The NMI watchdog uses either the fixed cycles or a generic cycles counter. This causes a lot of conflicts with users of the PMU who want to run a full group including the cycles fixed counter, for example the --topdown support recently added to perf stat. The code needs to fall back to not use groups, which can cause measurement inaccuracy due to multiplexing errors.
This patch switches the NMI watchdog to use reference cycles on Intel systems. This is actually more accurate than cycles, because cycles can tick faster than the measured CPU Frequency due to Turbo mode.
The ref cycles always tick at their frequency, or slower when the system is idling. That means the NMI watchdog can never expire too early, unlike with cycles.
The reference cycles tick roughly at the frequency of the TSC, so the same period computation can be used.
--- arch/x86/kernel/apic/hw_nmi.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/apic/hw_nmi.c +1 -0
@@ -18,6 +18,7 @@#include <linux/nmi.h> #include <linux/module.h> #include <linux/delay.h> +#include <linux/perf_event.h> #ifdef CONFIG_HARDLOCKUP_DETECTOR int hw_nmi_get_event (void )
Signature · 1 line
2.5.5
Peter Zijlstra
maintainerQuoted 1 line · Andi Kleen
This patch switches the NMI watchdog to use reference cycles
Are you sure; it seems to only add an #include
Quoted 19 lines
--- arch/x86/kernel/apic/hw_nmi.c | 1 + 1 file changed, 1 insertion(+)arch/x86/kernel/apic/hw_nmi.c +1
-0@@ -18,6 +18,7 @@#include <linux/nmi.h> #include <linux/module.h> #include <linux/delay.h> +#include <linux/perf_event.h> #ifdef CONFIG_HARDLOCKUP_DETECTOR int hw_nmi_get_event (void )Signature · 1 line
2.5.5
Quoted 5 lines · Peter Zijlstra
Quoted 1 line · Andi Kleen
This patch switches the NMI watchdog to use reference cycles
Are you sure; it seems to only add an #include
Right, sorry a git rebase went wrong. Let me resend with the correct patches.
-Andi