From mboxrd@z Thu Jan 1 00:00:00 1970 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 10E53CCA47A for ; Wed, 15 Jun 2022 03:05:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345913AbiFODFH (ORCPT ); Tue, 14 Jun 2022 23:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345884AbiFODE7 (ORCPT ); Tue, 14 Jun 2022 23:04:59 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA7FE4B43C; Tue, 14 Jun 2022 20:04:58 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d13so9265006plh.13; Tue, 14 Jun 2022 20:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QD0NmwuUrX47DPRLrWv40Es+J6Tt15gUljsar+e50t4=; b=PxLg80jhvr5wUnjqqPw86c44vOy2aVxVBaEiyWvukUQy2RV4fVhEMl8D8uLi72apSs DieyptDB3Y3yv091ajk9ih0UWiY3qpPEHO0D21YGdtvd2tqTa6RKoCBEY5BqQWH5aURl FIpvCPU1BFLmkXQjP8MrbgMyEdsShdIhY0mjTxk5zXr8nteFly69J8xjFeKdcd1MFxyv 3x5ewreMYiUDOCMILJIogLIk02UFjQp4Z8gT1yrYrDmXj8NyH19oE987CHNThdxQJMn5 g4WtP1id3bYiBhAgyCSzFDLR1dDBU22uARVCPkpz0m+fdz3K9Ul/sggIsBmpz33aCIQ9 8ySg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QD0NmwuUrX47DPRLrWv40Es+J6Tt15gUljsar+e50t4=; b=mFSmsDfQJEiSBwixXPjstkRraO2DpuzUMwwekcRT7A3aQNM5kjIzqjWMmYISKQqqC/ B58Z7abs604GU6UgASQ5e5Sf5hGMvlxSqTvAlrFcK06aQyGPFCI7B4+L45ZwKQfNuGBT j2t4E3rRmwpQTOdZGKi8oZz41nNb34GiDgbYxD9jzs42tvBoDZ0nMGD4YFkz7APTUlxx C9MslWn3IEwrRDig4u5iJhciv4AM+Jqt9t/fdMxyqtRe0WdzJLo2vZNb11vZEGRY5PmV c9bjdRtcKRp7DhTroJdMewDJPkH3DtfJpbZv0Wl7jckENfiDlk5+1f3niAOItP2M+dS+ 7oqw== X-Gm-Message-State: AJIora9chnnE04/5Z6qUsQgeg73gQrfRs7TdcJWxtD9BJjstceDtYzMQ 7A2+pf/Nt9GH8O7GymDfPPQ= X-Google-Smtp-Source: ABdhPJxP5PXz9iZOeCBb/215ZreFbAIf7RAywMg8VRicsryS6jSQPwBiAcigPwBxWEyTX/97+ZWXVA== X-Received: by 2002:a17:902:e54b:b0:166:50b6:a0a0 with SMTP id n11-20020a170902e54b00b0016650b6a0a0mr7337820plf.30.1655262298099; Tue, 14 Jun 2022 20:04:58 -0700 (PDT) Received: from rpi400.lan (c-73-70-190-118.hsd1.ca.comcast.net. [73.70.190.118]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f7cc00b0015e8d4eb28csm7933132plw.214.2022.06.14.20.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 20:04:51 -0700 (PDT) From: Ian Rogers X-Google-Original-From: Ian Rogers Received: by rpi400.lan (Postfix, from userid 1001) id AFC862FC697; Tue, 14 Jun 2022 20:04:48 -0700 (PDT) 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 Subject: [PATCH v4 0/4] Rewrite jevents program in python Date: Tue, 14 Jun 2022 20:04:34 -0700 Message-Id: <20220615030438.51477-1-irogers@google.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. 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 | 15 +- tools/perf/pmu-events/empty-pmu-events.c | 21 + tools/perf/pmu-events/jevents.c | 1342 ---------------------- tools/perf/pmu-events/jevents.py | 394 +++++++ tools/perf/pmu-events/jsmn.h | 68 -- tools/perf/pmu-events/json.c | 162 --- tools/perf/pmu-events/json.h | 39 - 9 files changed, 450 insertions(+), 1634 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.34.1