From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751160AbdFANLr (ORCPT ); Thu, 1 Jun 2017 09:11:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:60910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751062AbdFANLq (ORCPT ); Thu, 1 Jun 2017 09:11:46 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AEFF239EF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org Date: Thu, 1 Jun 2017 10:11:43 -0300 From: Arnaldo Carvalho de Melo To: Adrian Hunter Cc: Jiri Olsa , Michael Petlan , lkml , Ingo Molnar , Peter Zijlstra , Namhyung Kim , David Ahern , Andi Kleen Subject: Re: [PATCH 1/2] perf tests: Fix switch tracking test for P4 Message-ID: <20170601131143.GD2899@kernel.org> References: <20170526123141.20900-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170526123141.20900-1-jolsa@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, May 26, 2017 at 02:31:40PM +0200, Jiri Olsa escreveu: > The switch tracking test keeps failing on P4 cpu, > when NMI watchdog is enabled. > > The reason is that P4 pmu uses substitute event for cycles > when it's already taken (in our case by NMI watchdog), but > this event does not give even results like cycles, and we > could end up with no samples at all for our short > measuring period. > > Fixing this by using "instructions:u" event instead, > which seems to be stable enough. The original author of this test entry is Adrian, so would be nice for him to take a look and give his Ack, Adrian? - Arnaldo > Cc: Michael Petlan > Link: http://lkml.kernel.org/n/tip-4s8vo7skneszacdckv7uiog3@git.kernel.org > Signed-off-by: Jiri Olsa > --- > tools/perf/tests/switch-tracking.c | 27 +++++++++++++++++++++++++-- > 1 file changed, 25 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c > index 65474fd80da7..e519819ea2e5 100644 > --- a/tools/perf/tests/switch-tracking.c > +++ b/tools/perf/tests/switch-tracking.c > @@ -10,6 +10,7 @@ > #include "thread_map.h" > #include "cpumap.h" > #include "tests.h" > +#include "header.h" > > static int spin_sleep(void) > { > @@ -298,6 +299,27 @@ static int process_events(struct perf_evlist *evlist, > return ret; > } > > +static const char *get_hw_counter(void) > +{ > + const char *counter = "cycles:u"; > + char *cpuid; > + > + cpuid = get_cpuid_str(); > + > + /* > + * P4 pmu uses substitute event for cycles if it's already > + * taken, but it does not give even results like cycles, > + * and we could end up with no samples at all for our short > + * measuring period. Using "instructions:u" event instead, > + * which seems to be stable enough. > + */ > + if (!strcmp("GenuineIntel-15-4", cpuid)) > + counter = "instructions:u"; > + > + pr_debug("using '%s' HW counter"); > + return counter; > +} > + > /** > * test__switch_tracking - test using sched_switch and tracking events. > * > @@ -308,6 +330,7 @@ static int process_events(struct perf_evlist *evlist, > */ > int test__switch_tracking(int subtest __maybe_unused) > { > + const char *hw_counter = get_hw_counter(); > const char *sched_switch = "sched:sched_switch"; > struct switch_tracking switch_tracking = { .tids = NULL, }; > struct record_opts opts = { > @@ -357,9 +380,9 @@ int test__switch_tracking(int subtest __maybe_unused) > cpu_clocks_evsel = perf_evlist__last(evlist); > > /* Second event */ > - err = parse_events(evlist, "cycles:u", NULL); > + err = parse_events(evlist, hw_counter, NULL); > if (err) { > - pr_debug("Failed to parse event cycles:u\n"); > + pr_debug("Failed to parse event %s\n", hw_counter); > goto out_err; > } > > -- > 2.9.4