Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6668773iob; Wed, 11 May 2022 02:44:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWcF+3WlQxQL6ULp47s7KjA2C4qCoUb6Ri6gHSgBfMEXa9sWbm4o4dMpF6QYziow0tpDAl X-Received: by 2002:a17:907:8a17:b0:6f4:4b56:f550 with SMTP id sc23-20020a1709078a1700b006f44b56f550mr24237175ejc.720.1652262292210; Wed, 11 May 2022 02:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652262292; cv=none; d=google.com; s=arc-20160816; b=D/5wHzqhtVKAyoab62lDsajR0zVxOnu4ereg6L5SEBW/ssWzmcXaiMWElweVOvovR1 +ik5zSKZIbcywqa1/bdc2NYHx/0CJo6vbf9YKfLJsL7S9jG9Kyi/YYdE6bQZ4WQg1edq QtVp8IaQc6SSJA20Odj4AQZZ1PXKLcWTN4Pq33NsTHcTZZDkdtTflM+NPU/BhJDqCwp7 iX39+obKLx1MKEVqCkoYj3zfTL9SMrjHreVbKcw7AGzCXcKi6sWWRAQwc4vnpoBHhKfl iBaPyh9na3sDpKi2fxQ4EF6o9r1tUTwqStzbU9/3b77qG0HYoPiJ1OtQ7PnufYcZJbJd ScSg== 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=NAsDtBmU2OgI3N2OOYVSrhImShkhZd5HyHIxRIc0E/4=; b=E/Pi9+gaJvtavGThm6HWtXCSFUTTQ4fgTWlaynTfCJQ1yVa8l9xR+VIlVhj81bYA35 +9OyCqbD5Opc8ygsNmuQkSI377YB3sYZ5Ifbxhl5N3MIyKFuyhLTjY2NUnHxl1SB1Zm/ dPTJvdo95TgtoT0KBvnh4CiJijZ2WbIzaj9PcrsPlnUot0jBbGbjiOoX3s4n6e6TjNIU 1oI5UtYjLo8vP8VfRuvgGaD9y7QF4PeDwTDvjtmcuH+b+w6BzOAm8DybFIOmoyfi1UOs /H8xwH0ingMlGW8fEXuoPomEO7izxhVZ3wMs+l+oC4wfJ9njjw26hlljgahhKKP6v1Jv OHZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=U8RCrW8+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020a056402034400b00425ab11333csi1654775edw.428.2022.05.11.02.44.25; Wed, 11 May 2022 02:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=U8RCrW8+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242467AbiEKHBw (ORCPT + 99 others); Wed, 11 May 2022 03:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242416AbiEKHBl (ORCPT ); Wed, 11 May 2022 03:01:41 -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 7D45E56405 for ; Wed, 11 May 2022 00:01:38 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f4dfd09d7fso10472077b3.0 for ; Wed, 11 May 2022 00:01:38 -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=NAsDtBmU2OgI3N2OOYVSrhImShkhZd5HyHIxRIc0E/4=; b=U8RCrW8+Yjn/wgcQOIYzzbAstXL9qyLNQ2FILySewotlZ1IO849+9WLjTbiNuCX8Er Ij9OQ35Qp20XpJUf6mROtP5zM+ndT6BOTe7nK5AQtUvfSm9XxSPuBW5mCTh9t4JWk98J Q4FmNAc/r0Z0FhOeFM+b8unLyApQCsb96U2/uM5emYaD5Dfh9XEcPSnyFAa2VZJi6YHU Cda0T9KALbpdEUAVtOV6BIHCMDE0UHkK1mer694Uqf9ekzKCkyWmudaj39y+I82o9FRM XAKOJnMKuJstgcdJ2bP1ImVc/X/mYPff0JvAuzgVtCXJE3Jw2DEW7HypOlNZnvDIZAsH F3WQ== 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=NAsDtBmU2OgI3N2OOYVSrhImShkhZd5HyHIxRIc0E/4=; b=f3SjHlP1vIeM2TPF23iv7T8GNpHO/LP2Vba6+oupY3yehxr26aq88yRVUhxljIke75 1yhtsfBzNQ1TYS7edux5F7OUDIkw6ZUpBrxONnyDydeEJBTCYKnZTD/fXhXluUjfHTb7 AJGI6DLm50zxQguNlznbzvll8KBmBHSB9xiqKm9jiHHDf7OCItwqtgrjAse6LD9M3RbV 2FkqpJvAhctxnRH1XnXWGCqEKWq9AMGYRadjMrMbSG1xDoyQAY5XyxubLkSD4iA/xgPC IIXDyqjQ6INzjz0uTTqHBhWfMMBpB/gO7amkve/p1ETwndtp/8Q4aw9NaNJ6x7fDbQtY UYrQ== X-Gm-Message-State: AOAM532uolNNyxYGge79MFmkEb3tefDJfzm+tv5TaxEQ09k0dGgEC+cC gFSSigpQctpu2P0O6yna7uIHVFUg0GSS X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:b6c9:16a6:f912:39d5]) (user=irogers job=sendgmr) by 2002:a0d:edc7:0:b0:2f8:f300:df2b with SMTP id w190-20020a0dedc7000000b002f8f300df2bmr23506929ywe.515.1652252497609; Wed, 11 May 2022 00:01:37 -0700 (PDT) Date: Wed, 11 May 2022 00:01:26 -0700 Message-Id: <20220511070133.710721-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog Subject: [PATCH 0/7] 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.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham 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). 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. A difference in the python to the C approach is that the python loads an entire json file in to memory, while the C code works from token to token. In some cases the C approach was sensitive to the order of dictionary items in the json file. To ensure matching output there are two changes made to jevents.c to cause it to read all values before creating output. The changes also found a bug in Ivytown's UNC_M_ACT_COUNT.RD event encoding, as well as unnecessary whitespace introduced in Alderlake's metrics. In these cases the json input is fixed. Ian Rogers (7): perf jevents: Append PMU description later perf vendor events: Fix Alderlake metric groups perf vendor events: Fix Ivytown UNC_M_ACT_COUNT.RD umask perf jevents: Modify match field perf jevents: Add python converter script perf jevents: Switch build to use jevents.py perf jevents: Remove jevents.c tools/perf/Makefile.perf | 13 +- tools/perf/pmu-events/Build | 9 +- .../arch/x86/alderlake/adl-metrics.json | 32 - .../arch/x86/ivytown/uncore-memory.json | 3 +- tools/perf/pmu-events/jevents.c | 1322 ----------------- 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 - tools/perf/tests/pmu-events.c | 30 +- 10 files changed, 412 insertions(+), 1658 deletions(-) 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.0.512.ge40c2bad7a-goog