From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751672AbdGZR2J (ORCPT ); Wed, 26 Jul 2017 13:28:09 -0400 Received: from terminus.zytor.com ([65.50.211.136]:40831 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbdGZR2G (ORCPT ); Wed, 26 Jul 2017 13:28:06 -0400 Date: Wed, 26 Jul 2017 10:26:54 -0700 From: tip-bot for Andi Kleen Message-ID: Cc: mingo@kernel.org, hpa@zytor.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, sukadev@linux.vnet.ibm.com, tglx@linutronix.de, jolsa@kernel.org, acme@redhat.com Reply-To: sukadev@linux.vnet.ibm.com, tglx@linutronix.de, jolsa@kernel.org, acme@redhat.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com In-Reply-To: <20170725001638.19990-1-andi@firstfloor.org> References: <20170725001638.19990-1-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf jevents: Make build fail on JSON parse error Git-Commit-ID: 3f056b66647bafc39f060a57289320765915972c X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 3f056b66647bafc39f060a57289320765915972c Gitweb: http://git.kernel.org/tip/3f056b66647bafc39f060a57289320765915972c Author: Andi Kleen AuthorDate: Mon, 24 Jul 2017 17:16:38 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 25 Jul 2017 22:46:36 -0300 perf jevents: Make build fail on JSON parse error 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 Acked-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Sukadev Bhattiprolu Link: http://lkml.kernel.org/r/20170725001638.19990-1-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- 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 1408ade..c2ee3e4 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 bd0aabb..2350f60 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;