From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
James Clark <james.clark@linaro.org>,
Xu Yang <xu.yang_2@nxp.com>,
Thomas Falcon <thomas.falcon@intel.com>,
Andi Kleen <ak@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Atish Patra <atishp@rivosinc.com>,
Beeman Strong <beeman@rivosinc.com>, Leo Yan <leo.yan@arm.com>,
Vince Weaver <vincent.weaver@maine.edu>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Subject: [PATCH v6 06/28] perf jevents: Support copying the source json files to OUTPUT
Date: Tue, 23 Sep 2025 15:32:50 -0700 [thread overview]
Message-ID: <20250923223312.238185-7-irogers@google.com> (raw)
In-Reply-To: <20250923223312.238185-1-irogers@google.com>
The jevents command expects all json files to be organized under a
single directory. When generating json files from scripts (to reduce
laborious copy and paste in the json) we don't want to generate the
json into the source directory if there is an OUTPUT directory
specified. This change adds a GEN_JSON for this case where the
GEN_JSON copies the JSON files to OUTPUT, only when OUTPUT is
specified. The Makefile.perf clean code is updated to clean up this
directory when present.
This patch is part of:
https://lore.kernel.org/lkml/20240926173554.404411-12-irogers@google.com/
which was similarly adding support for generating json in scripts for
the consumption of jevents.py.
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/Makefile.perf | 21 ++++++++++++++++-----
tools/perf/pmu-events/Build | 18 ++++++++++++------
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index e2150acc2c13..cc1635335586 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -1272,9 +1272,24 @@ endif # CONFIG_PERF_BPF_SKEL
bpf-skel-clean:
$(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) $(SKEL_OUT)/vmlinux.h
+pmu-events-clean:
+ifeq ($(OUTPUT),)
+ $(call QUIET_CLEAN, pmu-events) $(RM) \
+ pmu-events/pmu-events.c \
+ pmu-events/metric_test.log \
+ pmu-events/test-empty-pmu-events.c \
+ pmu-events/empty-pmu-events.log
+else # When an OUTPUT directory is present, clean up the copied pmu-events/arch directory.
+ $(call QUIET_CLEAN, pmu-events) $(RM) -r $(OUTPUT)pmu-events/arch \
+ $(OUTPUT)pmu-events/pmu-events.c \
+ $(OUTPUT)pmu-events/metric_test.log \
+ $(OUTPUT)pmu-events/test-empty-pmu-events.c \
+ $(OUTPUT)pmu-events/empty-pmu-events.log
+endif
+
clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean \
arm64-sysreg-defs-clean fixdep-clean python-clean bpf-skel-clean \
- tests-coresight-targets-clean
+ tests-coresight-targets-clean pmu-events-clean
$(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive \
$(OUTPUT)perf-iostat $(LANG_BINDINGS)
$(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '*.a' -delete -o \
@@ -1287,10 +1302,6 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(
$(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
$(OUTPUT)util/intel-pt-decoder/inat-tables.c \
$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
- $(OUTPUT)pmu-events/pmu-events.c \
- $(OUTPUT)pmu-events/test-empty-pmu-events.c \
- $(OUTPUT)pmu-events/empty-pmu-events.log \
- $(OUTPUT)pmu-events/metric_test.log \
$(OUTPUT)$(fadvise_advice_array) \
$(OUTPUT)$(fsconfig_arrays) \
$(OUTPUT)$(fsmount_arrays) \
diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
index 32f387d48908..1503a16e662a 100644
--- a/tools/perf/pmu-events/Build
+++ b/tools/perf/pmu-events/Build
@@ -1,7 +1,6 @@
pmu-events-y += pmu-events.o
JDIR = pmu-events/arch/$(SRCARCH)
-JSON = $(shell [ -d $(JDIR) ] && \
- find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
+JSON = $(shell find pmu-events/arch -name *.json -o -name *.csv)
JDIR_TEST = pmu-events/arch/test
JSON_TEST = $(shell [ -d $(JDIR_TEST) ] && \
find $(JDIR_TEST) -name '*.json')
@@ -29,13 +28,20 @@ $(PMU_EVENTS_C): $(EMPTY_PMU_EVENTS_C)
$(call rule_mkdir)
$(Q)$(call echo-cmd,gen)cp $< $@
else
+# Copy checked-in json for generation.
+$(OUTPUT)pmu-events/arch/%: pmu-events/arch/%
+ $(call rule_mkdir)
+ $(Q)$(call echo-cmd,gen)cp $< $@
+
+GEN_JSON = $(patsubst %,$(OUTPUT)%,$(JSON))
+
$(METRIC_TEST_LOG): $(METRIC_TEST_PY) $(METRIC_PY)
$(call rule_mkdir)
$(Q)$(call echo-cmd,test)$(PYTHON) $< 2> $@ || (cat $@ && false)
-$(TEST_EMPTY_PMU_EVENTS_C): $(JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG)
+$(TEST_EMPTY_PMU_EVENTS_C): $(GEN_JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG)
$(call rule_mkdir)
- $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) none none pmu-events/arch $@
+ $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) none none $(OUTPUT)pmu-events/arch $@
$(EMPTY_PMU_EVENTS_TEST_LOG): $(EMPTY_PMU_EVENTS_C) $(TEST_EMPTY_PMU_EVENTS_C)
$(call rule_mkdir)
@@ -63,10 +69,10 @@ $(OUTPUT)%.pylint_log: %
$(call rule_mkdir)
$(Q)$(call echo-cmd,test)pylint "$<" > $@ || (cat $@ && rm $@ && false)
-$(PMU_EVENTS_C): $(JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG) \
+$(PMU_EVENTS_C): $(GEN_JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG) \
$(EMPTY_PMU_EVENTS_TEST_LOG) $(PMU_EVENTS_MYPY_TEST_LOGS) $(PMU_EVENTS_PYLINT_TEST_LOGS)
$(call rule_mkdir)
- $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@
+ $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) $(OUTPUT)pmu-events/arch $@
endif
# pmu-events.c file is generated in the OUTPUT directory so it needs a
--
2.51.0.534.gc79095c0ca-goog
next prev parent reply other threads:[~2025-09-23 22:33 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 22:32 [PATCH v6 00/28] Legacy hardware/cache events as json Ian Rogers
2025-09-23 22:32 ` [PATCH v6 01/28] perf stat: Allow retry for default events Ian Rogers
2025-09-23 22:32 ` [PATCH v6 02/28] perf parse-events: Fix legacy cache events if event is duplicated in a PMU Ian Rogers
2025-09-23 22:32 ` [PATCH v6 03/28] perf perf_api_probe: Avoid scanning all PMUs, try software PMU first Ian Rogers
2025-09-23 22:32 ` [PATCH v6 04/28] perf stat: Avoid wildcarding PMUs for default events Ian Rogers
2025-09-23 22:32 ` [PATCH v6 05/28] perf record: Skip don't fail for events that don't open Ian Rogers
2025-09-23 22:32 ` Ian Rogers [this message]
2025-09-23 22:32 ` [PATCH v6 07/28] perf pmu: Don't eagerly parse event terms Ian Rogers
2025-09-23 22:32 ` [PATCH v6 08/28] perf parse-events: Remove unused FILE input argument to scanner Ian Rogers
2025-09-23 22:32 ` [PATCH v6 09/28] perf pmu: Use fd rather than FILE from new_alias Ian Rogers
2025-09-23 22:32 ` [PATCH v6 10/28] perf pmu: Factor term parsing into a perf_event_attr into a helper Ian Rogers
2025-09-23 22:32 ` [PATCH v6 11/28] perf parse-events: Add terms for legacy hardware and cache config values Ian Rogers
2025-09-23 22:32 ` [PATCH v6 12/28] perf jevents: Add legacy json terms and default_core event table helper Ian Rogers
2025-09-23 22:32 ` [PATCH v6 13/28] perf pmu: Add and use legacy_terms in alias information Ian Rogers
2025-09-23 22:32 ` [PATCH v6 14/28] perf jevents: Add legacy-hardware and legacy-cache json Ian Rogers
2025-09-23 22:32 ` [PATCH v6 15/28] perf print-events: Remove print_hwcache_events Ian Rogers
2025-09-23 22:33 ` [PATCH v6 16/28] perf print-events: Remove print_symbol_events Ian Rogers
2025-09-23 22:33 ` [PATCH v6 17/28] perf parse-events: Remove hard coded legacy hardware and cache parsing Ian Rogers
2025-09-23 22:33 ` [PATCH v6 18/28] perf record: Use evlist__new_default when no events specified Ian Rogers
2025-09-23 22:33 ` [PATCH v6 19/28] perf top: " Ian Rogers
2025-09-23 22:33 ` [PATCH v6 20/28] perf evlist: Avoid scanning all PMUs for evlist__new_default Ian Rogers
2025-09-23 22:33 ` [PATCH v6 21/28] perf evsel: Improvements to __evsel__match Ian Rogers
2025-09-23 22:33 ` [PATCH v6 22/28] perf test parse-events: Use evsel__match for legacy events Ian Rogers
2025-09-23 22:33 ` [PATCH v6 23/28] perf test parse-events: Without a PMU use cpu-cycles rather than cycles Ian Rogers
2025-09-23 22:33 ` [PATCH v6 24/28] perf test parse-events: Remove cpu PMU requirement Ian Rogers
2025-09-23 22:33 ` [PATCH v6 25/28] perf test: Switch cycles event to cpu-cycles Ian Rogers
2025-09-23 22:33 ` [PATCH v6 26/28] perf test: Clean up test_..config helpers Ian Rogers
2025-09-23 22:33 ` [PATCH v6 27/28] perf test parse-events: Add evlist test helper Ian Rogers
2025-09-23 22:33 ` [PATCH v6 28/28] perf test parse-events: Add evsel " Ian Rogers
2025-10-01 13:37 ` [PATCH v6 00/28] Legacy hardware/cache events as json James Clark
2025-10-01 15:12 ` Ian Rogers
2025-10-01 20:55 ` Ian Rogers
2025-10-02 14:05 ` James Clark
2025-10-02 15:46 ` Ian Rogers
2025-10-02 17:58 ` Ian Rogers
2025-10-02 20:10 ` Ian Rogers
2025-10-03 9:20 ` James Clark
2025-10-03 11:26 ` James Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250923223312.238185-7-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atishp@rivosinc.com \
--cc=beeman@rivosinc.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=tmricht@linux.ibm.com \
--cc=vincent.weaver@maine.edu \
--cc=xu.yang_2@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox