From nobody Sun Dec 14 11:59:45 2025 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 94C883161BC for ; Fri, 12 Dec 2025 15:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765553582; cv=none; b=F0pOv1F0uIzdezpMPASn7LYybW1SU07wAqrFWAaR5a6OI6/lEMwS2ebLJZSVZA51HP+zXeeDgUHGIgPnTl8705OyOYENd55+44uN5FOARGXV/jnYF4/hno4j5ZTVZiC0W/wJeRa/Qa71HmjpVvnG0wN5Sv65O7WcXPJqJwhUO9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765553582; c=relaxed/simple; bh=qgsdekHEBzAXO5lvPU9/5A8O0g5IS9B8puKwIYnrP+M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HqAwqYWK+jaFeN9eEOIS5V8lpFaZvUKgah0p1Q04ppMi7OJpx7JxMW3VtDURxHom7ilKOJwNFYYvSCVaqY1OwkBkKC2QrpD17hv5NDOKjtKDWCRPWMU8Rnj0skgsdoLwTD+oVLXXg7BuAy8NxyTDLabrKihFrdgwKOsAH7AYSy0= 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=WMfGxlpv; arc=none smtp.client-ip=209.85.208.50 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="WMfGxlpv" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-64951939e1eso2210700a12.1 for ; Fri, 12 Dec 2025 07:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765553579; x=1766158379; 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=OERRRk3y48q4ktL/F5cCy8Sn/Ar6UF3zQz2qyOlFtzY=; b=WMfGxlpv4NSrFdg8VlcRpJmKAaijZk6lLy32by5ebZa2MmursnmhLVya136ZGxSP+f 8yTC/zRTyijTKZKeGLmxDVdct5sZeSvEZCU1kgs7LGWFXpN3J25lFUYw9G1oZE178p2x HXgwMpiWcASjLyV1VHc7Ui8KFUVuYqCghc7RR+krbus8Lc4FtxdLfErOrXoJIWSl+6Ok lD5U9ahCpOoEftNsHBe9dFl1KLB6d7VSjFQ4TQpJ1vE9xfEnEB6E8yCrrkq9onliADcH yCLIKClPMb+zUtrN90FG9DKXmbdom0t24nHSvIAahmRkNcZF2tTYdjtXo3dZt16uI8dF etQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765553579; x=1766158379; 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=OERRRk3y48q4ktL/F5cCy8Sn/Ar6UF3zQz2qyOlFtzY=; b=B1u8FqPlBky8SDpJCCPOwepcDB46yjOScoDGIKY2N8CppLbF+t0I/FfMD8EHdFSG5c Wi65ndgA0gK9WuXfvvGODrS9zeuINmVoPfpdvhmWsh6SQRjFnrV4yuD1meVAi42E+t22 XFgFaYrdU0Ygj/YpD2vDPPzqku0dBj60VO+F7clVdkJzNO7KJ28RBz6LUWaRdvs5HrDL Z2Yefo4dQZZWdYF6z+3VH9e9QXGci5rL4zHvEvnmICKx4hawUpCBfIEcMGelEUVrW+b7 TiSjgOSj89bn73xaQoZq+lJi/d6gr8uExNfxOrSuteyjfNrAaXHvLDFuA+rV+CVDwqtj LzYQ== X-Forwarded-Encrypted: i=1; AJvYcCXLqCIXE0xWDfX4OAbv8OEF1nUlwcS920LjvxpAVLq6M2CNM+wPV1x0ote4F3XXECzni7zhhC8D6ny2Szw=@vger.kernel.org X-Gm-Message-State: AOJu0YxVwZ4BEih1I09pxXzm/NhoawCdcGRPn58F0/nGnY2fmQJYSARF ZDXmLFzpxolRXY4VTCMRG67Muw/DoZELq4TtpKdaS47YUOXwfDD77EFRsmYbZW+Vgqg= X-Gm-Gg: AY/fxX6D5UJ6JmxzCQWngrfM1KX9Xjv4tLJZkFfiZ6kqGaAbex8HM52NPDFEcfQCD20 p38GFRVactQkZsjP/Tmue53Ii9+PjpmfJfv5BNhrbDd+FNQKxpqux/Wyb9IYtPscA4sUS0HW/6V miTUK9fruqU8njYWz63wkKYAvOZthVs8rR/KucuyG/VX1TBS5OqREpwI0qT3CAsYAy2xLJrYq2/ mGPyxOse+UvwoZv/eE3WeYxEfTVcSWDoVbXjI3dxKI4ywimAPQgoT8xCi22i94SnwuXWbhW6AUG EyXsyn4PqGsa/bAN83NtPBKHfwrvYd5OWe82lahXkHLakSAY6LGMUXlkxqi3bBpjv1bf7/wnWzI Zvia2F1abKsFHStGOXU+YGTidmMRF4DKrYIbqz9o2gHNSs0F51qkIRum85KCncC4M/brn2t1Fbd p4TCNFCBTw5IsdlU44r9EY X-Google-Smtp-Source: AGHT+IGKOsI6qPk5daX8P1jxmI9pL8L+QcZ2sUXB0l9hmBt0/lTf0xmqKtrLbY0Q9t9jSG5KaAnb6w== X-Received: by 2002:a05:6402:35ce:b0:63c:3c63:75ed with SMTP id 4fb4d7f45d1cf-6499b1c6ab0mr2342038a12.22.1765553578761; Fri, 12 Dec 2025 07:32:58 -0800 (PST) Received: from e133063.arm.com ([130.185.218.160]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6498210ed32sm5433234a12.29.2025.12.12.07.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Dec 2025 07:32:58 -0800 (PST) From: James Clark Date: Fri, 12 Dec 2025 17:32:25 +0200 Subject: [PATCH v3 08/12] 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: <20251212-james-perf-config-bits-v3-8-aa36a4846776@linaro.org> References: <20251212-james-perf-config-bits-v3-0-aa36a4846776@linaro.org> In-Reply-To: <20251212-james-perf-config-bits-v3-0-aa36a4846776@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, James Clark , Leo Yan X-Mailer: b4 0.14.2 This pattern occurs a few times and we'll add another one later, so add a helper function for it. Reviewed-by: Leo Yan 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 ea891d12f8f40beebf8dee1d3db71cad701f5666..22c6272e8c367e5671809771b84= 1c5babe2d5282 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) @@ -476,29 +489,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 @@ -832,12 +837,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