Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2202770pxb; Fri, 8 Oct 2021 03:07:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKahI+LRN5HEZvv1ukKk7Yo/QdCYGQ5HMqMagP3DsIdDSMEJz8P78Z5vC6G2fpfjMED+qL X-Received: by 2002:a17:906:d0ca:: with SMTP id bq10mr3116954ejb.25.1633687635255; Fri, 08 Oct 2021 03:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633687635; cv=none; d=google.com; s=arc-20160816; b=asoOn8m3nXWm/xLOKuq5fnFQd+3uPuue3sflyn4wTSKvXu/hNlSOLfdCCcVYByCojm mRWxf4YHZ+3j35Gv0K7n+vTjdTW4I7ZpJb5UbNU8/ce4D3f1G5pPKNd16w+YeCCNE2wj yiIyk3I4SfjZY0Dl5gSWbn+/RiEbT+Hw41RMfwo/pRZf047WC1hPnCbKxnSABcUUPEOc 13x74KuvEjofDc5groTy4KPWq+rDzdzBMxFvxaoZJ8EZY6058K07C+Z+HgKhlEe+TuTX +NQkFPm2oS1R4ZujySqZz37TSFQvMS6iCZqjJYsD/H2yh1RDcMx4HEnn+kqQ6yjNcu14 KrCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=aEyU9wRPys42W7RRKEAvp0rmcdnuToqbJkLTHkBvPKQ=; b=01StQzOq3wDpdZVx/qE4PuQ+IPCUVThUZaZE+xxwdMDc8oebap1FYQNwkrmyFIv5O9 ZM7HlxQ93svOTqpbI5EjWujkyOX2Pj6yMAQiBh0JuV4N4dFTtP6nq5/cB0fZxb1l0VLr egfbb8LCs6n5NO3zUwbS9R2HqIrXfQnscYw0XXVXn7zKJJu79H7RGTI2TQAnYqRG+Wun 9tby0grJuXxIeL3fN+t2zlr+KgZSaJSkEYrGO2lDHrdQRjFpd6gRzCqtdyd6pB4tqYR0 WbowMNgvNgwV7Oy6P5R69uIlxaEmEvMBVkBD7Bin2QqCmJGwGFOAC/o534lIzaBtqfwe oZbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si2884466ejm.314.2021.10.08.03.06.50; Fri, 08 Oct 2021 03:07:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239501AbhJHKEW (ORCPT + 99 others); Fri, 8 Oct 2021 06:04:22 -0400 Received: from foss.arm.com ([217.140.110.172]:39688 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239606AbhJHKES (ORCPT ); Fri, 8 Oct 2021 06:04:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5431FD6E; Fri, 8 Oct 2021 03:02:22 -0700 (PDT) Received: from [10.57.25.67] (unknown [10.57.25.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2DD373F70D; Fri, 8 Oct 2021 03:02:20 -0700 (PDT) Subject: Re: [PATCH 0/3] perf tools: Enable strict JSON parsing To: kajoljain , acme@kernel.org, john.garry@huawei.com, ak@linux.intel.com, linux-perf-users@vger.kernel.org Cc: Nick.Forrington@arm.com, Andrew.Kilroy@arm.com, Will Deacon , Mathieu Poirier , Leo Yan , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20211007110543.564963-1-james.clark@arm.com> From: James Clark Message-ID: Date: Fri, 8 Oct 2021 11:02:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/10/2021 08:43, kajoljain wrote: > > > On 10/7/21 4:35 PM, James Clark wrote: >> After a discussion on "[PATCH 1/4] perf vendor events: Syntax corrections in Neoverse N1 json", >> John Garry suggested that we can just modify the parser to make it more strict. Hopefully this will >> remove the need to apply any future JSON comma fixup commits. >> >> Applies on top of "[PATCH v2 1/3] perf vendor events: Syntax corrections in Neoverse N1 json" on >> perf/core. >> >> Also available at: >> git clone --branch james-json-parse-fix git@git.gitlab.arm.com:linux-arm/linux-jc.git > > Hi James, > Do we have any dependency patches on top of this patch series. I am > reviewing and testing it, but in both powerpc and x86 system I am > getting build issue. Not sure if I am missing something> > I am trying your changes on top of upstream perf. > > pmu-events/arch/test/test_soc/sys/uncore.json: json error Invalid > character inside JSON string Hi Kajol, A trailing comma was fixed in this file 3 weeks ago at b8b350a. Can you confirm if you have updated to get this commit on perf core? Alternately you could pull from my branch above which is up to date enough to include it. The file is in pmu-events/arch/test/ so I would expect it to fail on all platforms. > make[3]: *** [pmu-events/Build:18: pmu-events/pmu-events.c] Error 1 > make[3]: *** Deleting file 'pmu-events/pmu-events.c' > make[2]: *** [Makefile.perf:667: pmu-events/pmu-events-in.o] Error 2 > make[2]: *** Waiting for unfinished jobs.... > make[1]: *** [Makefile.perf:238: sub-make] Error 2 > make: *** [Makefile:70: all] Error 2 > > Also, Is it possible to add line number along with file name while > showing this error `json error Invalid character inside JSON string`. > It might make it easy to fix. I can add a character number with the following fix if you think that would be good enough? A line number might be a bigger change and involve keeping track of newline characters. diff --git a/tools/perf/pmu-events/json.c b/tools/perf/pmu-events/json.c index 0544398d6e2d..41a14e1543bf 100644 --- a/tools/perf/pmu-events/json.c +++ b/tools/perf/pmu-events/json.c @@ -99,7 +99,7 @@ jsmntok_t *parse_json(const char *fn, char **map, size_t *size, int *len) res = jsmn_parse(&parser, *map, *size, tokens, sz / sizeof(jsmntok_t)); if (res != JSMN_SUCCESS) { - pr_err("%s: json error %s\n", fn, jsmn_strerror(res)); + pr_err("%s: json error at character %u '%s'\n", fn, parser.pos, jsmn_strerror(res)); goto error_free; } if (len) It prints this for the same error you have above: pmu-events/arch/test/test_soc/sys/uncore.json: json error at character 213 'Invalid character inside JSON string' Although funnily enough after re-introducing that extra comma it doesn't fail the build for me, it just prints the error message. But I may have noticed some dependency tracking issues around the json files. James