perf util: Factor out sysctl__nmi_watchdog_enabled()

The NMI watchdog status is required for metric group constraint
examination.  Factor out sysctl__nmi_watchdog_enabled() to retrieve the
NMI watchdog status.

Users may count more than one metric group each time. If so, the NMI
watchdog status may be retrieved several times. To reduce the overhead,
cache the NMI watchdog status.

Replace the NMI watchdog status checking in print_footer() by

Suggested-by: Andi Kleen <>
Signed-off-by: Kan Liang <>
Acked-by: Jiri Olsa <>
Cc: Andi Kleen <>
Cc: Jin Yao <>
Cc: Mark Rutland <>
Cc: Namhyung Kim <>
Cc: Peter Zijlstra <>
Cc: Ravi Bangoria <>
Signed-off-by: Arnaldo Carvalho de Melo <>
3 files changed