From nobody Mon Sep 28 13:19:00 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 7485F471420 for ; Fri, 21 Aug 2026 09:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305849; cv=none; b=uG6e8GvFEqc/xdqyglcmxyihYoXSrdT4yxXVS/xEAvdajst2jOl7THAXTJmx+hOZ4awJOZpKJkpy4+rdgi/KhIEgfSREZ3R84SlBCtc0WYVWI7VpDvfNs9y9fpZS9yAmc9GzwZB5gF90Jkl0yw/bqviNWrk58fBBdk+5aUpyOQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305849; c=relaxed/simple; bh=DfHVRgZKJo7FcaZJs/rrBeFqWYYg2Q9WHniNMVQc3K0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kn8Jqp4J4YsEUs/5vbHCi5x7ffWuefEVWXhskMKFghYDWw+Uf8V4p+R+l5cKRXgCrIJuAAsZr5kfPyAlp+yWUSWwpD4NvJW59ONZ3oRpFtH3iWfUD9tQYNapQ/iuTvn39G67bKFZXo3xRYHQEL386e3Hpc2szdMu4+vbhY0tiHM= 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=SBNhXCTS; arc=none smtp.client-ip=209.85.221.52 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="SBNhXCTS" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-47fe377a217so461726f8f.1 for ; Fri, 21 Aug 2026 02:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1787305842; x=1787910642; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rihT5LklrtpR0kzEsT66cm8MSESBfy35sRA2IEprsPg=; b=SBNhXCTSR25JZ7UzS/C9SkF4f3qxDddUBKKXeIsvWa4o0GV1U/lnNTznotjlYIsUPQ x3hxcCh4YfOKoyRP8BcJhUdwGJDrgRsOABpFnlEb2hFFwwBeyKgCitTWvslnfbHD9Nqs gsC9DNTe0UnfS2pOBcPSqBqNcpdcMd34AfydMAcovOCsXGN5HnDknAyFffCB2FpQw7AD kWQZ78eqJJObo+EZ0hqHd3P+OP/xccjNJu0Tk/3dzD0vPG/tVVTAgIuDJoU5XocFq5aj KWEyzMK7nvhat33mlontfFbWpFhV2Xm5Y8dRKMbeGlV0Ltjc7Zkx9hJMphEvc7quSlSx 8G+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787305842; x=1787910642; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rihT5LklrtpR0kzEsT66cm8MSESBfy35sRA2IEprsPg=; b=b467I+A0h/GiuWilhjrvFXIxGiqkgmN9h93NqPL9PWPlMH3Xpr5W2xLBtvgWK62nJM LnAX2VPZUaBJg663TLLBC1HWa5bQZQAkV6jQjjYlNn9Hr1DmgIegfY+XGD/iFbxopApa sYpviXImkkjPMWrAfBNOVpS12XsAvz7B0OB5Xi0GJZOoSrrDKyWAjQ7a8AeCl33UK2kW m61PYP7E4Np2/1FrMwHlSjGfM4yEI3ZbUXIi327oaDcgAqLMp4eVh8FDh1x9Z+g1TjWB v6me7C3+cmDxtk1CaEzxsmStDAYr2yk9IeiCFAiGBy/PWoogrWDXWkLR9SngQANST/Ge Wl3w== X-Forwarded-Encrypted: i=1; AHgh+RpPPtNJKBsF0cWvFSWmKL2794qtVFeuDMiR7NcP/maaLJTOWF+Ft594nTAYq6RJb+CPKVX92sasIhZi4Cg=@vger.kernel.org X-Gm-Message-State: AOJu0Ywe7+A5J6SwuUUYIQl6/1DZkAhuS9DStAhXm7hZfPwFhjpL6bi1 tMdz4MJFPVafBaRgJ05sFRmCM5OX++IDF2GCWmbxFPeUeipaquNXe3UQSK9gtxNpWgU= X-Gm-Gg: AR+sD11iSNTXm4lLIIKkiM68lma6yOJkzwjAsBeqPy/gtFTCAMoRTtPTd97mIiGE9RY vOM95A6+XaiBdZet01y0DyTWt6NeTt19dvfX9k1jiDWzR8C3Rj2/rQYPVUo9lxZMv4Hb1iKdJgT 99vGSTB/JlHkkc9xu71P0GWLy2PSvbUgvwvabNzkCXZt9gpuIZiJAsvTs78Pvn54sn9DNCqoOHN ouYbU+EI72YrJSSZp0f1Ka5SAwYVNIjTZvd8FUyVKGmwCz1+eTAiy5F3CFzgsAJ/sdZhZOuDEDB 5bTgS154YBW9d/zs3/65xWbBDvjIsPKOTeZnqaQ8x3d4NZd/TIQgPINsJTmZOG7Xf3bECdyIku1 O4yohGNJQ3TYBj6zdLMKgm7dEgFkuwS7kZ1/0bP/6Y3wQLWSGdncDEDi5Pw6VoCBpRe6r7AVqVJ mFO3tetoA5ogWp7WwmdcjSfcPdh9HNF/DkkLxNong3WrsjS0j8MxB80/jG3tD5GTvn X-Received: by 2002:a05:600c:1384:b0:493:e365:7630 with SMTP id 5b1f17b1804b1-499b84618f0mr55399775e9.14.1787305841820; Fri, 21 Aug 2026 02:50:41 -0700 (PDT) Received: from pop-os.local ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482b14c3775sm14474284f8f.26.2026.08.21.02.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 02:50:41 -0700 (PDT) From: James Clark Date: Fri, 21 Aug 2026 10:50:29 +0100 Subject: [PATCH 1/6] perf: cs-etm: Don't add global v0 HW_IDs to unformatted queues 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: <20260821-james-cs-hw_id-output-failure-v1-1-9d532ddabcc3@linaro.org> References: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> In-Reply-To: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> To: John Garry , Will Deacon , Mike Leach , Leo Yan , Suzuki K Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Suyash Mahar , Amir Ayupov Cc: Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.15.2 In the case of mixed formatted and unformatted trace with v0 HW_IDs, or no HW_IDs at all resulting in the cs_etm__map_trace_ids_metadata() fallback, formatted queues will write their HW_IDs to unformatted queues. This will result in an assert because of multiple decoders on an unformatted queue. Fix it by not inserting trace ID nodes on other unformatted queues. This isn't an issue for v0.1 HW_IDs because they aren't global so will only add to their own queue. Fixes: 19c3e4db38c5 ("perf: cs-etm: Create decoders based on the trace ID m= appings") Signed-off-by: James Clark --- tools/perf/util/cs-etm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 6e04602ec204..8dfafd389066 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -306,27 +306,27 @@ static int cs_etm__map_trace_id_v0(struct cs_etm_auxt= race *etm, u8 trace_chan_id { struct cs_etm_queue *etmq; =20 - /* - * If the queue is unformatted then only save one mapping in the - * queue associated with that CPU so only one decoder is made. - */ etmq =3D cs_etm__get_queue(etm, cpu_metadata[CS_ETM_CPU]); if (!etmq) return -EINVAL; =20 + /* + * If the queue is unformatted then only save one mapping in the + * queue associated with that CPU so only one decoder is made. + */ if (etmq->format =3D=3D UNFORMATTED) return cs_etm__insert_trace_id_node(etmq, trace_chan_id, cpu_metadata); =20 /* * Otherwise, version 0 trace IDs are global so save them into every - * queue. + * formatted queue. */ for (unsigned int i =3D 0; i < etm->queues.nr_queues; ++i) { int ret; =20 etmq =3D etm->queues.queue_array[i].priv; - if (!etmq) + if (!etmq || etmq->format =3D=3D UNFORMATTED) continue; =20 ret =3D cs_etm__insert_trace_id_node(etmq, trace_chan_id, --=20 2.43.0 From nobody Mon Sep 28 13:19:00 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 2329544C64E for ; Fri, 21 Aug 2026 09:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305851; cv=none; b=VOBV8kN8H/7HIJMtWBlTjOPNi62e+SV89D55aEi+WHjVniNZ/VZBsDKgftzhdS+N/mmsfiIzNlB20dwwY3rPysvwPAupNSdeZ89gyoufAP0rBD+7UY++bsiTPLFZBqwzSHG21TDrawU7w5Sp9AX2XeNZIsu8wqlAEu0No++2vC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305851; c=relaxed/simple; bh=sb43BObHmZtyjwQ9/BEH9eWIoM2A8l6ZE+2UO2Ce/ws=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qE80WT+gfIsKnd3FCR7nKHyt+M4c3xZIOmKnDhLQCK8vnFypCDYdHIn1MUbBWaaAR6zG89fVIDKmb1cqZo4CvydTqgGtOXIiKlTiZ4aGTDKaIvo8wnOmzxzmc4GfblsZ3n2Dyl7hCgKDgn6NRg7fo2jhIWElF6pmU9WKO+PERHk= 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=oJzAfbkE; arc=none smtp.client-ip=209.85.128.48 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="oJzAfbkE" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-499b0eefa61so4514245e9.2 for ; Fri, 21 Aug 2026 02:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1787305843; x=1787910643; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hYjd0xAS1cNSY6XVrkyFUu4UCXh5rU8Z/1PEhyvhecM=; b=oJzAfbkEwSf/KcRGron2V905MsO69g9WfquV7hTmOlUq3MgqtjyrOdtigWbVJ75kL9 jWXhd7adrcylQBI5X0eJWRl1Eis0q1jnShfkNA0RtyPwfJNnohKbVVb8He06zGK/jgj1 eTMD2wfVJ/sTRodN3FxwWfT1IOt1MbO5fhwBJmeTKDUF6gJ8QF/x7JDU2vwbWJQz3weI M6pu1oo/Dzy7SnDCzWIW+FLDPzwujCCxm95W+SPeKwE6hz3DvQOZvdL+30ofo1Pla3aL uWg6fXbo8MojmP/dj4bQsqn0y0g6O9h2kvFuxNyIeX4WphjBlOemst76dtiEuwSWcXdf Cypw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787305843; x=1787910643; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hYjd0xAS1cNSY6XVrkyFUu4UCXh5rU8Z/1PEhyvhecM=; b=J9A9S+NpBYpPu/FCegGY3I7fUs1zMjU6hXYaRSakm4l32jdJEYqxoOrSf42y+a/Sq9 zeO+udnQIjdLbUcTrMiZap0UbTkv9gbTCWskVU1l4B5eToAvJx3FjBWoNy6FHHMmpSkd c5Maa0jqScAYSDZq+XM7jUSbXXLIma6RwgUD5nLOcPa2A72qFAAOwit2U+zbMmZFqx87 6ExFVDrfNFh5oqYZksnXbSshqWiGQ4CRwluT3UKCzKaC9F/54t8WJeFXEFv03sZqp4cB uN2ftISRT/+YpbIn6Y6NYyheEdFVUJmx3R3/nUIIoKFiObCyIKCAG9PX/KRAkEXJJGJ5 K5Sw== X-Forwarded-Encrypted: i=1; AHgh+RqzWgl9VJsq7PLvhWdSvAnImkeXXpac26DX70pk7NlAFJgmBNSZAMq/4YLYERVSd3GFWtlfdG6/xXtn9hI=@vger.kernel.org X-Gm-Message-State: AOJu0YwTAGHN9jw2BdspAGSy7ZomQTCj5YKsOZ5tG58hYQX/duwWnBt/ YpurgvGE4I3H0qk+5v8DkOFeoiP+rr5du1Qt6ppCrbCmjU8brn1s03HKI6F4haN3OT8= X-Gm-Gg: AR+sD12hUbC+qsFtQ+sU2kkAuqBpU84Unzb5X5CK93vdLx+CokD94jBfT6S6fKFFCEj x7opsEx7d8BiaMh30xTZH378pfyZloEQdu770Jcv2X7eW+pWl3l6+8+7wuLBMD6jNsyhFj8mOG8 KZXsW5JMlfp3UOf1BJmq0w1wN7R5cjDgNseTu3Ox1H5Tfr2OCTHI+C/y6D4B5OYXf7N682tz88U udWfGuRmqWpbRhApe8u4PorVgAiOzzpTQOL0nIFwvnoD+ikUrxKhc/QJTXPSw3q4pqLxuN06M68 xgnN56BuOYGlczfbOejfUxCFVodb5ysCLMJWl2jqi5iBbweX7C2IrOS/DfnkTKKF5NKIac/8gTq 2z5UbWEiD5gy5CM6SKe7aOXZk96ByxHGXER0kUu1XbpaKLg29NnYdUnuJLovzBcWiaw+nJuUSK/ SbI9s4wy27OAB5OmbhxED/ezTnJulYZfbWJY+/YubsHF21ynsAi6IoeOlSJyMTH8TPNF5H9PL/J l8= X-Received: by 2002:a05:600c:c4b7:b0:499:900c:9c68 with SMTP id 5b1f17b1804b1-499b8310653mr65038535e9.6.1787305842976; Fri, 21 Aug 2026 02:50:42 -0700 (PDT) Received: from pop-os.local ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482b14c3775sm14474284f8f.26.2026.08.21.02.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 02:50:42 -0700 (PDT) From: James Clark Date: Fri, 21 Aug 2026 10:50:30 +0100 Subject: [PATCH 2/6] perf cs-etm: Free partially created queues 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: <20260821-james-cs-hw_id-output-failure-v1-2-9d532ddabcc3@linaro.org> References: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> In-Reply-To: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> To: John Garry , Will Deacon , Mike Leach , Leo Yan , Suzuki K Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Suyash Mahar , Amir Ayupov Cc: Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.15.2 cs_etm__create_decoders() can fail half way through and the err_free_queues label won't free them. Call the full queue free function here instead. If no decoders were created it's a nop. Signed-off-by: James Clark Reviewed-by: Leo Yan --- tools/perf/util/cs-etm.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 8dfafd389066..44e20067da1f 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1014,13 +1014,10 @@ static void cs_etm__free_queue(void *priv) free(etmq); } =20 -static void cs_etm__free_events(struct perf_session *session) +static void cs_etm__free_queues(struct cs_etm_auxtrace *etm) { unsigned int i; - struct cs_etm_auxtrace *aux =3D container_of(session->auxtrace, - struct cs_etm_auxtrace, - auxtrace); - struct auxtrace_queues *queues =3D &aux->queues; + struct auxtrace_queues *queues =3D &etm->queues; =20 for (i =3D 0; i < queues->nr_queues; i++) { cs_etm__free_queue(queues->queue_array[i].priv); @@ -1030,13 +1027,23 @@ static void cs_etm__free_events(struct perf_session= *session) auxtrace_queues__free(queues); } =20 +static void cs_etm__free_events(struct perf_session *session) +{ + struct cs_etm_auxtrace *aux =3D container_of(session->auxtrace, + struct cs_etm_auxtrace, + auxtrace); + + cs_etm__free_queues(aux); +} + static void cs_etm__free(struct perf_session *session) { int i; struct cs_etm_auxtrace *aux =3D container_of(session->auxtrace, struct cs_etm_auxtrace, auxtrace); - cs_etm__free_events(session); + + cs_etm__free_queues(aux); session->auxtrace =3D NULL; =20 for (i =3D 0; i < aux->num_cpu; i++) @@ -3520,6 +3527,7 @@ static int cs_etm__create_queue_decoders(struct cs_et= m_queue *etmq) =20 out_free_decoder: cs_etm_decoder__free(etmq->decoder); + etmq->decoder =3D NULL; out_free: zfree(&t_params); return -EINVAL; @@ -3801,7 +3809,7 @@ int cs_etm__process_auxtrace_info_full(union perf_eve= nt *event, return 0; =20 err_free_queues: - auxtrace_queues__free(&etm->queues); + cs_etm__free_queues(etm); session->auxtrace =3D NULL; err_free_etm: zfree(&etm); --=20 2.43.0 From nobody Mon Sep 28 13:19:00 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 BBA6B472549 for ; Fri, 21 Aug 2026 09:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305859; cv=none; b=sg7y8Wsz0TsnF0RnnKQ+ozociXvaKnpJKuqQVxq9ny4MawrGpZWTWFyvPqto7EdwNxbfW1YvUkrtQ6w4HW7wtXjfa2XIFmmQ03USSliLGu3ecqoRSnFpgFYXbUWZApMSQ2XeGVy9JzHnMUd8AyxanV6Z0pJlh7l47+NjFltn5Cw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305859; c=relaxed/simple; bh=reIErwj1+cOWTcSHBC5mNblnE1436q/H5bkvt6GtBUI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FMwQHot4B9PEy+tfdAWNb40PqBvl1MNJwS1QFT8Ken1HRk2AtgkadpaJwwMMRsPSWQ1D3UEjNCrmHQ9amvQoo/eTSzqYibVB/2JLwZrYtc3P6E5qY2CWXZagMYong+XJR53BnsnOz1xdchJq4YDcggJdu0u0zupFiPsESc9o3zI= 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=L3CZjypT; arc=none smtp.client-ip=209.85.221.48 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="L3CZjypT" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-47fd4531020so473570f8f.3 for ; Fri, 21 Aug 2026 02:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1787305845; x=1787910645; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3VQqnhce33GsylOL+ZatKl0byJTqhAxHVQiF8A3WGaU=; b=L3CZjypTRXw+6MZY3/FVGuIR94VR3e0Se832UUivRCOuvk56hGllbtx+IWZbr855G/ /0YWfogmt7NmOCHj6UG/DDByicOkbgdanWSe02SDmHqqGGwF7IzwscMS2iFWb9IGu+uA xi4x7tFISVQP/TnN8xIBskXiAVRRdztgMNVGh/jqYx25PYJpyEAqAfWWEX6Fj7SLWdAG nzSg5Y2xvHr9A/+hrzIKboGeZqG372KROx1gq0c41H+Rmh26fcFr3AaPOvNDLQM0VWyH 6Q1JLJgRqVJHTvtjb6jtrwBDhC4TLa3H5NqHIpRa5UDlsRKuku+/D2ScQPJ17Oea7FNz pkBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787305845; x=1787910645; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3VQqnhce33GsylOL+ZatKl0byJTqhAxHVQiF8A3WGaU=; b=HG7852kLJ+fFWriizIAq6wybqzLhla6sF+jEm1AfcmroM1s1ZUFExSSJwEh1sHeINB EUHA8jYf2xZte0Tm1mhXhkdK8/IqA07cVQmu1+s45iNKQAbGSiK0fWJ+SJAUWqxi9Sc3 rffXBNEwPvheRffDO2NRrQlpOoI1U2iUkoo9Wzx253ZHZ6i0I3Qqj6qHm3jsCMvLyVZM yWQlPuMIOIAtEQw6mc+CffHV3/DhL627//246ofuX6YxUQz6VqqV9Uu+fEltO2y3JsI3 7q9xVmPgaRAVNPD1FLCsN+rCXPOU/CBIc+WsSlLV9ghjCvVhlIDxiCybnEMbFkhJP961 qHkg== X-Forwarded-Encrypted: i=1; AHgh+Rp4qPO7eo94yleyvQi2pGXSxKcZjfpwAEYHf1haDMWThnWxyOMTTVEl9YUntRMj1NSokRIXX0t/CLM71AM=@vger.kernel.org X-Gm-Message-State: AFuF++nfwi2/utdn6H/t7EzvXL5L5vi7aJZaejPLV8yp+ZgLfsoRH3LV SbPPNV+GxcAAPyCTNChO54sLuym2hcDXYyJN5mc9MrPbmO4qwrE9kraZzxSA6/vZ7t0= X-Gm-Gg: AR+sD13JNTX4pCkd2AppbkHI3Vf4XxjrSv1z/lnMDSSY0u+VwJdmQ1tKwoprrlYv1eY y59BctvrRoNvmBf+V/HGTrhzDwx+Y7QjPREHgIttoZtW8rM3rSldFM+AwCSP1ad9IMmbGS2AIZn Wdo87V1okCQprYHKBi3PMou1ljG8yQL1brwmoWMeBXQog1HLm+6mHJmtqaZnnwdr9vsNZ1+bz/j Yz2LC8tG+WIDNDaA9a6z+5ovzU7PexFHG6BUaIcKPtyhdPnKGC60wEmrXb8AFUh2k8041h6RSSP r6oNJSAo5ShhtP7SV3KosxQMCccY4QO+qVa54IE9jK7lLW8A8NbO3MKQCugYqgX83likczYs7Ja ZTpxB0Pu+nSLvLnRfPHN/QoEhIX13C36MHW+GwteNG7szv099+cW35DurYe8TxALt67xpjEsQgn IeaqdiMj5nJ0cfMowotqx/FqOfwa+seyFCfzdqiJQnLcqdPUHdQ2CDwbhu48R0raOh X-Received: by 2002:a05:6000:420c:b0:47f:eb5c:9b25 with SMTP id ffacd0b85a97d-482c0b83b3fmr6279797f8f.10.1787305844266; Fri, 21 Aug 2026 02:50:44 -0700 (PDT) Received: from pop-os.local ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482b14c3775sm14474284f8f.26.2026.08.21.02.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 02:50:43 -0700 (PDT) From: James Clark Date: Fri, 21 Aug 2026 10:50:31 +0100 Subject: [PATCH 3/6] perf cs-etm: Synthesize missing HW_ID mappings for raw trace 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: <20260821-james-cs-hw_id-output-failure-v1-3-9d532ddabcc3@linaro.org> References: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> In-Reply-To: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> To: John Garry , Will Deacon , Mike Leach , Leo Yan , Suzuki K Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Suyash Mahar , Amir Ayupov Cc: Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.15.2 From: Leo Yan The CoreSight driver emits PERF_RECORD_AUX_OUTPUT_HW_ID via perf_report_aux_output_id(). If the perf ring buffer is full, perf_report_aux_output_id() can fail to emit the record and return silently. When at least one HW_ID record is present in the file, perf skips the legacy metadata-only trace ID mapping path. Therefore any raw AUX queue whose HW_ID record was dropped can be left with an empty traceid_list, and cs_etm__create_queue_decoders() will not create a decoder for that queue. Backfill missing mappings for non-empty UNFORMATTED queues whose trace ID map is still empty after the HW_ID record scan. Real HW_ID mappings remain preferred and are not overwritten in case someone is trying to link what the kernel outputs to the raw trace dump. Signed-off-by: Leo Yan Signed-off-by: James Clark --- tools/perf/util/cs-etm.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 44e20067da1f..dd15e91b7b38 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -427,6 +427,39 @@ static int cs_etm__process_trace_id_v0_1(struct cs_etm= _auxtrace *etm, int cpu, return 0; } =20 +static int cs_etm__synth_unformatted_trace_ids(struct cs_etm_auxtrace *etm) +{ + struct auxtrace_queues *queues =3D &etm->queues; + + for (unsigned int i =3D 0; i < queues->nr_queues; i++) { + struct auxtrace_queue *queue =3D &queues->queue_array[i]; + struct cs_etm_queue *etmq =3D queue->priv; + u64 *cpu_data; + u8 trace_id; + int ret; + + if (list_empty(&queue->head) || !etmq || etmq->format !=3D UNFORMATTED) + continue; + + if (!intlist__empty(etmq->traceid_list)) + continue; + + cpu_data =3D get_cpu_data(etm, queue->cpu); + if (!cpu_data) + return -EINVAL; + + ret =3D cs_etm__metadata_get_trace_id(&trace_id, cpu_data); + if (ret) + return ret; + + ret =3D cs_etm__insert_trace_id_node(etmq, trace_id, cpu_data); + if (ret) + return ret; + } + + return 0; +} + static int cs_etm__metadata_get_trace_id(u8 *trace_chan_id, u64 *cpu_metad= ata) { u64 cs_etm_magic =3D cpu_metadata[CS_ETM_MAGIC]; @@ -3801,6 +3834,16 @@ int cs_etm__process_auxtrace_info_full(union perf_ev= ent *event, goto err_free_queues; } =20 + /* + * Add fake IDs for any unformatted queues missing them. The IDs + * themselves are only cosmetic in unformatted mode (raw dump output), + * but a decoder won't be created if one was dropped and Perf can be + * resilient to this. + */ + err =3D cs_etm__synth_unformatted_trace_ids(etm); + if (err) + goto err_free_queues; + err =3D cs_etm__create_decoders(etm); if (err) goto err_free_queues; --=20 2.43.0 From nobody Mon Sep 28 13:19:00 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 18A1446EF8D for ; Fri, 21 Aug 2026 09:50:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305852; cv=none; b=kMTsx1yZRHGbVioiE6VMDwVQajQT7bV60Nhl+S3jHniHn0Mg/Eefrl0HmqcrYuj0bLoXsZKQpk+nmSe2S8MMQ+2MK8A0s3/bo7XxjNR6AoMRYToCOX1Am5QHqji75et+rWTjrZwWQXH9sP63VaNzictYc8Pt2V/u6+cLPEwNcsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305852; c=relaxed/simple; bh=eLC8UWZIkmq+sG72ewDJLEWgWUKo/OduZ+n7icvyCCo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qoJNAfVPKFsMBAglSIfD/4F9ZQQdrW7DKHPcIbnjIY3F7ZuD5ZSwOve9hy/qcvXvdZzMY3fpzmDj3oBlSjyYsPqxEjQNqPgc60EhlPeXw69u4JsFVcj7TuJbLojSahDksRR53urZmbzijXNVyPi2cl9gfjKHEN78NEcl0hqIsFI= 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=uufovCjf; arc=none smtp.client-ip=209.85.221.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="uufovCjf" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-472326ca506so504040f8f.2 for ; Fri, 21 Aug 2026 02:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1787305846; x=1787910646; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tSigklk0YY/8y8Y825wPuagaBgws2jxeudbXBTBNYx8=; b=uufovCjfjM3Y3ZWBFs+4nE6yOiAM+KbYR5xxxuDsbvF8izdfOAqQZlBBHo/WApuzWL fUUOx85NX3DPkkCJRTtK3qfizHRZ6qav3TNR9wza+YNUYOW0WgIgEhcrPjlTdvwsLcAq 9JRYxjCCet5xkl2wpYm4cJqcB4aX4pKiFi/DAIv526FZ5Qlq8Uk/UueaI6DQsIMcSqCW sleayPTYfzWdwlPJtQSb08RNu2mfAY6nFKRPbIiqI5IN+8EyKmVFbEieq93ujPSL/I02 XNIZK1AtTM3eCTqpEV//HjSTas+/bm9NYB7gEBnRqLT339KqNBzb8oWD2uB09e0wTac/ M8Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787305846; x=1787910646; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tSigklk0YY/8y8Y825wPuagaBgws2jxeudbXBTBNYx8=; b=NmzRaX1WY9FUl3SlxBoZ/p4js/8cb0SDT6+bAJUR8SMIUkjiLnh8jDQYrwOlvOn5Sq 15CTV6KX3ORhds42Ee2AHOjVIvEZFizByHS91sXOSHZE5ld023gdAMHE4c//Mkg4Dirj 0SpX7lN2jL8NE3l5h4ro+y99zJMruZtaDIZPRNBcZTKrbWKOwO/7rg4XUlZpup6TwO+C Ul29u9hjjhZMYnz02pL6iVWfH69GsabmT8R7SO105tIoTZ7OBgYCc1eekmuogj1AAyQP L9oYFgw3VP22H11Ldh93x9sFehyl65oQ/xF/A3HcfkswIs0kdEoKosID6xG4Tzmomoka k1Mg== X-Forwarded-Encrypted: i=1; AHgh+RrP9pGVl6RxH8GTN91J6dmGLgwr4MAPtqW9RM17m/YtAnNBAShj2pRC1ttcsfxcOqRRZoQgibGP2ZrsmC4=@vger.kernel.org X-Gm-Message-State: AFuF++lbPsrmukgWW+a2jnvldFqY1LhHZbH8YMNNHWmVRZz/szPdk2Mf 3nAO3Kl8afP7Pf4mH8zHoH8NmgjgTP9NBCjp569jTzA4hD+z32XO7toePgTuzX7lbc8= X-Gm-Gg: AR+sD11YlSaD2DxvP8makMNwYbcOxqe8bmd3HbEnjPKgNzCw8yqs0FxaQRaOtHW4c3D fIXLXv89CUDickuQYQMlqf6ePjuH15/OeNYzDZXQurAIkrkKtlo59+E/RJzbN72mpJ32PcEhSiw Ecazm7lCvC6PiP5mlqjAqPQJT4UJNH/N+wnTrp2wvOY3im0nzpw9gERMq0mbnriRlhmrqYHL4gI Q1jpDtDtLgGnDhmQHk6Ar4hkj9Vxo65jaLaM3NEAJRA6KXL76JbpXzXr1ImlsYZ/j2JYVDI1wx9 yDcah7FYoqKic9s7elFGYQ+9vqsm8DP4+keXwzSLz/KjiQEsqZSLGwI7FaVrUy9/mR4jQAYAqmB Vpdr+GACfBkIi+phZ9y/JM+XnTM+deVNG4kgGjzQoBJW4ZeXv7oi3xl17YRj2tNESx1s+gdSrXh kto3Y84JC/UNWtnrRsi+QSUVw9f6gcM1eBM9g/qu+kP8g6hh24jw64fJJfoI6yoGYE X-Received: by 2002:adf:e193:0:b0:47f:e760:e5b9 with SMTP id ffacd0b85a97d-482c0ba3a3amr7830202f8f.18.1787305846313; Fri, 21 Aug 2026 02:50:46 -0700 (PDT) Received: from pop-os.local ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482b14c3775sm14474284f8f.26.2026.08.21.02.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 02:50:45 -0700 (PDT) From: James Clark Date: Fri, 21 Aug 2026 10:50:32 +0100 Subject: [PATCH 4/6] perf: cs-etm: Respect --no-itrace option 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: <20260821-james-cs-hw_id-output-failure-v1-4-9d532ddabcc3@linaro.org> References: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> In-Reply-To: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> To: John Garry , Will Deacon , Mike Leach , Leo Yan , Suzuki K Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Suyash Mahar , Amir Ayupov Cc: Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.15.2 If there is a bug in decoding then Perf will exit early and you can't investigate by using the raw dump mode. Make the --no-itrace option stop Coresight decoding after printing the aux header so decode errors don't stop the rest of the samples being printed. pmu_type and evsel_is_auxtrace need to be set so that the unleader_auxtrace() behavior is the same as without --no-itrace. Signed-off-by: James Clark Reviewed-by: Adrian Hunter --- tools/perf/util/auxtrace.c | 2 +- tools/perf/util/auxtrace.h | 1 + tools/perf/util/cs-etm.c | 66 +++++++++++++++++++++++++-----------------= ---- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index e3c770b46e94..caa53056d349 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -123,7 +123,7 @@ static int evlist__regroup(struct evlist *evlist, struc= t evsel *leader, struct e return 0; } =20 -static bool auxtrace__dont_decode(struct perf_session *session) +bool auxtrace__dont_decode(struct perf_session *session) { return !session->itrace_synth_opts || session->itrace_synth_opts->dont_decode; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 971b817d3396..47fb97136836 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -651,6 +651,7 @@ void auxtrace__free(struct perf_session *session); bool auxtrace__evsel_is_auxtrace(struct perf_session *session, struct evsel *evsel); u64 auxtrace_synth_id_range_start(struct evsel *evsel); +bool auxtrace__dont_decode(struct perf_session *session); =20 #define ITRACE_HELP \ " i[period]: synthesize instructions events\n" \ diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index dd15e91b7b38..22884c9fdff8 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -969,7 +969,7 @@ static int cs_etm__flush_events(struct perf_session *se= ssion, struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, auxtrace); - if (dump_trace) + if (dump_trace || auxtrace__dont_decode(session)) return 0; =20 if (!tool->ordered_events) @@ -3040,7 +3040,7 @@ static int cs_etm__process_event(struct perf_session = *session, struct cs_etm_auxtrace, auxtrace); =20 - if (dump_trace) + if (dump_trace || auxtrace__dont_decode(session)) return 0; =20 if (!tool->ordered_events) { @@ -3603,27 +3603,49 @@ int cs_etm__process_auxtrace_info_full(union perf_e= vent *event, int err =3D 0; int aux_hw_id_found; int i; - u64 *ptr =3D NULL; + u64 *ptr =3D (u64 *) auxtrace_info->priv; u64 **metadata =3D NULL; =20 - /* First the global part */ - ptr =3D (u64 *) auxtrace_info->priv; - num_cpu =3D ptr[CS_PMU_TYPE_CPUS] & 0xffffffff; + etm =3D zalloc(sizeof(*etm)); + if (!etm) + return -ENOMEM; + + session->auxtrace =3D &etm->auxtrace; + etm->auxtrace.free =3D cs_etm__free; + etm->auxtrace.evsel_is_auxtrace =3D cs_etm__evsel_is_auxtrace; + etm->auxtrace.process_event =3D cs_etm__process_event; + etm->auxtrace.process_auxtrace_event =3D cs_etm__process_auxtrace_event; + etm->auxtrace.flush_events =3D cs_etm__flush_events; + etm->auxtrace.free_events =3D cs_etm__free_events; + etm->pmu_type =3D (unsigned int) ((ptr[CS_PMU_TYPE_CPUS] >> 32) & 0xfffff= fff); + + /* + * Don't go further than the minimum required to identify this event as + * auxtrace with cs_etm__evsel_is_auxtrace() so unleader_auxtrace() + * works. + */ + if (auxtrace__dont_decode(session)) + return 0; =20 /* * Bound num_cpu by the event size: the global header consumes * CS_ETM_HEADER_SIZE bytes, and each CPU needs at least one u64 * metadata entry after that. */ + num_cpu =3D ptr[CS_PMU_TYPE_CPUS] & 0xffffffff; priv_size =3D total_size - event_header_size - INFO_HEADER_SIZE - CS_ETM_HEADER_SIZE; if (num_cpu <=3D 0 || priv_size <=3D 0 || - num_cpu > priv_size / (int)sizeof(u64)) - return -EINVAL; + num_cpu > priv_size / (int)sizeof(u64)) { + err =3D -EINVAL; + goto err_free_etm; + } =20 metadata =3D zalloc(sizeof(*metadata) * num_cpu); - if (!metadata) - return -ENOMEM; + if (!metadata) { + err =3D -ENOMEM; + goto err_free_etm; + } =20 /* Start parsing after the common part of the header */ i =3D CS_HEADER_VERSION_MAX; @@ -3682,13 +3704,6 @@ int cs_etm__process_auxtrace_info_full(union perf_ev= ent *event, goto err_free_metadata; } =20 - etm =3D zalloc(sizeof(*etm)); - - if (!etm) { - err =3D -ENOMEM; - goto err_free_metadata; - } - /* * As all the ETMs run at the same exception level, the system should * have the same PID format crossing CPUs. So cache the PID format @@ -3698,7 +3713,7 @@ int cs_etm__process_auxtrace_info_full(union perf_eve= nt *event, =20 err =3D auxtrace_queues__init_nr(&etm->queues, max_cpu + 1); if (err) - goto err_free_etm; + goto err_free_metadata; =20 for (unsigned int j =3D 0; j < etm->queues.nr_queues; ++j) { err =3D cs_etm__setup_queue(etm, &etm->queues.queue_array[j], j); @@ -3736,7 +3751,6 @@ int cs_etm__process_auxtrace_info_full(union perf_eve= nt *event, etm->session =3D session; =20 etm->num_cpu =3D num_cpu; - etm->pmu_type =3D (unsigned int) ((ptr[CS_PMU_TYPE_CPUS] >> 32) & 0xfffff= fff); etm->snapshot_mode =3D (ptr[CS_ETM_SNAPSHOT] !=3D 0); etm->metadata =3D metadata; etm->auxtrace_type =3D auxtrace_info->type; @@ -3763,14 +3777,6 @@ int cs_etm__process_auxtrace_info_full(union perf_ev= ent *event, "you can specify the itrace option 'T' for timestamp decoding\n" "if the Coresight timestamp on the platform is same with the kernel= time.\n\n"); =20 - etm->auxtrace.process_event =3D cs_etm__process_event; - etm->auxtrace.process_auxtrace_event =3D cs_etm__process_auxtrace_event; - etm->auxtrace.flush_events =3D cs_etm__flush_events; - etm->auxtrace.free_events =3D cs_etm__free_events; - etm->auxtrace.free =3D cs_etm__free; - etm->auxtrace.evsel_is_auxtrace =3D cs_etm__evsel_is_auxtrace; - session->auxtrace =3D &etm->auxtrace; - cs_etm__setup_timeless_decoding(etm); =20 etm->tc.time_shift =3D tc->time_shift; @@ -3853,13 +3859,13 @@ int cs_etm__process_auxtrace_info_full(union perf_e= vent *event, =20 err_free_queues: cs_etm__free_queues(etm); - session->auxtrace =3D NULL; -err_free_etm: - zfree(&etm); err_free_metadata: /* No need to check @metadata[j], free(NULL) is supported */ for (int j =3D 0; j < num_cpu; j++) zfree(&metadata[j]); zfree(&metadata); +err_free_etm: + session->auxtrace =3D NULL; + zfree(&etm); return err; } --=20 2.43.0 From nobody Mon Sep 28 13:19:00 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 C319E4519A5 for ; Fri, 21 Aug 2026 09:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305856; cv=none; b=h1g0YOjgfKWaVmmnSzujJng7Y5nr+qsKRl3xJXDRbZ42bNL8Pf7bvq4cvP0roPdGxFG3fAmAiz+UfIRVLRfrtD1Ewai1AXX7DbkB9CD9p7tqff7V8nl7fJi4gNSav/xdUFbaEDDeOXFQuenkrr8V0W1gP+u9cf3C9rW2NyCZyYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305856; c=relaxed/simple; bh=oJvsHqKtmERgG+BHDRgpYd3Hg+5b3dI0zORQ85m27Cc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q/bgoF1RYOTnls9hTanGOGQqBK5oQ6RjQpWS+vBaaBm3hr2/ZRZ2TRDhyoArg+WCvgcJReOr/AHLEiqxBC3g29RAWTgsmKHk0+g3sNjvo4kQrfGn67+0r11/ybEQ1mzyuDJx7G1cHOYMhe/pzcT21AhvRTbfgP5A7OPRkHtWmEw= 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=butVKHZP; arc=none smtp.client-ip=209.85.221.48 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="butVKHZP" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-47f93b2fe4cso399446f8f.0 for ; Fri, 21 Aug 2026 02:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1787305847; x=1787910647; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PiWS5xibm4AuM2M11jS2y7wQ/FmG+Wf2gKfhaKMAwvk=; b=butVKHZPQaVpIGhlFFoOzSZKjRGwbl9ZwdI/WPv5FD6Sx0umJmraplKKwWVpHtp7rQ RMQ8Z9BUGmvDu5kMmtH2mt4nVPCLnC0P38prRRGnJN9ylSUwqkFDzmL9QZsoABkZW3bk oKoy7XzKk5WEC5cVqCn7rnOgWLCTJQeSKahPDP9A5XKzKadGoi7eDh9ToXC/QBvM/JDB WCERwG7XJaS8c9hNE+vWu2UoYxxMbNKbUXld31sJzp2x5lTcNyeE7iXKVFFUxiXMnEjn JWPkdD99ZtIAIUr4bFRwv9RlrjYx+zbbH7q4EVXuHpyg9h2M7ZeR9aYcCdpyRWy5roV9 NvEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787305847; x=1787910647; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PiWS5xibm4AuM2M11jS2y7wQ/FmG+Wf2gKfhaKMAwvk=; b=NH94ECuNm1Ho68NrK2ipha/AfyJuIWnYoBBWP4YEJSC9RmBL2TBqqnmfKY0eLzWF8+ yLfzshx4AlkkEMI6jPSOTLnr9oDI7bMfLZU02vpCBGI0NQZ/eg+GpRlQ7pINZJB9tWM2 yUz1+H3g/6IUy48BdYw+FvM7uTgsmOTvdWSpDnkR/BcmIv35sKoollj8lgyxwF6qlC4w rEAN/2GrgQ1PWBXDthIlgk+eyH2jTwT/cVrIVmWHizjnpIQPQzmp+vK/T0jRuhWRgCDm HOuyQz8vNON1xFeRZLCsmFvEPvO/YXigSwOhxoIiZkbbf/bYkQTv2889CyBsnVdStArF ZURQ== X-Forwarded-Encrypted: i=1; AHgh+Rr57HUnedaIqNxZgCWizhMtWZEKnTE5E50cM9bo2OkiUxYllK0+KBmicM94TvD2PM7P1beDK/f2AHXr5EQ=@vger.kernel.org X-Gm-Message-State: AFuF++lAMGebM1cuBMYPaJTZ01agooj1YsArAhbM8UA+K0wHY6FAr7b9 0pBlLjbPTh9r6XMs07OwxbB0Vrj2PxhbO39yF/sYLnsHzqaQHXZ0K+DZbS5AhvedgPY= X-Gm-Gg: AR+sD10FO4uyWKUUpQ4OMO/bbiH5QkvG+Ls7iAKdEevytalBG8xK63Z4PTtV1+KFIFu 4BjRYbdq8oCOrlLuCXrcWmR0h7erLFzHzmr+tHxA6xaqSnrKZ9ZDhZm4fSdLiTGuT1bciLajIC2 1MewTQjwGLoS4A53eyQGg4rjO5Fmt5yeTmFgw4k+4G2NMDMT8IxLWa52L2OusjQ/jsxP06eD094 VA4szfPWJTzKzH9ol7Sb1HrP/jiZWtN4znb4CKmNiD8NsAN0CyEeHOaS9llmSYMgU4LCqGHkxeh M3DIes9l0y6GirlnCO1REskJ5PdHaEizfd/X/ueRDPZFw+/E9vRZvgOxlF8pxLILGV5tbdBdWh/ 0LWeeb0jGhE94Iux3qC7l91UUs/x/vVRCCfD3bwVPvplMQAQr+E2HbSh7W3eRg+qo0+60fEyGUT 9BdEzgNtfa9E67/qizqqKFGiaIg23PaaPhGflfXO6QFvfL3qLe6rqcN13ArLppkRca X-Received: by 2002:a05:6000:2907:b0:481:5167:abda with SMTP id ffacd0b85a97d-482c0b4c908mr6700276f8f.9.1787305847538; Fri, 21 Aug 2026 02:50:47 -0700 (PDT) Received: from pop-os.local ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482b14c3775sm14474284f8f.26.2026.08.21.02.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 02:50:47 -0700 (PDT) From: James Clark Date: Fri, 21 Aug 2026 10:50:33 +0100 Subject: [PATCH 5/6] perf/core: Return errors from perf_report_aux_output_id() 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: <20260821-james-cs-hw_id-output-failure-v1-5-9d532ddabcc3@linaro.org> References: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> In-Reply-To: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> To: John Garry , Will Deacon , Mike Leach , Leo Yan , Suzuki K Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Suyash Mahar , Amir Ayupov Cc: Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.15.2 It's useful to know if this failed or not so a retry can be attempted later. Return the error code or success. Signed-off-by: James Clark --- include/linux/perf_event.h | 2 +- kernel/events/core.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 48d851fbd8ea..01d318a4de50 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1896,7 +1896,7 @@ static inline struct fasync_struct **perf_event_fasyn= c(struct perf_event *event) } =20 extern void perf_event_addr_filters_sync(struct perf_event *event); -extern void perf_report_aux_output_id(struct perf_event *event, u64 hw_id); +extern int perf_report_aux_output_id(struct perf_event *event, u64 hw_id); =20 extern int perf_output_begin(struct perf_output_handle *handle, struct perf_sample_data *data, diff --git a/kernel/events/core.c b/kernel/events/core.c index ba5bd6a78fe7..bcdc9e7d2637 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10565,7 +10565,7 @@ static void perf_log_itrace_start(struct perf_event= *event) perf_output_end(&handle); } =20 -void perf_report_aux_output_id(struct perf_event *event, u64 hw_id) +int perf_report_aux_output_id(struct perf_event *event, u64 hw_id) { struct perf_output_handle handle; struct perf_sample_data sample; @@ -10587,12 +10587,14 @@ void perf_report_aux_output_id(struct perf_event = *event, u64 hw_id) ret =3D perf_output_begin(&handle, &sample, event, rec.header.size); =20 if (ret) - return; + return ret; =20 perf_output_put(&handle, rec); perf_event__output_id_sample(event, &handle, &sample); =20 perf_output_end(&handle); + + return 0; } EXPORT_SYMBOL_GPL(perf_report_aux_output_id); =20 --=20 2.43.0 From nobody Mon Sep 28 13:19:00 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 C324C47ACED for ; Fri, 21 Aug 2026 09:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305856; cv=none; b=r6nk1CwBWUwk/nIVHw9PxKhIhO9Li+jm/NxmEk74xLavvMCx1yF8kbySrljMB4W1U9qoQZ5eYymFwVriLlYYE1T+A+PiJLe5F0a9TA2dOfuYd+ZOOFyjRASNKuGAOVrgKq61oAQUTkJgJoSo88luLDDfkQUzpnlV52x3jtpIc0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787305856; c=relaxed/simple; bh=nzEQ8JU4JoYYnPRoIwkN2IQxvscqWNK64xxNJksGgsU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FIdj7bwZHypgzrvL+tdEGKCagB+Ntf4xfha+2vvsitQNkMmVvf0KU7W7BFXXzEK08FlHp3XDdI18JZO7ArF5BcxazlCac8xa/zpBFvbgVGkO6rWXuP8EUhLXrMSAHpDXv7eQe++3EbjVMB28NU29IpJWLWVVMbv8Al/mxpanWvM= 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=HcRS+fJr; arc=none smtp.client-ip=209.85.128.42 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="HcRS+fJr" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4998590d392so6810915e9.0 for ; Fri, 21 Aug 2026 02:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1787305849; x=1787910649; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=05DUnskBW8qYusWX8ek9jHQJpSgnNnSpmQtWmqnHEBs=; b=HcRS+fJr8RFiwCfd6JUcPYsqUHHbircLmB19fWIRKkLj+mhCcu+Vbs9+UlF6zRUGq+ +6IqMPEM0J+7WcewkGkXLXvGXhAHWmds8byDt7x5OkiVlQ7z9ZuTGqMWvKQYlV1K7kbQ F8lwwUhDHqOYGmbVSsURodZ4zFrdT2ozj48O6nI7HyvSfmJRPqhbN3CJFbKoop4KoBJT 5bZAuCkUmpPXJ75ek7FXkH3R2hTxqoY2Gh+k89wy4wRQubl0Oll1FbFfWEJaTSlhA2Qf Hag1t5IiJ4/uuiDDyMO22XEIhuP6ifjEmdwPJF7y4JenU+ipa8KiuEDBzWUPmCO1GfQV lQLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787305849; x=1787910649; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=05DUnskBW8qYusWX8ek9jHQJpSgnNnSpmQtWmqnHEBs=; b=ljni8JsJEv70I31Te/m0MTaC+d9mkzXAoqcDW55uF+igXp6gFqd3lDeLg+US3TiJmG DaV0duNc65VJqkq28AcRcUkU6V1me5E56Ruqt9FgeqZt/88tiaLp4okHaBECcwE2j5Yn hVLyYj9dvFko3/PCiLty66zPks7SPtcXal6e9uj5f/xmtgOQDd6eFQO2+HoChe6kGNtz 1CpaovQXHPlkXELAQXw50oWKu0Tu4sY6tl8zCa71Cs5cxdWM8qZRQrDMI1IkCEK3dmIC xqFPTvetBhgciQj4QkLMz1p/Llqux90GmXBG++9tFxP1n+bUJ/Pc45npfTdr/jHwgDES yhpQ== X-Forwarded-Encrypted: i=1; AHgh+RoBGGDa4Jnbq8oEEeg/bs6XHIt1l4xRr73Wp3dtsRCU+8gDKktLXRRynmjsjmVpf91hHUOZ6SV4eNRhD0g=@vger.kernel.org X-Gm-Message-State: AFuF++m2t0SbFiij404ldpyh40fimhY+rbRZZoT+RYZoTzKbYX2sO2q2 ag1jzxUnpEQIdJDlyQ1WOEnPfuY2z9EJdMWK4vgAmjKfyWwd2vDM/pd1puVVP7+XjvM= X-Gm-Gg: AR+sD135rcopc4CxQMbwgnDIIQC3VQNb/avl9rcd9rKUQoRB2MZbWTpJHAi4PCAPJjp K0kmkIELNITuMNIVYleEYuJzq9OJXMDudobNDZadE5Ox+81JoIR4TXeYXgBpCc7Ocb2urCHL9CW hv2hB+Vj3fyYLVAuHjoLluHNQTi+zq8wLNbnkD3taav1a+0dKeEHXPJTQDSF6iZjteZKDqe7SUq XCno6oQr5b4rvzFizbkwwB20EyfbhS+D+4lClM8fy+YG6d/ZaJ/5CJPZBq+qa+C0QFgwhhYohH3 4T92XouxBelH1x5naahAIsvGHnd0hIxQyKBpLwXrdYuP76Vyt5f191/9gosCTTZp3m6ZN1/sIee vCO4wpmIQ0S5v4oIAswJxuNC8e9hAuacAxpqXnyOGBN34H5Ux5JOMxp2Gj55WbgSz6cYp/Xe5yw lanynvJvgG+h1fs7YoRq2zbKl/boy+Zsd9wmpHFO4QyDAs+4sx5PG1c5DkM4yMoR2g X-Received: by 2002:a05:6000:4811:b0:47f:6f9e:1e82 with SMTP id ffacd0b85a97d-482c0b4ef34mr8274865f8f.9.1787305848760; Fri, 21 Aug 2026 02:50:48 -0700 (PDT) Received: from pop-os.local ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482b14c3775sm14474284f8f.26.2026.08.21.02.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 02:50:48 -0700 (PDT) From: James Clark Date: Fri, 21 Aug 2026 10:50:34 +0100 Subject: [PATCH 6/6] coresight: perf: Retry failed HW_ID writes 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: <20260821-james-cs-hw_id-output-failure-v1-6-9d532ddabcc3@linaro.org> References: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> In-Reply-To: <20260821-james-cs-hw_id-output-failure-v1-0-9d532ddabcc3@linaro.org> To: John Garry , Will Deacon , Mike Leach , Leo Yan , Suzuki K Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Leo Yan , Suyash Mahar , Amir Ayupov Cc: Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.15.2 Don't set the aux_hwid_done bit when writes fail so that it can be retried later if the ring buffer was full. Add a second attempt on stop in case this session only has one call to start. Otherwise there is no chance to retry and it isn't fixed by not setting aux_hwid_done. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.c | 52 +++++++++++++++-----= ---- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index 09b21a711a87..0ffc5cd9c88f 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -536,6 +536,31 @@ static int etm_event_resume(struct coresight_path *pat= h) return ret; } =20 +static void etm_output_hw_id(struct perf_event *event, + struct etm_event_data *event_data, + struct coresight_path *path, + struct coresight_device *sink) +{ + int cpu =3D smp_processor_id(); + u64 hw_id; + + /* + * output cpu / trace ID in perf record, once for the lifetime + * of the event. + */ + if (!cpumask_test_cpu(cpu, &event_data->aux_hwid_done)) { + hw_id =3D FIELD_PREP(CS_AUX_HW_ID_MAJOR_VERSION_MASK, + CS_AUX_HW_ID_MAJOR_VERSION); + hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_MINOR_VERSION_MASK, + CS_AUX_HW_ID_MINOR_VERSION); + hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, path->trace_id); + hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_SINK_ID_MASK, coresight_get_sink_id(s= ink)); + + if (!perf_report_aux_output_id(event, hw_id)) + cpumask_set_cpu(cpu, &event_data->aux_hwid_done); + } +} + static void etm_event_start(struct perf_event *event, int flags) { int cpu =3D smp_processor_id(); @@ -544,7 +569,6 @@ static void etm_event_start(struct perf_event *event, i= nt flags) struct perf_output_handle *handle =3D &ctxt->handle; struct coresight_device *source, *sink; struct coresight_path *path; - u64 hw_id; =20 if (flags & PERF_EF_RESUME) { path =3D etm_event_get_ctxt_path(ctxt); @@ -596,22 +620,7 @@ static void etm_event_start(struct perf_event *event, = int flags) if (coresight_enable_source(source, event, CS_MODE_PERF, path)) goto fail_disable_path; =20 - /* - * output cpu / trace ID in perf record, once for the lifetime - * of the event. - */ - if (!cpumask_test_cpu(cpu, &event_data->aux_hwid_done)) { - cpumask_set_cpu(cpu, &event_data->aux_hwid_done); - - hw_id =3D FIELD_PREP(CS_AUX_HW_ID_MAJOR_VERSION_MASK, - CS_AUX_HW_ID_MAJOR_VERSION); - hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_MINOR_VERSION_MASK, - CS_AUX_HW_ID_MINOR_VERSION); - hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, path->trace_id); - hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_SINK_ID_MASK, coresight_get_sink_id(s= ink)); - - perf_report_aux_output_id(event, hw_id); - } + etm_output_hw_id(event, event_data, path, sink); =20 out: /* Tell the perf core the event is alive */ @@ -630,7 +639,7 @@ static void etm_event_start(struct perf_event *event, i= nt flags) */ if (READ_ONCE(handle->event)) { perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED); - perf_aux_output_end(handle, 0); + perf_aux_output_end(path->handle, 0); } fail: event->hw.state =3D PERF_HES_STOPPED; @@ -679,6 +688,7 @@ static void etm_event_pause(struct coresight_path *path, if (!size) return; =20 + etm_output_hw_id(event, event_data, path, sink); perf_aux_output_end(handle, size); perf_aux_output_begin(handle, event); } else { @@ -769,10 +779,12 @@ static void etm_event_stop(struct perf_event *event, = int mode) * But we should never get a non-zero size with * an invalid handle. */ - if (READ_ONCE(handle->event)) + if (READ_ONCE(handle->event)) { + etm_output_hw_id(event, event_data, path, sink); perf_aux_output_end(handle, size); - else + } else { WARN_ON(size); + } } =20 /* Disabling the path make its elements available to other sessions */ --=20 2.43.0