linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Kim Phillips <kim.phillips@arm.com>,
	Ingo Molnar <mingo@kernel.org>,
	Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>, David Ahern <dsahern@gmail.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: Re: [PATCH 01/11] perf tests parse-events: Add intel_pt parse test
Date: Thu, 17 May 2018 22:58:11 +0200	[thread overview]
Message-ID: <20180517205811.GE12497@krava> (raw)
In-Reply-To: <20180517201553.GB25467@kernel.org>

On Thu, May 17, 2018 at 05:15:53PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, May 16, 2018 at 04:33:55PM -0500, Kim Phillips escreveu:
> > On Wed, 16 May 2018 11:48:58 -0300
> > Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > 
> > > From: Arnaldo Carvalho de Melo <acme@redhat.com>
> > > 
> > > To avoid regressions such as the one fixed by 4a35a9027f64 ("Revert
> > > "perf pmu: Fix pmu events parsing rule""), where '-e intel_pt//u' got
> > > broken, with this new entry in this 'perf tests' subtest, we would have
> > > caught it before pushing upstream.
> > > 
> > > Acked-by: Jiri Olsa <jolsa@kernel.org>
> > > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > > Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> > > Cc: Andi Kleen <ak@linux.intel.com>
> > > Cc: David Ahern <dsahern@gmail.com>
> > > Cc: Jiri Olsa <jolsa@kernel.org>
> > > Cc: Kan Liang <kan.liang@linux.intel.com>
> > > Cc: Namhyung Kim <namhyung@kernel.org>
> > > Cc: Peter Zijlstra <peterz@infradead.org>
> > > Cc: Wang Nan <wangnan0@huawei.com>
> > > Link: https://lkml.kernel.org/n/tip-kw62fys9bwdgsp722so2ln1l@git.kernel.org
> > > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > > ---
> > 
> > This causes a SEGV on Arm, and an Intel box without Intel-PT h/w:
> > 
> > (gdb) run test -F -v 6
> > Starting program: /home/kimphi01/git/linux-perf-acme/tools/perf/perf test -F -v 6
> > [Thread debugging using libthread_db enabled]
> > Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> >  6: Parse event definition strings             :
> > --- start ---
> > running test 0 'syscalls:sys_enter_openat'
> > Using CPUID GenuineIntel-6-3C
> > <SNIP>
> > running test 51 'L1-dcache-misses/name=cachepmu/'
> > running test 52 'intel_pt//u'
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > __GI___vasprintf_chk (result_ptr=0x8, flags=1, format=<optimized out>, args=args@entry=0x7fffffffbf30)
> >     at vasprintf_chk.c:88
> > 88	vasprintf_chk.c: No such file or directory.
> > (gdb) bt
> > #0  __GI___vasprintf_chk (result_ptr=0x8, flags=1, format=<optimized out>, args=args@entry=0x7fffffffbf30)
> >     at vasprintf_chk.c:88
> > #1  0x00007ffff6456e6f in __asprintf_chk (result_ptr=result_ptr@entry=0x8, flags=flags@entry=1, 
> >     format=format@entry=0x555555992e80 "Cannot find PMU `%s'. Missing kernel support?") at asprintf_chk.c:32
> > #2  0x0000555555766836 in asprintf (__fmt=0x555555992e80 "Cannot find PMU `%s'. Missing kernel support?", __ptr=0x8)
> >     at /usr/include/x86_64-linux-gnu/bits/stdio2.h:178
> > #3  parse_events_add_pmu (parse_state=parse_state@entry=0x7fffffffdda0, list=list@entry=0x555555e137d0, 
> >     name=0x5555563e84e0 "intel_pt", head_config=0x0, auto_merge_stats=auto_merge_stats@entry=false, 
> >     use_alias=use_alias@entry=false) at util/parse-events.c:1236
> 
> 
> Humm:
> 
>         struct parse_events_error *err = parse_state->error;
> 
>         pmu = perf_pmu__find(name);
>         if (!pmu) {
>                 if (asprintf(&err->str,
>                                 "Cannot find PMU `%s'. Missing kernel support?",
>                                 name) < 0)
> 
> $ pahole -C parse_events_error ~/bin/perf
> struct parse_events_error {
> 	int                        idx;                  /*     0     4 */
> 
> 	/* XXX 4 bytes hole, try to pack */
> 
> 	char *                     str;                  /*     8     8 */
> 	char *                     help;                 /*    16     8 */
> 
> 	/* size: 24, cachelines: 1, members: 3 */
> 	/* sum members: 20, holes: 1, sum holes: 4 */
> 	/* last cacheline: 24 bytes */
> };
> $
> 
> So parse_state->error == NULL, Jiri, ideas?

yep, we don't use it in tests.. and when trying intel_pt on
system without that pmu, the parse_events_add_pmu fails
and store the error to NULL.. we should check on that err pointer

wrt to the test itself, how about we add callback
to check if the test is valid before we run it,
something like below
jirka



---
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 6829dd416a99..8efefead2c04 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1309,6 +1309,11 @@ static int test__checkevent_config_cache(struct perf_evlist *evlist)
 	return 0;
 }
 
+static bool test__intel_pt_valid(void)
+{
+	return !!perf_pmu__find("intel_pt");
+}
+
 static int test__intel_pt(struct perf_evlist *evlist)
 {
 	struct perf_evsel *evsel = perf_evlist__first(evlist);
@@ -1374,6 +1379,7 @@ struct evlist_test {
 	const char *name;
 	__u32 type;
 	const int id;
+	bool (*valid)(void);
 	int (*check)(struct perf_evlist *evlist);
 };
 
@@ -1647,6 +1653,7 @@ static struct evlist_test test__events[] = {
 	},
 	{
 		.name  = "intel_pt//u",
+		.valid = test__intel_pt_valid,
 		.check = test__intel_pt,
 		.id    = 52,
 	},
@@ -1685,17 +1692,23 @@ static struct terms_test test__terms[] = {
 
 static int test_event(struct evlist_test *e)
 {
+	struct parse_events_error err;
 	struct perf_evlist *evlist;
 	int ret;
 
+	if (e->valid && !e->valid()) {
+		pr_debug("... SKIP");
+		return 0;
+	}
+
 	evlist = perf_evlist__new();
 	if (evlist == NULL)
 		return -ENOMEM;
 
-	ret = parse_events(evlist, e->name, NULL);
+	ret = parse_events(evlist, e->name, &err);
 	if (ret) {
-		pr_debug("failed to parse event '%s', err %d\n",
-			 e->name, ret);
+		pr_debug("failed to parse event '%s', err %d, str '%s'\n",
+			 e->name, ret, err.str);
 	} else {
 		ret = e->check(evlist);
 	}
@@ -1713,10 +1726,11 @@ static int test_events(struct evlist_test *events, unsigned cnt)
 	for (i = 0; i < cnt; i++) {
 		struct evlist_test *e = &events[i];
 
-		pr_debug("running test %d '%s'\n", e->id, e->name);
+		pr_debug("running test %d '%s'", e->id, e->name);
 		ret1 = test_event(e);
 		if (ret1)
 			ret2 = ret1;
+		pr_debug("\n");
 	}
 
 	return ret2;
@@ -1798,7 +1812,7 @@ static int test_pmu_events(void)
 	}
 
 	while (!ret && (ent = readdir(dir))) {
-		struct evlist_test e;
+		struct evlist_test e = { };
 		char name[2 * NAME_MAX + 1 + 12 + 3];
 
 		/* Names containing . are special and cannot be used directly */

  reply	other threads:[~2018-05-17 20:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16 14:48 [GIT PULL 00/11] perf/core improvements and fixes Arnaldo Carvalho de Melo
2018-05-16 14:48 ` [PATCH 01/11] perf tests parse-events: Add intel_pt parse test Arnaldo Carvalho de Melo
2018-05-16 21:33   ` Kim Phillips
2018-05-17 20:15     ` Arnaldo Carvalho de Melo
2018-05-17 20:58       ` Jiri Olsa [this message]
2018-05-17 22:54         ` Kim Phillips
2018-05-18 14:13           ` Arnaldo Carvalho de Melo
2018-05-16 14:48 ` [PATCH 02/11] perf buildid-cache: Warn --purge-all failures Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 03/11] perf llvm-utils: Add bpf include path to clang command line Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 04/11] perf bpf: Add 'examples' directories Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 05/11] perf bpf: Add bpf.h to be used in eBPF proggies Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 06/11] perf bpf: Add kprobe example to catch 5s naps Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 07/11] perf bpf: Add license(NAME) helper Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 08/11] perf bpf: Add probe() helper to reduce kprobes boilerplate Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 09/11] perf tools: Use the "_stest" symbol to identify the kernel map when loading kcore Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 10/11] perf parse-events: Handle uncore event aliases in small groups properly Arnaldo Carvalho de Melo
2018-05-16 14:49 ` [PATCH 11/11] perf bpf: Fix NULL return handling in bpf__prepare_load() Arnaldo Carvalho de Melo
2018-05-16 15:58 ` [GIT PULL 00/11] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180517205811.GE12497@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=kim.phillips@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=wangnan0@huawei.com \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).