From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753177AbdGXTII (ORCPT ); Mon, 24 Jul 2017 15:08:08 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57393 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932321AbdGXTIC (ORCPT ); Mon, 24 Jul 2017 15:08:02 -0400 Date: Mon, 24 Jul 2017 12:07:55 -0700 From: Sukadev Bhattiprolu To: Andi Kleen Cc: Arnaldo Carvalho de Melo , Jiri Olsa , jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH] perf, tools: Make build fail on JSON parse error References: <20170721192557.4371-1-andi@firstfloor.org> <20170722003159.GA15787@us.ibm.com> <20170724141649.GA2645@krava> <20170724174209.GW4134@kernel.org> <20170724174454.GR3044@two.firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170724174454.GR3044@two.firstfloor.org> X-Operating-System: Linux 2.0.32 on an i486 User-Agent: Mutt/1.7.1 (2016-10-04) X-TM-AS-GCONF: 00 x-cbid: 17072419-0020-0000-0000-00000C6D5326 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007418; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00892320; UDB=6.00445990; IPR=6.00672484; BA=6.00005489; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016356; XFM=3.00000015; UTC=2017-07-24 19:08:00 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072419-0021-0000-0000-00005D655E99 Message-Id: <20170724190755.GD15787@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-24_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707240289 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andi Kleen [andi@firstfloor.org] wrote: > On Mon, Jul 24, 2017 at 02:42:09PM -0300, Arnaldo Carvalho de Melo wrote: > > Em Mon, Jul 24, 2017 at 04:16:49PM +0200, Jiri Olsa escreveu: > > > On Fri, Jul 21, 2017 at 05:31:59PM -0700, Sukadev Bhattiprolu wrote: > > > > Andi Kleen [andi@firstfloor.org] wrote: > > > > > From: Andi Kleen > > > > > > > > > > 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. > > > > > > > > I see the problem and we were being defensive to not break the build > > > > on architectures that don't yet have the PMU event lists. It will be > > > > good to check build on an architecture other than x86/powerpc. > > > > > > > > Also, following comments may no longer be applicable? > > > > > > Isn't the Andi's change only to fail in case there's > > > a real error in process_one_file? I think you can still > > > have empty events dir. > > > > That explains why all the cross builds failed when I added that cset? > > Hmm, let me test. It was supposed to only fail when there > is a file, but it cannot be parsed. Wonder if adding this check for event lists helps. --- diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index baa073f..4de5c87 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -840,6 +840,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) { @@ -861,11 +862,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 @@ -882,6 +889,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; } @@ -896,7 +906,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;