From nobody Mon Dec 1 21:31:21 2025 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 6F7A83358A3 for ; Mon, 1 Dec 2025 16:41:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764607310; cv=none; b=HVCLmx9IojTkjBvPQ9aLFiyIhnxPfQazvftTUvqXGG5AGupSZwawesEy1M5m3J+d9LssC4/nOI6hmAmEsSl9H8aBglHww7PWfOs/VmmeNagPrbRfE67jxTMuIQ7Rh5UjKFkr0tjuVYo3SvG+vEqmOvTbMyCK+1YCL0EVBrIG2yg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764607310; c=relaxed/simple; bh=v7g+eJS8zgDENJl8497hl9tj8yvM2zLWTQWKh+fYsBw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oc/rf/1OExJy+m68o4xkOai4DnsIAyunOgi5CT6MU3/6z+mUVX7J04UgcXp42APZVGzVMqDXvQWSg7Y1uq5xWFsv82jG3urRGemDqTBJW/HZpqdFlei0BckMgkX+xwVxsLVZGFLzgzYIFdpUGJ/8BfS7LdTe7ger7OiHWfNYF5k= 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=SjqqXan+; arc=none smtp.client-ip=209.85.128.45 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="SjqqXan+" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-477770019e4so36837085e9.3 for ; Mon, 01 Dec 2025 08:41:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764607307; x=1765212107; 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=T/5T6lo313puZ/SVQF0jyUpNeCSlBosPw8CY0HUbC1E=; b=SjqqXan+P6pFlwYry25L8gAPCxe1+uiAcwa1xNRikjUmyUPbS7MgpfDgC3bDtwJEqd D991bXuMk6B9Shl0HvYs5fgGF0Yrn1UzPXRhghb8zDj6ZBNM9HOqIG45Ng14BWrl3q5S WQbGmnm6ksSxXsbQWziAJirA2mPhYeqxdGeiSrNBHMxDjeob/GygB0EOmU9xJDAf3Xnc ok07wnJHwmzIoHX7kl9YV9MGA03fUO1Rw1KlP+yZsxCdaRFW8wjZ9uWgRAtJBR52Eo/O hy/sbeBh6u9Kwi17Py2ErgAZxpaE5c7M8JSCkmDV117WjtXID9rRrDHJh3Kf49QqrWCd H8+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764607307; x=1765212107; 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=T/5T6lo313puZ/SVQF0jyUpNeCSlBosPw8CY0HUbC1E=; b=W+ishsaygdsvIRT0x4R2U4GkiI+CjDDkTn3s4AQj0JYZyEGySPhabvcgRutPl5rFnv OKR+9LgQzWO3CnOkUEQInORuUeUhzSwylQkXjv3GZMhgK8UAUVXzY0WJPoYFXolCkPH7 ooWlbH43a3uKxxYiAb1UwgO/RIgGD1ItGdbG8GTgiO1Vlt4m9Q5BGC98sRx85n1qUKBE caxlGuNXY7fyeLpi12flnx9NrHypwiZuUrs7ckAh7OILFgDGnvg4Lmbqcb+8agIm62ZZ MfLacjLouC4c1dXowM4p8UmCiFhKOCB+XQxHxk5DRboCmCqZbDF9IiCp8qdJTcnQZw5z VsRA== X-Forwarded-Encrypted: i=1; AJvYcCXQpckEXutxZn/ObNRldoxsYns0UGhwNx2DX97EebJihstXNBId2kYbIBW0YuGKKuTFTWN9806TkxDTsBo=@vger.kernel.org X-Gm-Message-State: AOJu0Ywds3BxhzUN1OkeSgX2elZ65lgBJEFloXIU0VwgkUiGkU5oywC7 OJSFbfT2//+bCYuLe0eGbuo7/cXZVdd2LXAzMV2Sc6t6aTInZbOhfxXk8edHRD2ExdzTN8BsIZ9 YVVtg X-Gm-Gg: ASbGncsenW8qWpT7NjNwAMm+H8t6g+QWA0iexWzkQh0/FR/D8QgnepKZlfizoCVocEh i1eAtUP1OdEoIBFRODK8xyYJMXvd6QmQek4olJbSWPNKU/+Y3zkcx/OE06mi0VXJqyIn/Y7y43S SBoGA4MVpIPl/aULU3uVSHSj7qWMTKTOuyRakjRElJOCKDU58Yvg9OS6LQSaC4LzarQrY8IWYZs YlO7cjwzFnXsjqC4PKN7CP1KA/+nNMJ72XXP8Z2oMVmsEzyk0VPnvSzjuP6Mq5MHsaali52cW3S Cu2wVMOl19wtRMIM+yOvYq5QcpsYZR3tNE+i50f0/rKchn9MhhGyBulJAusF9BjPXZZ2GC4PAkk if4Pkfphn+zgz7Sy0p2B7MtdSvldyPfR//Xq3QQMfilleiPWy5CaR/SGmPjDjqfjPUyGTC4f1vQ ZS8cWKwIk1HgzopBnPSWjm X-Google-Smtp-Source: AGHT+IEE3voa2OXjkQohxBlLJHCO8n9F+sDfMVLCHbry/3Vx/3/QnGHskYaS+QvFk8/708DyHCFFKQ== X-Received: by 2002:a05:600c:3587:b0:471:131f:85aa with SMTP id 5b1f17b1804b1-47904aecfd9mr268721295e9.13.1764607306655; Mon, 01 Dec 2025 08:41:46 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4791164d4f3sm255901275e9.13.2025.12.01.08.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 08:41:46 -0800 (PST) From: James Clark Date: Mon, 01 Dec 2025 16:41:06 +0000 Subject: [PATCH 3/7] 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: <20251201-james-perf-config-bits-v1-3-22ecbbf8007c@linaro.org> References: <20251201-james-perf-config-bits-v1-0-22ecbbf8007c@linaro.org> In-Reply-To: <20251201-james-perf-config-bits-v1-0-22ecbbf8007c@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 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. 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 ea891d12f8f4..22c6272e8c36 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