Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F8CAC43334 for ; Wed, 29 Jun 2022 18:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230271AbiF2SZd (ORCPT ); Wed, 29 Jun 2022 14:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbiF2SZc (ORCPT ); Wed, 29 Jun 2022 14:25:32 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AEED25EBD for ; Wed, 29 Jun 2022 11:25:31 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id n84-20020a25da57000000b0066d2ae53d18so4992182ybf.15 for ; Wed, 29 Jun 2022 11:25: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=1f0Ur6hbGyTYzxP4DvfGWl44AJTfod6EaR5IYzCVFo4=; b=tOoS6bbd/0Ckdjf3fUN9LHcpnfnrZf1cuEgEb8U6NMdaeoo3m6AcP5/ZsqFJk0mWPd gkn/0GGkbrvYcnYCGIauJfpVdxs3BT8FuMDBoSh86dg/XV3fFjIpuHg/hNo1ZPHEgVSN Jzxog92KnO6NOwEtKY7WN5rDk6VTXDkyETvGNnxjl8fEIQQVGuHqTvI5tb7KXr6Y/mt8 SELiyHcw3PSGPfCZnNFvrw4cdBRy10f3oqGdfiRjw2niWUbtMfh3dBgaxrnVlkoHLzWC ej1pbtNrXWjf7njSHMa0PcZqTDAzk6GTuhobAQfy+g/f8oj0UiAuZl5G7o/I4z+gw60f OxFg== 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=1f0Ur6hbGyTYzxP4DvfGWl44AJTfod6EaR5IYzCVFo4=; b=5HoHKrhjdauZspI6bRdG4Kb00LbUl96bbl/zUrXh8Iz9RwT3sPiLpfLvkm0QCsughV Ud1spgUc9b68LqVHKnXMkDlNgBrSQhoRETmT+7i2uXMgFw/ZbDkHMWxOh5jw9iI765JS HVCS8GQ7Z17mNE/aUoziq3+kszUpE7J0wnigSmGk/O+WkUKJ0cvwTVR030u4cuxLitz/ a32a4WcrnBRL0UkFpZFX0PrUAAKEApurTBd8aCbms7huRzUZdMn5Hei4LeWFi+75mx39 hdnERd8OLwuoDGPT/Q1DfJzJ0bgAdNleDelVGuE0ZzglpV5797dumLR54AiUVbk+gfIc g3AQ== X-Gm-Message-State: AJIora+VIKqVb1jv64KSrg60ShhkCSwEjmCSF3fyepLlxkbp8PfSOL1x vSQeqwf81SFK7n8w05vkcVzR7TcMNGyE X-Google-Smtp-Source: AGRyM1tE0QYu5xftU0kl9VWEzzxD6BkZj/8WgT0dTjS8P4XcNOoJyoarGWwbUmLqEjKpKr6Bms2W2lQ8nsFp X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:f5a1:84fb:df7d:bd89]) (user=irogers job=sendgmr) by 2002:a25:5c5:0:b0:66c:b809:ddde with SMTP id 188-20020a2505c5000000b0066cb809dddemr4885032ybf.67.1656527130312; Wed, 29 Jun 2022 11:25:30 -0700 (PDT) Date: Wed, 29 Jun 2022 11:25:01 -0700 Message-Id: <20220629182505.406269-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v7 0/4] 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" Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@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. v7. Adds Tested-by from John Garry . v6. Adds Tested-by from Zhengjun Xing and Thomas Richter . Fixes issues spotted by Jiri Olsa , jsmn.c wasn't deleted and the empty pmu-events.c didn't pass the pmu-events test. It also adds a missing mkdir which is necessary before creating pmu-events.c and tweaks the quiet display code in the empty case to display a gen. v5. Adds a 2>/dev/null as suggested by David Laight . v4. Fixes the build for systems with python2 installed by adding a patch that makes python3 the preferred python (Reported-by: John Garry ). It also fixes a bash-ism in the jevents-test.sh and fixes the handling of an empty string for a metric BriefDescription as one was added for sapphirerapids in the metric Execute. 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 (4): perf python: Prefer python3 perf jevents: Add python converter script perf jevents: Switch build to use jevents.py perf jevents: Remove jevents.c tools/perf/Makefile.config | 27 +- tools/perf/Makefile.perf | 16 +- tools/perf/pmu-events/Build | 17 +- tools/perf/pmu-events/empty-pmu-events.c | 158 +++ tools/perf/pmu-events/jevents.c | 1342 ---------------------- tools/perf/pmu-events/jevents.py | 409 +++++++ tools/perf/pmu-events/jsmn.c | 352 ------ tools/perf/pmu-events/jsmn.h | 68 -- tools/perf/pmu-events/json.c | 162 --- tools/perf/pmu-events/json.h | 39 - 10 files changed, 604 insertions(+), 1986 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.c 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.37.0.rc0.161.g10f37bed90-goog