From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>, Kajol Jain <kjain@linux.ibm.com>,
Andi Kleen <ak@linux.intel.com>,
John Garry <john.garry@huawei.com>,
Jin Yao <yao.jin@linux.intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Kim Phillips <kim.phillips@amd.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Leo Yan <leo.yan@linaro.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, Stephane Eranian <eranian@google.com>,
Paul Clarke <pc@us.ibm.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH v3 6/7] perf test: Improve pmu event metric testing
Date: Tue, 19 May 2020 16:06:02 -0300 [thread overview]
Message-ID: <20200519190602.GB28228@kernel.org> (raw)
In-Reply-To: <20200515221732.44078-7-irogers@google.com>
Em Fri, May 15, 2020 at 03:17:31PM -0700, Ian Rogers escreveu:
> Break pmu-events test into 2 and add a test to verify that all pmu
> metric expressions simply parse. Try to parse all metric ids/events,
> skip/warn if metrics for the current architecture fail to parse. To
> support warning for a skip, and an ability for a subtest to describe why
> it skips.
>
> Tested on power9, skylakex, haswell, broadwell, westmere, sandybridge and
> ivybridge.
>
> May skip/warn on other architectures if metrics are invalid. In
> particular s390 is untested, but its expressions are trivial. The
> untested architectures with expressions are power8, cascadelakex,
> tremontx, skylake, jaketown, ivytown and variants of haswell and
> broadwell.
>
> v3. addresses review comments from John Garry <john.garry@huawei.com>,
> Jiri Olsa <jolsa@redhat.com> and Arnaldo Carvalho de Melo
> <acme@kernel.org>.
> v2. changes the commit message as event parsing errors no longer cause
> the test to fail.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Jin Yao <yao.jin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: John Garry <john.garry@huawei.com>
> Cc: Kajol Jain <kjain@linux.ibm.com>
> Cc: Kan Liang <kan.liang@linux.intel.com>
> Cc: Leo Yan <leo.yan@linaro.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Clarke <pc@us.ibm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Stephane Eranian <eranian@google.com>
> Link: http://lore.kernel.org/lkml/20200513212933.41273-1-irogers@google.com
> [ split from a larger patch ]
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
> tools/perf/tests/builtin-test.c | 7 ++
> tools/perf/tests/pmu-events.c | 168 ++++++++++++++++++++++++++++++--
> tools/perf/tests/tests.h | 3 +
> 3 files changed, 172 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index baee735e6aa5..9553f8061772 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -75,6 +75,13 @@ static struct test generic_tests[] = {
> {
> .desc = "PMU events",
> .func = test__pmu_events,
> + .subtest = {
> + .skip_if_fail = false,
> + .get_nr = test__pmu_events_subtest_get_nr,
> + .get_desc = test__pmu_events_subtest_get_desc,
> + .skip_reason = test__pmu_events_subtest_skip_reason,
> + },
> +
> },
> {
> .desc = "DSO data read",
> diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
> index d64261da8bf7..e21f0addcfbb 100644
> --- a/tools/perf/tests/pmu-events.c
> +++ b/tools/perf/tests/pmu-events.c
> @@ -8,6 +8,9 @@
> #include <linux/zalloc.h>
> #include "debug.h"
> #include "../pmu-events/pmu-events.h"
> +#include "util/evlist.h"
> +#include "util/expr.h"
> +#include "util/parse-events.h"
>
> struct perf_pmu_test_event {
> struct pmu_event event;
> @@ -144,7 +147,7 @@ static struct pmu_events_map *__test_pmu_get_events_map(void)
> }
>
> /* Verify generated events from pmu-events.c is as expected */
> -static int __test_pmu_event_table(void)
> +static int test_pmu_event_table(void)
> {
> struct pmu_events_map *map = __test_pmu_get_events_map();
> struct pmu_event *table;
> @@ -347,14 +350,11 @@ static int __test__pmu_event_aliases(char *pmu_name, int *count)
> return res;
> }
>
> -int test__pmu_events(struct test *test __maybe_unused,
> - int subtest __maybe_unused)
> +
> +static int test_aliases(void)
> {
> struct perf_pmu *pmu = NULL;
>
> - if (__test_pmu_event_table())
> - return -1;
> -
> while ((pmu = perf_pmu__scan(pmu)) != NULL) {
> int count = 0;
>
> @@ -377,3 +377,159 @@ int test__pmu_events(struct test *test __maybe_unused,
>
> return 0;
> }
> +
> +static bool is_number(const char *str)
> +{
> + char *end_ptr;
> +
> + strtod(str, &end_ptr);
> + return end_ptr != str;
> +}
So, this breaks in some systems:
cc1: warnings being treated as errors
tests/pmu-events.c: In function 'is_number':
tests/pmu-events.c:385: error: ignoring return value of 'strtod', declared with attribute warn_unused_result
mv: cannot stat `/tmp/build/perf/tests/.pmu-events.o.tmp': No such file or director
So I'm changing it to verify the result of strtod() which is, humm,
interesting, please check:
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 3de59564deb0..6c58c3a89e6b 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
+#include "math.h"
#include "parse-events.h"
#include "pmu.h"
#include "tests.h"
@@ -381,8 +382,12 @@ static int test_aliases(void)
static bool is_number(const char *str)
{
char *end_ptr;
+ double v;
- strtod(str, &end_ptr);
+ errno = 0;
+ v = strtod(str, &end_ptr);
+ if ((errno == ERANGE && (v == HUGE_VAL || v == -HUGE_VAL)) || (errno != 0 && v == 0.0))
+ return false;
return end_ptr != str;
}
next prev parent reply other threads:[~2020-05-19 19:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-15 22:17 [PATCH v3 0/7] Copy hashmap to tools/perf/util, use in perf expr Ian Rogers
2020-05-15 22:17 ` [PATCH v3 1/7] libbpf: Fix memory leak and possible double-free in hashmap__clear Ian Rogers
2020-05-15 22:17 ` [PATCH v3 2/7] libbpf hashmap: Remove unused #include Ian Rogers
2020-05-15 22:17 ` [PATCH v3 3/7] libbpf hashmap: Fix signedness warnings Ian Rogers
2020-05-15 22:17 ` [PATCH v3 4/7] tools lib/api: Copy libbpf hashmap to tools/perf/util Ian Rogers
2020-05-15 22:17 ` [PATCH v3 5/7] perf test: Provide a subtest callback to ask for the reason for skipping a subtest Ian Rogers
2020-05-15 22:17 ` [PATCH v3 6/7] perf test: Improve pmu event metric testing Ian Rogers
2020-05-19 19:06 ` Arnaldo Carvalho de Melo [this message]
2020-05-19 20:15 ` Ian Rogers
2020-05-20 1:15 ` Arnaldo Carvalho de Melo
2020-05-20 2:34 ` Arnaldo Carvalho de Melo
2020-05-15 22:17 ` [PATCH v3 7/7] perf expr: Migrate expr ids table to a hashmap Ian Rogers
2020-05-18 15:45 ` Arnaldo Carvalho de Melo
2020-05-18 16:03 ` Ian Rogers
2020-05-18 16:06 ` Arnaldo Carvalho de Melo
2020-05-18 16:11 ` Arnaldo Carvalho de Melo
2020-05-18 16:29 ` Ian Rogers
2020-05-19 19:28 ` Arnaldo Carvalho de Melo
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=20200519190602.GB28228@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=john.fastabend@gmail.com \
--cc=john.garry@huawei.com \
--cc=jolsa@redhat.com \
--cc=kafai@fb.com \
--cc=kan.liang@linux.intel.com \
--cc=kim.phillips@amd.com \
--cc=kjain@linux.ibm.com \
--cc=kpsingh@chromium.org \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pc@us.ibm.com \
--cc=peterz@infradead.org \
--cc=songliubraving@fb.com \
--cc=xiyou.wangcong@gmail.com \
--cc=yao.jin@linux.intel.com \
--cc=yhs@fb.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).