From nobody Mon Feb 9 17:57:40 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 A78DE3A0E95 for ; Wed, 14 Jan 2026 15:57:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768406276; cv=none; b=kBgE0rCWsUFnH+VI0CYReyRqLqqS+qnLMcxrwZo0ufqKJ2h//DJBHLxo+BE4B/CLij6JVOj2l3ETub0AFGlj/+Y6T3CTn5j3wHH80vQ4o0nePnhKDiLKZXGV8loPsI9HRivilmCp0gapbmbqxHr/F86VYsI/p7ccvCsyIOLn7Mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768406276; c=relaxed/simple; bh=xdhUjHRtxvw8BCDXCGf/XHbPNrOY6/jThaBJXsuN6Oo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GkbwxW4OMPLJ6hlnJQ8I96kpLdfBiabSq65zK5LPTEzKlpygqwKuvnzwTs/6OFQxi/oJKbvPtzI8f8tBoIcndNIIAE2Cqpe8RBPHfUP41k79FpPp+ytUPeS4QGFBbmXnw9UdF6n2u3oGyBveszH092XzHsethYZ/18r+OAIZYvs= 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=xSdcg2eH; arc=none smtp.client-ip=209.85.128.43 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="xSdcg2eH" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-47d493a9b96so51039875e9.1 for ; Wed, 14 Jan 2026 07:57:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768406270; x=1769011070; 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=IHuJ8xIDoo5vqekEsW8kb8XOXUQ7JU8mQQu2ivsjyMg=; b=xSdcg2eHhCutz9reuhtnBgNDNVr34PByifVoIrIKoqLiJlfur/GHzgnP1dYiVO014D rQgqbK8yY5tOAEg2BFIDYmenmVeSf0kGfcPcUmNTnIimFyKfMSUueNy2AwNxJubbiCug mXl8mYZCgGXt+GY+0MdWd8+ZEMsPAB3Ay3ClwxNzMpjq+TQn6sLPi7G4W2bE/iu5D75b YIBoCg1JnRkX1jI9OxWZMvPYXDmFBNPtaua7lsP2ulXr7hYPhBZ+oPGXPVU1l8Xyt8LV BgAZ/CrY66sqnBEg3hoyt9RrDds1mcrm8tH5YywuocGEjf1qwhAhF3CqhTZYAMgcRvV5 fg+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768406270; x=1769011070; 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=IHuJ8xIDoo5vqekEsW8kb8XOXUQ7JU8mQQu2ivsjyMg=; b=NugfzXTdHkUk/HhzkQ9R/xNKvgbGDvKaq4c5m7ZrjYXP9TuwLdY5AGAK3Ef1kUmK/I /9ZZKREY0ImsaYcjN+I0Vh13KGkAX7799TZ2ydKB94gC46elYqLK2f9rwAer/gg1iwi5 vuVTuUgdFNazk+PHUbJ48KnycFOW79GM4aZM01KYhnlECciJKMGFFBpKflNn66cY6TzU aev11tPYETTVS6yLrEvk8j/1UEh1k5hRq8lLN5ap5NTnU09noVszH8kcpk3qAWDOoapY Y1EAmVhIYPZNw0e2Ry/kUAO1qoYrssFfZ7dG7k5vTT7D+cFuhLgMRfBiMOupcSkE4GXR Fo1g== X-Forwarded-Encrypted: i=1; AJvYcCWMR1Ao4SS28KfjkgZ8dhs6LS8F7d1CVADyvTLd+8bJ4+sQvXkoyjMedabn9BSWGWpr61qlGTJVE9Ogn8I=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7D8wpfKFUJERXdz+aUjV2aBjRRO0ATD/mXIQdTnIchblMQs6s drpmD8J8DPCk1NsURqKiaZM3d37vjhjBrSFJOGfad5Pm0J+xLx6XHnyfEaAoHEAqCkc= X-Gm-Gg: AY/fxX4mv8wJMr44Wo0ufuQGal3fNyZWb/959kC4xR45eovIkUxNpJDJwumVZTDzjA4 JswpiLijQQdFLdXMES6aKLlgZXUv/pmSoIy83Rcp3G/IQDKsEQiQvPqr3fcTRIJGub16bYt8vPV Pi9vbLkApWT/7gPyzcrEGuiNZ/LGU7zlRPcUQL0wwQuoSmBAjyoar0NtPapnjqDMeSngnzdd5Mf f5DgIW1nfEuHK/XqpkTkgi9E5W4nU9aLpl6ttaeipkKKAinghz7DTNSmzh5posFFMF8ljhdMp6J 5rYN/9Cwjz/1jIgpHFNaNFJ5c1ILlTycYMgKlpp3nc/+OYMR58wupIngS85gD5UV07XeI32UkY1 WZTajq6xKW61k9NIjH0DTy3lCJDl4KMHQQzDLnwogvCCT619GM7D5PZzlwKExhn2YrPHhnZmC5c O/Rg34iI4KpFqytI1Cl/H0 X-Received: by 2002:a05:600c:8b0a:b0:47a:7fd0:9f01 with SMTP id 5b1f17b1804b1-47ee3356c0amr37970915e9.16.1768406270036; Wed, 14 Jan 2026 07:57:50 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47ee85e8807sm7426475e9.16.2026.01.14.07.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 07:57:49 -0800 (PST) From: James Clark Date: Wed, 14 Jan 2026 15:57:22 +0000 Subject: [PATCH v5 10/14] perf cs-etm: Make a helper to find the Coresight evsel 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: <20260114-james-perf-config-bits-v5-10-0ef97aaf1ac0@linaro.org> References: <20260114-james-perf-config-bits-v5-0-0ef97aaf1ac0@linaro.org> In-Reply-To: <20260114-james-perf-config-bits-v5-0-0ef97aaf1ac0@linaro.org> To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Leo Yan Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Leo Yan , James Clark X-Mailer: b4 0.14.0 This pattern occurs a few times and we'll add another one later, so add a helper function for it. Reviewed-by: Leo Yan Reviewed-by: Ian Rogers Signed-off-by: James Clark --- tools/perf/arch/arm/util/cs-etm.c | 50 +++++++++++++++++++++--------------= ---- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/c= s-etm.c index c28208361d91..a49753f0d20f 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -302,6 +302,19 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu, return 0; } =20 +static struct evsel *cs_etm_get_evsel(struct evlist *evlist, + struct perf_pmu *cs_etm_pmu) +{ + struct evsel *evsel; + + evlist__for_each_entry(evlist, evsel) { + if (evsel->core.attr.type =3D=3D cs_etm_pmu->type) + return evsel; + } + + return NULL; +} + static int cs_etm_recording_options(struct auxtrace_record *itr, struct evlist *evlist, struct record_opts *opts) @@ -473,29 +486,21 @@ static int cs_etm_recording_options(struct auxtrace_r= ecord *itr, =20 static u64 cs_etm_get_config(struct auxtrace_record *itr) { - u64 config =3D 0; struct cs_etm_recording *ptr =3D container_of(itr, struct cs_etm_recording, itr); struct perf_pmu *cs_etm_pmu =3D ptr->cs_etm_pmu; struct evlist *evlist =3D ptr->evlist; - struct evsel *evsel; + struct evsel *evsel =3D cs_etm_get_evsel(evlist, cs_etm_pmu); =20 - evlist__for_each_entry(evlist, evsel) { - if (evsel->core.attr.type =3D=3D cs_etm_pmu->type) { - /* - * Variable perf_event_attr::config is assigned to - * ETMv3/PTM. The bit fields have been made to match - * the ETMv3.5 ETRMCR register specification. See the - * PMU_FORMAT_ATTR() declarations in - * drivers/hwtracing/coresight/coresight-perf.c for - * details. - */ - config =3D evsel->core.attr.config; - break; - } - } - - return config; + /* + * Variable perf_event_attr::config is assigned to + * ETMv3/PTM. The bit fields have been made to match + * the ETMv3.5 ETRMCR register specification. See the + * PMU_FORMAT_ATTR() declarations in + * drivers/hwtracing/coresight/coresight-perf.c for + * details. + */ + return evsel ? evsel->core.attr.config : 0; } =20 #ifndef BIT @@ -829,12 +834,11 @@ static int cs_etm_snapshot_start(struct auxtrace_reco= rd *itr) { struct cs_etm_recording *ptr =3D container_of(itr, struct cs_etm_recording, itr); - struct evsel *evsel; + struct evsel *evsel =3D cs_etm_get_evsel(ptr->evlist, ptr->cs_etm_pmu); + + if (evsel) + return evsel__disable(evsel); =20 - evlist__for_each_entry(ptr->evlist, evsel) { - if (evsel->core.attr.type =3D=3D ptr->cs_etm_pmu->type) - return evsel__disable(evsel); - } return -EINVAL; } =20 --=20 2.34.1