From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751093AbdBKSce (ORCPT ); Sat, 11 Feb 2017 13:32:34 -0500 Received: from mail.skyhub.de ([78.46.96.112]:44264 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750779AbdBKScc (ORCPT ); Sat, 11 Feb 2017 13:32:32 -0500 Date: Sat, 11 Feb 2017 19:32:18 +0100 From: Borislav Petkov To: Ingo Molnar Cc: Robert Richter , Arnaldo Carvalho de Melo , Peter Zijlstra , Vince Weaver , lkml Subject: Re: [RFC PATCH] perf/stat: Add --disable-hwdt Message-ID: <20170211183218.ijnvb5f7ciyuunx4@pd.tnic> References: <20170206124116.7jmrmufthqtnd3dc@pd.tnic> <20170206124447.GA12772@gmail.com> <20170206124937.zlowglr5gpq35piy@pd.tnic> <20170206131832.GG4906@rric.localdomain> <20170206132349.bl6qbpjflez3lpkp@pd.tnic> <20170207072512.GB18584@gmail.com> <20170207105412.yrvnd3ks42jjtrtg@pd.tnic> <20170207150610.k7aptdiqtpxqd6dp@pd.tnic> <20170211170330.nm2ew4nxwa2mn3fo@pd.tnic> <20170211175910.GA31544@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170211175910.GA31544@gmail.com> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 11, 2017 at 06:59:10PM +0100, Ingo Molnar wrote: > So I checked the perf-list manpage and it didn't tell me much about how to disable > the NMI watchdog. Oh, it is buried there: " EVENT GROUPS ------------ ... Globally pinned events can limit the number of counters available for other groups. On x86 systems, the NMI watchdog pins a counter by default. The nmi watchdog can be disabled as root with echo 0 > /proc/sys/kernel/nmi_watchdog" > How about a more proactive hint, something like: > > To disable the NMI watchdog permanently, do: Why permanently? We want it to run and be disabled around the measurement only. Anyway, here's something more to the point: --- From: Borislav Petkov Date: Tue, 7 Feb 2017 01:40:05 +0100 Subject: [PATCH -v2] perf stat: Issue a HW watchdog disable hint When using perf stat on an AMD F15h system with the default hw events attributes, some of the events don't get counted: Performance counter stats for 'sleep 1': 0.749208 task-clock (msec) # 0.001 CPUs utilized 1 context-switches # 0.001 M/sec 0 cpu-migrations # 0.000 K/sec 54 page-faults # 0.072 M/sec 1,122,815 cycles # 1.499 GHz 286,740 stalled-cycles-frontend # 25.54% frontend cycles idle stalled-cycles-backend (0.00%) ^^^^^^^^^^^^ instructions (0.00%) ^^^^^^^^^^^^ branches (0.00%) branch-misses (0.00%) 1.001550070 seconds time elapsed The reason is that we have the HW watchdog consuming one PMU counter and when perf tries to schedule 6 events on 6 counters and some of those counters are constrained to only a specific subset of PMCs by the hardware, the event scheduling fails. So issue a hint to disable the HW watchdog around a perf stat session. Signed-off-by: Borislav Petkov --- tools/perf/builtin-stat.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index a02f2e965628..a2763243a03d 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -146,6 +146,7 @@ static aggr_get_id_t aggr_get_id; static bool append_file; static const char *output_name; static int output_fd; +static int print_free_counters_hint; struct perf_stat { bool record; @@ -1109,6 +1110,9 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval, counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED, csv_sep); + if (counter->supported) + print_free_counters_hint = 1; + fprintf(stat_config.output, "%-*s%s", csv_output ? 0 : unit_width, counter->unit, csv_sep); @@ -1477,6 +1481,13 @@ static void print_footer(void) avg_stats(&walltime_nsecs_stats)); } fprintf(output, "\n\n"); + + if (print_free_counters_hint) + fprintf(output, +"Some events weren't counted. Try disabling the NMI watchdog:\n" +" echo 0 > /proc/sys/kernel/nmi_watchdog\n" +" perf stat ...\n" +" echo 1 > /proc/sys/kernel/nmi_watchdog\n"); } static void print_counters(struct timespec *ts, int argc, const char **argv) -- 2.11.0 -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.