From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C4023DFC63 for ; Fri, 15 May 2026 19:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778873637; cv=none; b=ryeD87q3I/axpmU+WDBcLXN0Qf8n8Z3iYE89FZ+RsbusGURjZoLbZUjYb+ACmUJLM71qT3/lcP0+GFp7YxFEMCRS56YX6ZsdtlU+Lf7R2sNv/nt30OYqzuEzSif9ZDFTpXEUSUZ7IxQyN6Ii7uaWxqlc94/Fy6nx6ta2alIdscU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778873637; c=relaxed/simple; bh=NGfYl6kDEytKUmpKfL2C4Og3ft1hP0ENd8qszCmyGZM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ANEzj/0O9o+xmmL7r7CE/D8eSj77TbQM++/tKlorJbKgsA3zDH67rxwEmPbiOhxlgJe0Uow3BT8KnuSKSYKTRj2kgBJCb1SNeZeoPlFpoIS6j6KWayV/vawCdegeZ0CMPscXFf8iOMCoGmaPhSvMOPuCHVRe4JN8vp7OjCkDz4c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SDqny1x/; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SDqny1x/" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1353bfdbf99so931983c88.0 for ; Fri, 15 May 2026 12:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778873635; x=1779478435; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ugOFCk7HwEprnixRixPWaow/W0W91ZlZhg4SUCGAxfk=; b=SDqny1x/8dX7St//cLGfkccVacFkgX9dRZl2SJGG9P0Jq8+TlLHFb8SM3OkmZy0Ygq ChxaAAuQ2IK2CVNr5jU86qm5H2/TCX9RYDgPfgtUpKEHlZzxkf0qu2kOFt+pfKCFbEk8 94UZGZtX/bJX0xEnVx1C20F1hABEH1jJjdX9rqEb507IPDDEcnRwIVvyw50qyX7JwuuQ UhfZCR/DlguKPCpfBwqa7zCW5oGPpV63i34SoeEjaJELaPcxLagbFM7D6CWpTUQMU6DS qiHP2lye4vym007UXc0TnOTvtNJXxccmnvabQxV2KzXNCdeVMbIBST/WojFJnNdSQqyt 0xuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778873635; x=1779478435; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ugOFCk7HwEprnixRixPWaow/W0W91ZlZhg4SUCGAxfk=; b=iIn7RbAbYmrF+zGLpm7H7LOe5rjITOkcw719AAbYMY0aLlJ4PfdrjW18gJe1xuwnL3 hG9Bb941Qhw0ynDCWq7l3xC9+T5zRLGXKw2Vwyjw1zGG2wgv15vuTqCSOHWEr7GcORfN HfZqfa0AMM3ojGW2hGEpFQSKK+jpHPQdSjmpptE/chFNUw/GED5NhBi9LJ/UNTj48M7B geavInHOfO1WGPRwD/zwOp2xW6g3lOGio+hDeqt0aLlg5/wyhSCzhnXA3xnCxWzBnkyO mTciIiut6FbCbvOLBmid4rcDmQRs5dlPjrA+eWKHz5k8weHZyUyujvN6gASy5D7m1x7Q CA5w== X-Forwarded-Encrypted: i=1; AFNElJ/sCHkf/7zY18vAFbnmuV/1sCrE1QvQKYujDFYzHy4hw7V8Q0zqFSkfpdtvYbMr/zgT7zE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1Zf5LfsL07+ZHpiUGK77njkQu6GLv5tKL5zpTXSy8GOHjzzf9 UFtnBRLHzKbsGcb8p1YA0jq5XCyE6An4JaHWZdm6NBWKYQYjdZF2ey2MOvTIpNXdAeNB5OnyO18 BerUnEgjo1Q== X-Received: from dled20-n1.prod.google.com ([2002:a05:701b:42d4:10b0:12d:d0a4:2ed9]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:221c:b0:130:a479:797d with SMTP id a92af1059eb24-1350494e48emr1418656c88.29.1778873634429; Fri, 15 May 2026 12:33:54 -0700 (PDT) Date: Fri, 15 May 2026 12:33:13 -0700 In-Reply-To: <20260515193314.1593560-1-irogers@google.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260515173852.1378571-1-irogers@google.com> <20260515193314.1593560-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260515193314.1593560-14-irogers@google.com> Subject: [PATCH v5 13/14] perf pmu-events: Convert recursive shell assignments and macros to Make built-ins From: Ian Rogers To: irogers@google.com, acme@kernel.org, james.clark@linaro.org, namhyung@kernel.org Cc: 9erthalion6@gmail.com, adrian.hunter@intel.com, alex@ghiti.fr, alexandre.chartre@oracle.com, andrii@kernel.org, ankur.a.arora@oracle.com, aou@eecs.berkeley.edu, bpf@vger.kernel.org, collin.funk1@gmail.com, costa.shul@redhat.com, daniel@iogearbox.net, dapeng1.mi@linux.intel.com, dsterba@suse.com, eddyz87@gmail.com, howardchu95@gmail.com, jolsa@kernel.org, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, martin.lau@linux.dev, memxor@gmail.com, mingo@redhat.com, mmayer@broadcom.com, nathan@kernel.org, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, qmo@kernel.org, ricky.ringler@proton.me, song@kernel.org, swapnil.sapkal@amd.com, terrelln@fb.com, tglozar@redhat.com, thomas.falcon@intel.com, yonghong.song@linux.dev Content-Type: text/plain; charset="UTF-8" In pmu-events/Build, ZENS, ARMS, and INTELS were assigned using recursive assignment (=), and model_name/vendor_name were evaluated using shell macros (echo ... | sed ...). Because these variables were expanded inside the COPY_RULE dependency evaluation loop across hundreds of PMU JSON files and inside every metric generation recipe, Kbuild continuously re-executed 'ls', 'grep', and 'sed' shell forks thousands of times during AST parsing and execution. Convert ZENS, ARMS, and INTELS to simply expanded variables (:=) and replace model_name/vendor_name with pure GNU Make string functions. This guarantees Make executes directory probing shell forks exactly once when the Build file is parsed and evaluates path macros purely in memory, completely eliminating over 7,800 redundant sub-processes during build startup. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers --- tools/perf/pmu-events/Build | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index 95172a2a851f..372773b998e4 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -56,12 +56,12 @@ $(LEGACY_CACHE_JSON): $(LEGACY_CACHE_PY) # Python to generate architectural metrics GEN_METRIC_DEPS := pmu-events/metric.py pmu-events/common_metrics.py # Functions to extract the model from an extra-metrics.json or extra-metricgroups.json path. -model_name = $(shell echo $(1)|sed -e 's@.\+/\(.*\)/extra-metric.*\.json@\1@') -vendor_name = $(shell echo $(1)|sed -e 's@.\+/\(.*\)/[^/]*/extra-metric.*\.json@\1@') +model_name = $(notdir $(patsubst %/,%,$(dir $(1)))) +vendor_name = $(notdir $(patsubst %/,%,$(dir $(patsubst %/,%,$(dir $(1)))))) ifeq ($(JEVENTS_ARCH),$(filter $(JEVENTS_ARCH),x86 all)) # Generate AMD Json -ZENS = $(shell ls -d pmu-events/arch/x86/amdzen*) +ZENS := $(shell ls -d pmu-events/arch/x86/amdzen*) ZEN_METRICS = $(foreach x,$(ZENS),$(OUTPUT)$(x)/extra-metrics.json) ZEN_METRICGROUPS = $(foreach x,$(ZENS),$(OUTPUT)$(x)/extra-metricgroups.json) GEN_JSON += $(ZEN_METRICS) $(ZEN_METRICGROUPS) @@ -78,7 +78,7 @@ endif ifeq ($(JEVENTS_ARCH),$(filter $(JEVENTS_ARCH),arm64 all)) # Generate ARM Json -ARMS = $(shell ls -d pmu-events/arch/arm64/arm/*|grep -v cmn) +ARMS := $(shell ls -d pmu-events/arch/arm64/arm/*|grep -v cmn) ARM_METRICS = $(foreach x,$(ARMS),$(OUTPUT)$(x)/extra-metrics.json) ARM_METRICGROUPS = $(foreach x,$(ARMS),$(OUTPUT)$(x)/extra-metricgroups.json) GEN_JSON += $(ARM_METRICS) $(ARM_METRICGROUPS) @@ -95,7 +95,7 @@ endif ifeq ($(JEVENTS_ARCH),$(filter $(JEVENTS_ARCH),x86 all)) # Generate Intel Json -INTELS = $(shell ls -d pmu-events/arch/x86/*|grep -v amdzen|grep -v mapfile.csv) +INTELS := $(shell ls -d pmu-events/arch/x86/*|grep -v amdzen|grep -v mapfile.csv) INTEL_METRICS = $(foreach x,$(INTELS),$(OUTPUT)$(x)/extra-metrics.json) INTEL_METRICGROUPS = $(foreach x,$(INTELS),$(OUTPUT)$(x)/extra-metricgroups.json) GEN_JSON += $(INTEL_METRICS) $(INTEL_METRICGROUPS) -- 2.54.0.563.g4f69b47b94-goog