Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1051559iob; Thu, 12 May 2022 10:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAx/TFf0rWrOEErMLTMArCmiz7r/zHBWuzha3ERI4YNOexq5xid03BpCEV/Pv3iB12rHuZ X-Received: by 2002:a17:903:2303:b0:15e:a53e:322d with SMTP id d3-20020a170903230300b0015ea53e322dmr866153plh.36.1652374998028; Thu, 12 May 2022 10:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652374998; cv=none; d=google.com; s=arc-20160816; b=p6N5h96C0GKjeNAO+6EbXQ7/pMFbVoc6dV4nxZYqcBfIkC083wyVXk9dwdVgC706B4 ftvgiSpuOQmtQy0ui7X4cK0CieQ0np8Icb9nwkZMRqRCu7KrUzig8j7FKq6WjpKTnP8I cJ/1gXpudIKYGO43SWRpu2/DYLaczxrlBRJOh8pBNPCO1iXQ+8Zpw+6NJry5jFe72Lq1 IvqqzEgGsuCIM8B6D+1cy0uY7iOmAjt6bbfwTBsA/sc8ggHCA4rK35nvGWrjYf96GKZy le1eRU3lyZL0SxyBYQOGFNYjIp3QFucsUs9KRrtpAlOEFOcaL3ENDpCoXDSy/Hcj5pN7 R8HQ== 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:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=D6em2/y0Ec3M3JoELPusdEp/9enysIaA1frZAYckr0E=; b=ZIhVX81jXELc2s8OlYY+el9cEJvu9W1birKuBTX7PY7w8SSJwlcvea/636xkYyK9PR F5jCnyRomklhl8oXOiEfRZtKzXTmC7keTmYNdXzsI7Pq7j8ZVPVve6EEOfpv7YqzMDp5 if9JtaibqBxspofpB3SBjz2TgEJK5zAi5lXxw11nkCzvi7RSq0ol4miq9tXDKr45R5zS dMp83JYRMZWstQShlESCQq/LMqLXtlLMVkEv4JWyyLABsNfkgUTvaqq536TlKVga0cQp GOR9LZJA6VCe50CrThVSIXpTkstn9f61xrS20+G95VtOm0cVrB+JPLjwegzjE1zHRIfR d/UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aIDLDCuh; 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 v28-20020a637a1c000000b003a303daed2dsi4280339pgc.631.2022.05.12.10.02.45; Thu, 12 May 2022 10:03:18 -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=aIDLDCuh; 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 S232181AbiEKVQ2 (ORCPT + 99 others); Wed, 11 May 2022 17:16:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348117AbiEKVPr (ORCPT ); Wed, 11 May 2022 17:15:47 -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 E5CB15F7E for ; Wed, 11 May 2022 14:15:44 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 9-20020a250909000000b006484b89c979so2901822ybj.21 for ; Wed, 11 May 2022 14:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=D6em2/y0Ec3M3JoELPusdEp/9enysIaA1frZAYckr0E=; b=aIDLDCuhHE8szzALl3o4l1VcmbNHpCJrVV9g5TMIh4zA1eD44EtcAVT4j0t+29zjCB yCmL6UjQcrN68Nw/BhBwZqN+Qpk3L4lrYZYpBVVP5nSl/TW5JBV6OOEHc5DKJvx7042g p3RqUPbMNUljpY+o+q5HhEJf2yEGYyQlGxVY5fjt2u8rVU+hTlROiQ/IK8fFwNAsN3ZS KBExbsQVNevoBmRciu6IMypHDnM/Rbo7GUe0ps85yRhsbE6qY8GPr7AsvP+ZdHSfHR8Z koEwd+/DSsMW1CCzUGUov6wacVz+8p4UDbckTkdjLicUEj9Zf/Z+Z11CFW61J1KD2QAA TiTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=D6em2/y0Ec3M3JoELPusdEp/9enysIaA1frZAYckr0E=; b=4Jh+cDQ5mHK7w6eVOkOMFKLIG7GtS7LfZ2SLkZS3yE63r17jOcZl2BEd1uvxnN4MD3 hy9tlxLiO7w5xp9TEITuHR9jR4j3H0dv5bkWUrMF6D+N126wdsmcJ/vo9vP+lMtYlusG Me2gFMloDLBP8QaFMBFE2VOi64D8CR5OyQUkRqeW+2fv1xEokT63dyP526ClCTW7WSWn sEnO6OToQKBrXjvMvTxoauXmz0ohK+E0brxvY5trY05LbHktJJS3Tc6fSObaI/eLopjq CT6tSwXEyfYBt7nb09pO9gBMl+9yuxRgzOu197Fmzl7jzvQwuOzCnmTY92LmnLIfd6xZ ixsw== X-Gm-Message-State: AOAM533t4sPAzox6uOSlV6obDwLQyhpS1qez6AAlgtlBU6jgQT5s9hGY r+zBkeSVX9bzfpOF14yrpgdC0EB3HMx2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:5993:294b:7b62:54cb]) (user=irogers job=sendgmr) by 2002:a81:b810:0:b0:2fb:2da2:e043 with SMTP id v16-20020a81b810000000b002fb2da2e043mr28869289ywe.483.1652303743938; Wed, 11 May 2022 14:15:43 -0700 (PDT) Date: Wed, 11 May 2022 14:15:25 -0700 In-Reply-To: <20220511211526.1021908-1-irogers@google.com> Message-Id: <20220511211526.1021908-7-irogers@google.com> Mime-Version: 1.0 References: <20220511211526.1021908-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog Subject: [PATCH v2 6/7] perf jevents: Switch build to use jevents.py 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=unavailable 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 Generate pmu-events.c using jevents.py rather than the binary built from jevents.c. Add a new config variable NO_JEVENTS that is set when there is no architecture json or an appropriate python interpreter isn't present. When NO_JEVENTS is defined the file pmu-events/empty-pmu-events.c is copied and used as the pmu-events.c file. Signed-off-by: Ian Rogers --- tools/perf/Makefile.config | 19 +++++++++++++++++++ tools/perf/Makefile.perf | 1 + tools/perf/pmu-events/Build | 11 +++++++++-- tools/perf/pmu-events/empty-pmu-events.c | 21 +++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tools/perf/pmu-events/empty-pmu-events.c diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index d9b699ad402c..5a19469f0048 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -854,6 +854,25 @@ else endif endif +ifneq ($(NO_JEVENTS),1) + ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),) + NO_JEVENTS := 1 + endif +endif +ifneq ($(NO_JEVENTS),1) + NO_JEVENTS := 0 + ifndef PYTHON + $(warning No python interpreter disabling jevent generation) + NO_JEVENTS := 1 + else + # jevents.py uses os.scandir and type hints present in Python 3.5 released in Sept. 2015. + JEVENTS_PYTHON_GOOD := $(shell $(PYTHON) -c 'import sys;print("1" if(sys.version_info.major >= 3 and sys.version_info.minor >= 5) else "0")') + ifneq ($(JEVENTS_PYTHON_GOOD), 1) + $(warning Python interpreter too old (older than 3.5) disabling jevent generation) + NO_JEVENTS := 1 + endif + endif +endif ifndef NO_LIBBFD ifeq ($(feature-libbfd), 1) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 078f0b06f08a..db416a13dca7 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -655,6 +655,7 @@ JEVENTS := $(OUTPUT)pmu-events/jevents JEVENTS_IN := $(OUTPUT)pmu-events/jevents-in.o PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o +export NO_JEVENTS export JEVENTS diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index a055dee6a46a..5e459e1c7a85 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -9,10 +9,17 @@ JSON = $(shell [ -d $(JDIR) ] && \ JDIR_TEST = pmu-events/arch/test JSON_TEST = $(shell [ -d $(JDIR_TEST) ] && \ find $(JDIR_TEST) -name '*.json') +JEVENTS_PY = pmu-events/jevents.py # # Locate/process JSON files in pmu-events/arch/ # directory and create tables in pmu-events.c. # -$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS) - $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V) + +ifeq ($(NO_JEVENTS),1) +$(OUTPUT)pmu-events/pmu-events.c: pmu-events/empty-pmu-events.c + $(Q)cp $< $@ +else +$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS_PY) + $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(SRCARCH) pmu-events/arch $@ +endif diff --git a/tools/perf/pmu-events/empty-pmu-events.c b/tools/perf/pmu-events/empty-pmu-events.c new file mode 100644 index 000000000000..08fee615e015 --- /dev/null +++ b/tools/perf/pmu-events/empty-pmu-events.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * An empty pmu-events.c file used when there is no architecture json files in + * arch or when the jevents.py script cannot be run. + */ +#include "pmu-events/pmu-events.h" + +const struct pmu_events_map pmu_events_map[] = { + { + .cpuid = 0, + .version = 0, + .type = 0, + .table = 0, + }, +}; + +const struct pmu_sys_events pmu_sys_event_tables[] = { + { + .table = 0 + }, +}; -- 2.36.0.512.ge40c2bad7a-goog