Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2399337ioo; Sat, 28 May 2022 12:24:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIDvCS6119/d9azEXQ/VgiLQ4E8FOlKhgDpm0jBh0J1bAIRA7EME+HHeJn2oBIX7PeD6yY X-Received: by 2002:a63:8048:0:b0:3fb:d725:977b with SMTP id j69-20020a638048000000b003fbd725977bmr3407383pgd.579.1653765842576; Sat, 28 May 2022 12:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653765842; cv=none; d=google.com; s=arc-20160816; b=ecmgvzthQpannWbZ7hTGJa3uWGCikq89TEK1QbOpMsylx+37HlsUdh1cTlT1CJz4rd vRu8nT/l3QnGD1xyGGHum+GIf+E23BlEnu12FwymzhIFTC3McedlRFw/UoX8Ii0iuUEE 3Szq+t1TGvdowsrbLkzzjJ37t67wWfxaNQZHWr7/8bkyKkCWKyCQW84POrxF2j+LTFR5 ghD3ozs+aJOkU3D2WOggffPRhLOn6e1x17kDTWa10Z+diisETQRkfoMzbstCU+p8JrMQ hXxjyKdz9BBiMAxeS7gsT1C2HbfrkpFHcaMKNa2qV9/gC1bzUsGMQPzactIEqzPdejEY WpJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=3jMHuEWZEVTgcKAyUiSFGjXQFMoZWUz11fN75aDaI5g=; b=EeoKvv+z6DaJyjaTyX/hAr2+FGL+tpKk9gicM2OuaGqGoUNDx/9RuSdG8VdaifCNz4 mWlIaSNaJRfg0yjoGGz1hHqUOFeWFmBVqayhrKG7fkHC4kTOmMOvHb4Tqegb2EnwR+PB R+mimXSta33OMzfPDGy9sTlG7yxY2fWpwPl8prSMs9E6fdjjfHKsNBTweFZpQQuh0zFq nXzBqgClsm2ayCFmK96C12i4GkyIPmYqyOk4CEDvSin8DZpZcJcY4Za8sln+NaFlatfY Pcu8141zSii0T2FL+Ou2pmIPrS/kKr/bhrm6ZI2+Hj33gr7PzEpW4qKAP0H87kKdzA1b wLYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PxCLRYqh; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v1-20020a17090a6b0100b001e00edc0c6csi6464254pjj.121.2022.05.28.12.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:24:02 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PxCLRYqh; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 40D694D618; Sat, 28 May 2022 11:54:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354181AbiE0Syf (ORCPT + 99 others); Fri, 27 May 2022 14:54:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242227AbiE0Syd (ORCPT ); Fri, 27 May 2022 14:54:33 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2904C7BB for ; Fri, 27 May 2022 11:54:31 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-30047b94aa8so46349007b3.1 for ; Fri, 27 May 2022 11:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=3jMHuEWZEVTgcKAyUiSFGjXQFMoZWUz11fN75aDaI5g=; b=PxCLRYqhvE0DZtFglnz62+sCDB4Vt4NUyo32ldkQ9A4c30DDh9X7Ky2Cn0gZ2jZGlf LPFxoj5yNFHsk751cMTkU4oy95xOVOiLwNni8YZ6lz0yrQa/SXfA/KuKju2FyAS94Cxg PT7m+vJf5JuN/a0EKoiHrzd+ZaeXLz32zehfaIMKbJPRjzX68tSjGvKOldAAMSsZF4fR qHAnd/x4pbCMWZknMQtHKOSe1XssAzQPhiulOg+eexRjpCLUdofNviv3onjrF/GlgNIe rVn6rhf7MlGoGN3vgaMKz9hMR8Fir1Hyr458x2gBlM7WThVueUuugonnuOkYjX/wicQa IYDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=3jMHuEWZEVTgcKAyUiSFGjXQFMoZWUz11fN75aDaI5g=; b=22bTPzh63IdhsW4rHJgBvPDLYoi0NYVUdIPqYt9lgPju5APTsLdz/AWj0OfuYfB1Cy JisynDevZX1c3ed5Urg/j7bYFYnujdbRz9dl6TcKkdSeiSduO0M042xFZi1VHrjZC8ge YSxAu87Kn5BgqQm0sV1vsFZWiP1qej/+TYMDsLCldVmr7x4RsdeWTzU5r4kLrAxpze0t 9bvPKwDfPEbXwS3SG7Y3IU54o7in42rVI4C2Nw/fR2bjGijN7GC09l+9Q6G1vE64OU6Y J2Rp2oW66/McCl2INZ+mHCsGciCAMfHb4DFbBkwWK911cZ/rkSyGtbG0hPn8kt7OxVo8 2u2g== X-Gm-Message-State: AOAM5326zPX061VVl+qQSr7fnwL86alxcjJxfJkhcQZCRpHprVDm/PV7 SX39x/MBvQENnxh3F6jtmhKb+7Y+lMz4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:ed8f:39b4:b259:40ef]) (user=irogers job=sendgmr) by 2002:a25:d89:0:b0:65c:6714:71c1 with SMTP id 131-20020a250d89000000b0065c671471c1mr11197ybn.226.1653677670143; Fri, 27 May 2022 11:54:30 -0700 (PDT) Date: Fri, 27 May 2022 11:54:23 -0700 Message-Id: <20220527185426.240235-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog Subject: [PATCH v3 0/3] Rewrite jevents program in python From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Kan Liang , Andi Kleen , Zhengjun Xing , Felix Fietkau , Qi Liu , Like Xu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Nick Forrington , Kajol Jain , James Clark , Andrew Kilroy , "Paul A . Clarke" , Will Deacon , Mathieu Poirier , ananth.narayan@amd.com, ravi.bangoria@amd.com, santosh.shukla@amd.com, sandipan.das@amd.com, Caleb Biggers , Perry Taylor , Kshipra Bopardikar Cc: Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org New architectures bring new complexity, such as Intel's hybrid models. jevents provides an alternative to specifying events in the kernel and exposing them through sysfs, however, it is difficult to work with. For example, an error in the json input would yield an error message but no json file or location. It is also a challenge to update jsmn.c given its forked nature. The changes here switch from jevents.c to a rewrite in python called jevents.py. This means there is a build time dependency on python, but such a dependency already exists for asciidoc (used to generate perf's man pages). If the build detects that python isn't present or is older than version 3.6 (released Dec. 2016) then an empty file is substituted for the generated one. A challenge with this code is in avoiding regressions. For this reason the jevents.py produces identical output to jevents.c, validated with a test script and build target. v3. Updates the patches for merged changes (on acme/tmp.perf/core). Re-runs all comparisons to make sure the generated pmu-events.c isn't altered at all by this change. Adds the jevents.c ExtSel fix in: https://lore.kernel.org/lkml/20220525140410.1706851-1-zhengjun.xing@linux.intel.com/ Bumps the python version from 3.5 to 3.6, as f-strings weren't introduced until 3.6. v2. Fixes the build for architectures that don't have pmu-events json (Suggested-by: John Garry ) and fixes the build for python not being present or too old (Suggested-by: Peter Zijlstra /John Garry ). Ian Rogers (3): perf jevents: Add python converter script perf jevents: Switch build to use jevents.py perf jevents: Remove jevents.c tools/perf/Makefile.config | 19 + tools/perf/Makefile.perf | 16 +- tools/perf/pmu-events/Build | 15 +- tools/perf/pmu-events/empty-pmu-events.c | 21 + tools/perf/pmu-events/jevents.c | 1342 ---------------------- tools/perf/pmu-events/jevents.py | 392 +++++++ tools/perf/pmu-events/jsmn.h | 68 -- tools/perf/pmu-events/json.c | 162 --- tools/perf/pmu-events/json.h | 39 - 9 files changed, 444 insertions(+), 1630 deletions(-) create mode 100644 tools/perf/pmu-events/empty-pmu-events.c delete mode 100644 tools/perf/pmu-events/jevents.c create mode 100755 tools/perf/pmu-events/jevents.py delete mode 100644 tools/perf/pmu-events/jsmn.h delete mode 100644 tools/perf/pmu-events/json.c delete mode 100644 tools/perf/pmu-events/json.h -- 2.36.1.255.ge46751e96f-goog