From nobody Thu Apr 9 18:52:57 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 36344342177 for ; Fri, 6 Mar 2026 14:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772806133; cv=none; b=nMUG/jgzaMNvsqaXDMUQJ99veYMPf5zXFaObJ3t/vL9OiKNeD7ODMPxaF2QFDdbUhK4Cd797JGokruXUceJ7AnX7WZ24J/iVF4SKzuf+VsdCNvAkf5a0STqMffn9BGeZ6raYSV2JeEarC3mVrzIHNGqSFEmK8qidpXmGjk1C2yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772806133; c=relaxed/simple; bh=zl55HFZnBS29a+7Lxq4Y4Fp1AbgahaDuXMHEYyrIiew=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X9JtKqDBQPSiwJtsYHiyrPtSOw6SxLQPUqS+uUty8axP7tbxeO03Ka9zrbba8+w+QOX9QNwq8H7TirDK0VXN8s01ncI6N+NU3b+pV3MFsuC0luW4lN8HQJSZHlAdTAgoz4MUU6+kHVjKm2qd+ZkTHnP4Uon+YyaGq2ZUjmDqh54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=LfMm1wYP; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LfMm1wYP" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-48374014a77so111915455e9.3 for ; Fri, 06 Mar 2026 06:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772806130; x=1773410930; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tdnYy4pqHOHDMEp3XhdGrBeoVKwJbjAtI69wSRa1lMc=; b=LfMm1wYP8S7fdtYr7wK/+Ez77oFuBC6duzAY/udnK17YmB4sHlswptWRGkOC9a9XEN ktOvOn0PDQeVrNYAcYyFJFpgFBY11WPSRGqgCCJ5WXRv0ok8oxvECTwVmIDRrGL2qO+C AFXY6fXoOGVoMx/xKcmkEp9y6pR/4boxr12tYhEHOqDaYSJboBhyMhZkL3nqlSSJyvPT RyWHQy6wAyKcsiENULYEBnBLY6mMP1NNL26GyNEw+Mov2+2+oup1bsCFLKiwEUMPY3IY VMjxYmKzBTXVwgXpOu0Z8/9NZ4L8kEB/WDYEXn5S+0dpGXh7k4GAtimQ3oo04Iv2bVuh yM2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772806130; x=1773410930; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=tdnYy4pqHOHDMEp3XhdGrBeoVKwJbjAtI69wSRa1lMc=; b=lGQ2ZVPFtdlvTgAIdl8BaJZcoWe6ZFwKaVW/3R1s5nNHlDV7gzYEyFIjRBNNnpaX5C Tiw33y3NV5IFE3bL7HvC13iy/zxXADLeHWMfG6w+Ztk6yAT1bcmMmB9AWutqdppT1iOm Leyjwu9l7k5PsrGU2PycxAboMmFca+ZS3PGoNSjKVJ+ZN9KSEHAy/BEz+zuQ4Ms6DaYX WBl//1KpCxCMRYFEHjQxmOpiNp2RvIhNES1IYKCtM9empB+tFD/Lhz0zwquRLI92Tr48 cSBqfQtKW3t7baVDOrqMjIRSR9M8ILBmsZzScrzcM3HOJk0oNbc2ctiuyoohqTAW48HU QwSA== X-Forwarded-Encrypted: i=1; AJvYcCWFUDu1lIRUSzJLCjQGV5XxcGcXekiZ6FEJ0WomFuv+AnbJAjlADIRy/180oQ6Bkb9cYmSMqoJ3R0/F+E8=@vger.kernel.org X-Gm-Message-State: AOJu0YyfyDV0di0Dq/XmDdC+Fqgc5szqdE5Q8kuYRA0xJq5s3EbyDyJd Mun9d7T28PHoJLqktF1hDoxIr60ETN0pVefBKZE+eGmuWhZw26TY6Vue3Nip5sVPhDo= X-Gm-Gg: ATEYQzy4yaGIL89soEnLzjOIB9bu2aM9C+CciNtc6vRHvpi/d+FkI6wKfjooZz7XrzU OJhy/sRkd3CWIBLo2b1ocYTnnWznAFsbqWIMF/yNqW/PLOTgNc0HjJexRxGqpX3XDuApMwv2RZR 7+GBpe9F2YZQ9QINNGh4lJ5bFQGoYWoqk0li9oFID2VoV+4ST8mgo8QMZKb/L6uiQ7HAMXUin1v xVK1D+Q3AY/jho3bCMGSNOzRUunrNDO/TuIOv52Darv8m1ricdx9IsXC6ubg9icLH7X/DDwj8RH ppLcSxaxYoGLtVI7cWzABj85ZZlYFo3bFyOlukZNAUMEUulGGxduKiIun0XJMDFAtt/mA1YayN3 Q8WvamsXZCDC/heLOveDiNlbb7D2XG//f92uGEHcxZEgGumdRITib7JycgPn3+2kXy4LWshg4j6 BGPAMyWdzFKMdJEeq8IQaj0/9sXmj/9q+v X-Received: by 2002:a05:600c:4710:b0:480:20f1:7abd with SMTP id 5b1f17b1804b1-48526978dc0mr34177745e9.31.1772806129556; Fri, 06 Mar 2026 06:08:49 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dae2bdf8sm4212967f8f.25.2026.03.06.06.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 06:08:49 -0800 (PST) From: James Clark Date: Fri, 06 Mar 2026 14:08:34 +0000 Subject: [PATCH v2 1/2] perf cs-etm: Finish removal of ETM_OPT_* Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260306-james-perf-remove-etm_opt-v2-1-b411d3ae24b3@linaro.org> References: <20260306-james-perf-remove-etm_opt-v2-0-b411d3ae24b3@linaro.org> In-Reply-To: <20260306-james-perf-remove-etm_opt-v2-0-b411d3ae24b3@linaro.org> To: Arnaldo Carvalho de Melo , Namhyung Kim , Leo Yan , Suzuki K Poulose , Mike Leach Cc: John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark , Leo Yan X-Mailer: b4 0.14.0 These #defines have been removed from the kernel headers in favour of the string based PMU format attributes. Usages were previously removed from the recording side of cs-etm in Perf. Finish the removal by removing usages from the decode side too. It's a straight replacement of the old #defines with the new register bit definitions. Except cs_etm__setup_timeless_decoding() which wasn't looking at the saved metadata and was instead hard coding an access to 'attr.config'. This was vulnerable to the same issue of .config being moved to .config2 etc that the original removal of ETM_OPT_* tried to fix. So fix that too. Tested-by: Leo Yan Signed-off-by: James Clark --- tools/perf/arch/arm/util/cs-etm.c | 14 ---------- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 2 +- tools/perf/util/cs-etm.c | 36 +++++++++------------= ---- tools/perf/util/cs-etm.h | 15 +++++++++++ 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/c= s-etm.c index dc3f4e86b075..4418d21708d6 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -68,20 +68,6 @@ static const char * const metadata_ete_ro[] =3D { =20 enum cs_etm_version { CS_NOT_PRESENT, CS_ETMV3, CS_ETMV4, CS_ETE }; =20 -/* ETMv4 CONFIGR register bits */ -#define TRCCONFIGR_BB BIT(3) -#define TRCCONFIGR_CCI BIT(4) -#define TRCCONFIGR_CID BIT(6) -#define TRCCONFIGR_VMID BIT(7) -#define TRCCONFIGR_TS BIT(11) -#define TRCCONFIGR_RS BIT(12) -#define TRCCONFIGR_VMIDOPT BIT(15) - -/* ETMv3 ETMCR register bits */ -#define ETMCR_CYC_ACC BIT(12) -#define ETMCR_TIMESTAMP_EN BIT(28) -#define ETMCR_RETURN_STACK BIT(29) - static bool cs_etm_is_ete(struct perf_pmu *cs_etm_pmu, struct perf_cpu cpu= ); static int cs_etm_get_ro(struct perf_pmu *pmu, struct perf_cpu cpu, const = char *path, __u64 *val); static bool cs_etm_pmu_path_exists(struct perf_pmu *pmu, struct perf_cpu c= pu, const char *path); diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/u= til/cs-etm-decoder/cs-etm-decoder.c index 3050fe212666..212f17a3dc72 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -549,7 +549,7 @@ cs_etm_decoder__set_tid(struct cs_etm_queue *etmq, /* * Process the PE_CONTEXT packets if we have a valid contextID or VMID. * If the kernel is running at EL2, the PID is traced in CONTEXTIDR_EL2 - * as VMID, Bit ETM_OPT_CTXTID2 is set in this case. + * as VMID, Format attribute 'contextid2' is set in this case. */ switch (cs_etm__get_pid_fmt(etmq)) { case CS_ETM_PIDFMT_CTXTID: diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 95f439c96180..8a639d2e51a4 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -194,7 +194,7 @@ int cs_etm__get_cpu(struct cs_etm_queue *etmq, u8 trace= _chan_id, int *cpu) * CS_ETM_PIDFMT_CTXTID2: CONTEXTIDR_EL2 is traced. * CS_ETM_PIDFMT_NONE: No context IDs * - * It's possible that the two bits ETM_OPT_CTXTID and ETM_OPT_CTXTID2 + * It's possible that the two format attributes 'contextid1' and 'contexti= d2' * are enabled at the same time when the session runs on an EL2 kernel. * This means the CONTEXTIDR_EL1 and CONTEXTIDR_EL2 both will be * recorded in the trace data, the tool will selectively use @@ -210,15 +210,15 @@ static enum cs_etm_pid_fmt cs_etm__init_pid_fmt(u64 *= metadata) if (metadata[CS_ETM_MAGIC] =3D=3D __perf_cs_etmv3_magic) { val =3D metadata[CS_ETM_ETMCR]; /* CONTEXTIDR is traced */ - if (val & BIT(ETM_OPT_CTXTID)) + if (val & ETMCR_CTXTID) return CS_ETM_PIDFMT_CTXTID; } else { val =3D metadata[CS_ETMV4_TRCCONFIGR]; /* CONTEXTIDR_EL2 is traced */ - if (val & (BIT(ETM4_CFG_BIT_VMID) | BIT(ETM4_CFG_BIT_VMID_OPT))) + if (val & (TRCCONFIGR_VMID | TRCCONFIGR_VMIDOPT)) return CS_ETM_PIDFMT_CTXTID2; /* CONTEXTIDR_EL1 is traced */ - else if (val & BIT(ETM4_CFG_BIT_CTXTID)) + else if (val & TRCCONFIGR_CID) return CS_ETM_PIDFMT_CTXTID; } =20 @@ -2914,29 +2914,21 @@ static int cs_etm__process_auxtrace_event(struct pe= rf_session *session, return 0; } =20 -static int cs_etm__setup_timeless_decoding(struct cs_etm_auxtrace *etm) +static void cs_etm__setup_timeless_decoding(struct cs_etm_auxtrace *etm) { - struct evsel *evsel; - struct evlist *evlist =3D etm->session->evlist; + /* Take first ETM as all options will be the same for all ETMs */ + u64 *metadata =3D etm->metadata[0]; =20 /* Override timeless mode with user input from --itrace=3DZ */ if (etm->synth_opts.timeless_decoding) { etm->timeless_decoding =3D true; - return 0; + return; } =20 - /* - * Find the cs_etm evsel and look at what its timestamp setting was - */ - evlist__for_each_entry(evlist, evsel) - if (cs_etm__evsel_is_auxtrace(etm->session, evsel)) { - etm->timeless_decoding =3D - !(evsel->core.attr.config & BIT(ETM_OPT_TS)); - return 0; - } - - pr_err("CS ETM: Couldn't find ETM evsel\n"); - return -EINVAL; + if (metadata[CS_ETM_MAGIC] =3D=3D __perf_cs_etmv3_magic) + etm->timeless_decoding =3D !(metadata[CS_ETM_ETMCR] & ETMCR_TIMESTAMP_EN= ); + else + etm->timeless_decoding =3D !(metadata[CS_ETMV4_TRCCONFIGR] & TRCCONFIGR_= TS); } =20 /* @@ -3499,9 +3491,7 @@ int cs_etm__process_auxtrace_info_full(union perf_eve= nt *event, etm->auxtrace.evsel_is_auxtrace =3D cs_etm__evsel_is_auxtrace; session->auxtrace =3D &etm->auxtrace; =20 - err =3D cs_etm__setup_timeless_decoding(etm); - if (err) - return err; + cs_etm__setup_timeless_decoding(etm); =20 etm->tc.time_shift =3D tc->time_shift; etm->tc.time_mult =3D tc->time_mult; diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index a8caeea720aa..aa9bb4a32eca 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -230,6 +230,21 @@ struct cs_etm_packet_queue { /* CoreSight trace ID is currently the bottom 7 bits of the value */ #define CORESIGHT_TRACE_ID_VAL_MASK GENMASK(6, 0) =20 +/* ETMv4 CONFIGR register bits */ +#define TRCCONFIGR_BB BIT(3) +#define TRCCONFIGR_CCI BIT(4) +#define TRCCONFIGR_CID BIT(6) +#define TRCCONFIGR_VMID BIT(7) +#define TRCCONFIGR_TS BIT(11) +#define TRCCONFIGR_RS BIT(12) +#define TRCCONFIGR_VMIDOPT BIT(15) + +/* ETMv3 ETMCR register bits */ +#define ETMCR_CYC_ACC BIT(12) +#define ETMCR_CTXTID BIT(14) +#define ETMCR_TIMESTAMP_EN BIT(28) +#define ETMCR_RETURN_STACK BIT(29) + int cs_etm__process_auxtrace_info(union perf_event *event, struct perf_session *session); void cs_etm_get_default_config(const struct perf_pmu *pmu, struct perf_eve= nt_attr *attr); --=20 2.34.1