Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1697185

[PATCH 38/40] perf jevents: Make build fail on JSON parse error

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 38/40] perf jevents: Make build fail on JSON parse error
Date 2017-07-26 16:30 +0200
Message-ID <u7vu2-1s1-33@gated-at.bofh.it> (permalink)
References <u7vkm-1ob-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Andi Kleen <ak@linux.intel.com>

Today, when a JSON file fails parsing the build continues, but there are
no json files built in, which is difficult to debug later.  Make the
build stop on a parse error instead.

v2: Add fixes from Sukadev. Now we handle architectures
    with no JSON events correctly. And fix some stale comments.

Committer note:

Tested by running the cross build container tests, that were all failing
for v1.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20170725001638.19990-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/pmu-events/README    |  4 ----
 tools/perf/pmu-events/jevents.c | 21 ++++++++++++++-------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tools/perf/pmu-events/README b/tools/perf/pmu-events/README
index 1408ade0d773..c2ee3e4417fe 100644
--- a/tools/perf/pmu-events/README
+++ b/tools/perf/pmu-events/README
@@ -85,10 +85,6 @@ users to specify events by their name:
 
 where 'pm_1plus_ppc_cmpl' is a Power8 PMU event.
 
-In case of errors when processing files in the tools/perf/pmu-events/arch
-directory, 'jevents' tries to create an empty mapping file to allow the perf
-build to succeed even if the PMU event aliases cannot be used.
-
 However some errors in processing may cause the perf build to fail.
 
 Mapfile format
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index bd0aabb2bd0f..2350f6099a46 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -822,10 +822,6 @@ static int process_one_file(const char *fpath, const struct stat *sb,
  * PMU event tables (see struct pmu_events_map).
  *
  * Write out the PMU events tables and the mapping table to pmu-event.c.
- *
- * If unable to process the JSON or arch files, create an empty mapping
- * table so we can continue to build/use  perf even if we cannot use the
- * PMU event aliases.
  */
 int main(int argc, char *argv[])
 {
@@ -836,6 +832,7 @@ int main(int argc, char *argv[])
 	const char *arch;
 	const char *output_file;
 	const char *start_dirname;
+	struct stat stbuf;
 
 	prog = basename(argv[0]);
 	if (argc < 4) {
@@ -857,11 +854,17 @@ int main(int argc, char *argv[])
 		return 2;
 	}
 
+	sprintf(ldirname, "%s/%s", start_dirname, arch);
+
+	/* If architecture does not have any event lists, bail out */
+	if (stat(ldirname, &stbuf) < 0) {
+		pr_info("%s: Arch %s has no PMU event lists\n", prog, arch);
+		goto empty_map;
+	}
+
 	/* Include pmu-events.h first */
 	fprintf(eventsfp, "#include \"../../pmu-events/pmu-events.h\"\n");
 
-	sprintf(ldirname, "%s/%s", start_dirname, arch);
-
 	/*
 	 * The mapfile allows multiple CPUids to point to the same JSON file,
 	 * so, not sure if there is a need for symlinks within the pmu-events
@@ -878,6 +881,9 @@ int main(int argc, char *argv[])
 	if (rc && verbose) {
 		pr_info("%s: Error walking file tree %s\n", prog, ldirname);
 		goto empty_map;
+	} else if (rc < 0) {
+		/* Make build fail */
+		return 1;
 	} else if (rc) {
 		goto empty_map;
 	}
@@ -892,7 +898,8 @@ int main(int argc, char *argv[])
 
 	if (process_mapfile(eventsfp, mapfile)) {
 		pr_info("%s: Error processing mapfile %s\n", prog, mapfile);
-		goto empty_map;
+		/* Make build fail */
+		return 1;
 	}
 
 	return 0;
-- 
2.9.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/40] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:20 +0200
  [PATCH 15/40] tools include: Adopt strstarts() from the kernel Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:20 +0200
  [PATCH 30/40] perf script: Remove some bogus error handling Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 39/40] perf annotate stdio: Fix column header when using --show-total-period Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 33/40] perf script python: Add sample_read to dict Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 22/40] perf annotate stdio: Fix --show-total-period Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 40/40] perf tools: Add tools/include/uapi/asm-generic/fcntl.h to the MANIFEST Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 38/40] perf jevents: Make build fail on JSON parse error Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 36/40] perf report: Make --branch-history work without callgraphs(-g) option in perf record Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 26/40] perf annotate: Process tracing data in pipe mode Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 29/40] perf top: Support lookup of symbols in other mount namespaces. Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 32/40] perf script python: Refactor creation of perf sample dict Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 23/40] perf report: Fix kernel symbol adjustment for s390x Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 28/40] perf evsel: Add verbose output for sys_perf_event_open fallback Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 35/40] perf script python: Generate hooks with additional argument Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 21/40] perf annotate: Do not overwrite sample->period Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 27/40] perf jvmti: Fix linker error when libelf config is disabled Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 31/40] perf script python: Allocate memory only if handler exists Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 34/40] perf script python: Add perf_sample dict to tracepoint handlers Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 25/40] perf tools: Add EXCLUDE_EXTLIBS and EXTRA_PERFLIBS to makefile Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 24/40] perf cgroup: Fix refcount usage Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 37/40] perf report: Tag branch type/flag on "to" and tag cycles on "from" Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
  [PATCH 03/40] perf trace: Add missing ' = ' in the default formatting of syscall returns Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
  [PATCH 05/40] perf trace: Allow allocating sc->arg_fmt even without the syscall tracepoint Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
  [PATCH 01/40] perf intel-pt: Set no_aux_samples for the tracking event Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
  [PATCH 04/40] perf trace beauty mmap: Ignore 'fd' and 'offset' args for MAP_ANONYMOUS Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
  [PATCH 17/40] perf annotate: Introduce struct sym_hist_entry Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
  Re: [GIT PULL 00/40] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2017-07-26 19:20 +0200

csiph-web