From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 81602336896 for ; Wed, 3 Jun 2026 10:17:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481848; cv=none; b=MoPu1Uzdl0I6DOwY651xbJWfonCuWHGMkPOcRqhpzD3RCbudWBSRXtD+DoT37jrGggG4PCTW6H10Ekbbr5hQA9jgb50mTM5E9k6uAodNsk3MuZsI2d4K14/U3p6YjT50w7mj05Bt9HonTooYSAEoXEs3t8ZSOgJGfzwNBGuYbzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481848; c=relaxed/simple; bh=UKxA13BszOJE25/nUeMeJyLDu+oQeuaediBZT3D/sAM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ma1YbqL6B5Lqp69Iw1FG8TNj1J8wONyT4lNNvxFu+LgHxexRtZR7M+Wu4v56U/EUXmi/yUYVnqPndEuI9cASOxXAi8Vedv/wTpikHZWoEDLak+maDT1C4F/Un5ocu0294qJpRKgJBXWleQnZ9wAGYwbmJ+T2W3phm9W9atYzuHw= 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=m6V6KrR4; arc=none smtp.client-ip=209.85.128.41 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="m6V6KrR4" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-49050ff7cbdso116632665e9.2 for ; Wed, 03 Jun 2026 03:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481843; x=1781086643; 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=//ElRvliiYl+p+NZ7gDgcnCIeEdEUU7NLC2fbqXa46Q=; b=m6V6KrR4oNQS80bN7mm+sjBXb6TrmjGmCe0I1xt+srEylxEiIRnMJpS3hLF8pSBCx2 xHQfJr5EpImqGqhQBZo6CjiBC09n6OSz8FL+GKUFp/zIgqfoLcOh9uEEkpEEVlpXLzec ysy4s4e1kgUmyvTy5MLN9eGIviRN4jLyQQnpdN99/KWpM8b+LUdiGCpZKh2OfrjxpXnZ ygrK9CZI+efy4KYLWMKzDRX235848Do8hJpZCzmXqpxEnzx6ImloU+H5zbtUSzOSIB+r uaXnQOgaqWO6yhzILju2s0mf/IdgOqbMgW8JrHAwxeTykcgp/Sq7Ujd7D0wg+Lm+00pt vx4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481843; x=1781086643; 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=//ElRvliiYl+p+NZ7gDgcnCIeEdEUU7NLC2fbqXa46Q=; b=RVG0xJGXUnRuKNE9UO4TAAK7+Ut2/VgDu0HTo+03eAAH8sSavUrRJNhW/JiiScBjKN BtMyi+NEHUaavWHHj4CiG5v8TTQhzmnDaNpmvhf3QGmSiz+6j0LgButnX6jX8bJ/16pB J+gxXwwlVUUnKpC/psLfFZnfCJcI/410By4QcyEYmCEEn7jtSQnHb4XTRvgGjS6fO3ru r+uxhJRy4iMCJxeFXt/W/WgbErvVTF6DAJgYsUXl7yayBh/Q0LioCSkK4qUQ5dAF3fqf fBxbhzi0Mchhw4MHzPIPqj87AnkJmi41TdS3+sybobxxOGYIyLQit+g29NdQI8WRfpp4 5xIw== X-Forwarded-Encrypted: i=1; AFNElJ/zrCm2OyeBQMw9O/JBWAbQG9JWHjBCZB4E4Kc8en6p0FuJDp6coyY9VucpW4BwmD9c8lGC+0qqh5OL45A=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9mACE5R3gZWwwI542xcnQVywZgjPW8VU2kwHH9GbzaaIsYpHz VHYkFdAPEo2iBQa10TCxDY672w808kX3uHYFyW976WMXIc677FN6JLtXk6S4/fpJtBI= X-Gm-Gg: Acq92OEEZF3DpGABEvjsg+bf8OQn7dkg078maImeuSyBW5k1k0eawb1IuMmwaNN5NG+ 9uhPWqU/WEYqACt1XtNG6aXUKzGMD2AE4dvsht6M4LdXGj0RiB2i0uPim5dbLQnDPnyjNngKuiA XRm2gXKEgCHA9Yqf0+Fu4KDOkN0lEWB0gIqt3IJCIYA+bm4aXTGlXpFJRSk1WMre1pl7g8wePI0 tmU/gHZAyOvO11LvM69rne9OmTf1SlQ4tQtBCYtHs0v+Kdnq2/LxyXVMDEZX4wd6zSS3DIUQSup i8J625KvHzzdQymeJ/2+f3/n8YqBwHH9oJsxkKr5tHEY7434pS/VLXo3hKFJ7nRrtA0EmkfkKjR O5Tvfduvt+acEBH6DZJUjs+TVal5H1aqkDrEiiW4wx+5/LNkztu51NniCCjZ9Vl7QR7JM3BpRqL TJynbjKPmuGo9P/iZZ6jovG/MAQ9IfX1IPaYhb/jpXYkY= X-Received: by 2002:a05:600c:82c3:b0:490:b591:b5a1 with SMTP id 5b1f17b1804b1-490b5ed5dd8mr46719645e9.32.1780481842779; Wed, 03 Jun 2026 03:17:22 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:22 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:05 +0100 Subject: [PATCH v3 01/19] perf cs-etm: Queue context packets for frontend 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: <20260603-james-cs-context-tracking-fix-v3-1-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 PE_CONTEXT elements update the context ID and exception level, but the decoder may still have prior packets cached for frontend processing. Updating the context immediately in the decoder backend can make those cached packets get consumed with the wrong thread or EL state. Add a CS_ETM_CONTEXT packet carrying the TID and EL to the frontend, this keeps context changes ordered with the rest of the packet stream and avoids mismatches when synthesizing samples from cached packets. Separate the memory access function into one for the frontend and one for decoding. The frontend also needs memory access to attach the instruction to samples. Because the frontend does memory access for both previous and current packets, change all the frontend memory access function signatures to take both a tidq and packet. But backend always uses the current backend EL and thread from the tidq. Treat context packets as a boundary for branch sample generation and remove tidq->prev_packet_thread because it's not possible to branch to a different thread, so only tracking the current thread is required for sample generation. Fixes: e573e978fb12 ("perf cs-etm: Inject capabilitity for CoreSight traces= ") Reported-by: Amir Ayupov Closes: https://lore.kernel.org/linux-perf-users/20260515021135.1729028-1-a= aupov@meta.com/ Co-authored-by: James Clark Signed-off-by: Leo Yan Signed-off-by: James Clark --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 21 ++- tools/perf/util/cs-etm.c | 234 ++++++++++++++------= ---- tools/perf/util/cs-etm.h | 8 +- 3 files changed, 162 insertions(+), 101 deletions(-) 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 dee3020ceaa9..26940f1f1b0b 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -402,6 +402,8 @@ cs_etm_decoder__buffer_packet(struct cs_etm_queue *etmq, packet_queue->packet_buffer[et].flags =3D 0; packet_queue->packet_buffer[et].exception_number =3D UINT32_MAX; packet_queue->packet_buffer[et].trace_chan_id =3D trace_chan_id; + packet_queue->packet_buffer[et].el =3D ocsd_EL_unknown; + packet_queue->packet_buffer[et].tid =3D -1; =20 if (packet_queue->packet_count =3D=3D CS_ETM_PACKET_MAX_BUFFER - 1) return OCSD_RESP_WAIT; @@ -449,6 +451,7 @@ cs_etm_decoder__buffer_range(struct cs_etm_queue *etmq, packet->last_instr_type =3D elem->last_i_type; packet->last_instr_subtype =3D elem->last_i_subtype; packet->last_instr_cond =3D elem->last_instr_cond; + packet->el =3D elem->context.exception_level; =20 if (elem->last_i_type =3D=3D OCSD_INSTR_BR || elem->last_i_type =3D=3D OC= SD_INSTR_BR_INDIRECT) packet->last_instr_taken_branch =3D elem->last_instr_exec; @@ -525,7 +528,9 @@ cs_etm_decoder__set_tid(struct cs_etm_queue *etmq, const ocsd_generic_trace_elem *elem, const uint8_t trace_chan_id) { + struct cs_etm_packet *packet; pid_t tid =3D -1; + int ret; =20 /* * Process the PE_CONTEXT packets if we have a valid contextID or VMID. @@ -546,12 +551,18 @@ cs_etm_decoder__set_tid(struct cs_etm_queue *etmq, break; } =20 - if (cs_etm__etmq_set_tid_el(etmq, tid, trace_chan_id, - elem->context.exception_level)) + if (cs_etm__etmq_update_decode_context(etmq, trace_chan_id, + elem->context.exception_level, tid)) return OCSD_RESP_FATAL_SYS_ERR; =20 - if (tid =3D=3D -1) - return OCSD_RESP_CONT; + ret =3D cs_etm_decoder__buffer_packet(etmq, packet_queue, trace_chan_id, + CS_ETM_CONTEXT); + if (ret !=3D OCSD_RESP_CONT && ret !=3D OCSD_RESP_WAIT) + return ret; + + packet =3D &packet_queue->packet_buffer[packet_queue->tail]; + packet->tid =3D tid; + packet->el =3D elem->context.exception_level; =20 /* * A timestamp is generated after a PE_CONTEXT element so make sure @@ -559,7 +570,7 @@ cs_etm_decoder__set_tid(struct cs_etm_queue *etmq, */ cs_etm_decoder__reset_timestamp(packet_queue); =20 - return OCSD_RESP_CONT; + return ret; } =20 static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 40c6ddfa8c8d..ce570913669c 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -85,15 +85,22 @@ struct cs_etm_traceid_queue { u64 period_instructions; size_t last_branch_pos; union perf_event *event_buf; - struct thread *thread; - struct thread *prev_packet_thread; - ocsd_ex_level prev_packet_el; - ocsd_ex_level el; struct branch_stack *last_branch; struct branch_stack *last_branch_rb; struct cs_etm_packet *prev_packet; struct cs_etm_packet *packet; struct cs_etm_packet_queue packet_queue; + + struct thread *decode_thread; + ocsd_ex_level decode_el; + + /* + * The frontend accesses the EL from '[prev_]packet' because it needs + * previous EL for branch and current EL for instruction samples. It's + * not possible to change thread in a single branch sample so no need to + * store or access the thread through the packet. + */ + struct thread *frontend_thread; }; =20 enum cs_etm_format { @@ -614,10 +621,11 @@ static int cs_etm__init_traceid_queue(struct cs_etm_q= ueue *etmq, =20 queue =3D &etmq->etm->queues.queue_array[etmq->queue_nr]; tidq->trace_chan_id =3D trace_chan_id; - tidq->el =3D tidq->prev_packet_el =3D ocsd_EL_unknown; - tidq->thread =3D machine__findnew_thread(&etm->session->machines.host, -1, + tidq->decode_el =3D ocsd_EL_unknown; + tidq->frontend_thread =3D machine__findnew_thread(&etm->session->machines= .host, -1, + queue->tid); + tidq->decode_thread =3D machine__findnew_thread(&etm->session->machines.h= ost, -1, queue->tid); - tidq->prev_packet_thread =3D machine__idle_thread(&etm->session->machines= .host); =20 tidq->packet =3D zalloc(sizeof(struct cs_etm_packet)); if (!tidq->packet) @@ -750,21 +758,10 @@ static void cs_etm__packet_swap(struct cs_etm_auxtrac= e *etm, /* * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for * the next incoming packet. - * - * Threads and exception levels are also tracked for both the - * previous and current packets. This is because the previous - * packet is used for the 'from' IP for branch samples, so the - * thread at that time must also be assigned to that sample. - * Across discontinuity packets the thread can change, so by - * tracking the thread for the previous packet the branch sample - * will have the correct info. */ tmp =3D tidq->packet; tidq->packet =3D tidq->prev_packet; tidq->prev_packet =3D tmp; - tidq->prev_packet_el =3D tidq->el; - thread__put(tidq->prev_packet_thread); - tidq->prev_packet_thread =3D thread__get(tidq->thread); } } =20 @@ -937,8 +934,8 @@ static void cs_etm__free_traceid_queues(struct cs_etm_q= ueue *etmq) =20 /* Free this traceid_queue from the array */ tidq =3D etmq->traceid_queues[idx]; - thread__zput(tidq->thread); - thread__zput(tidq->prev_packet_thread); + thread__zput(tidq->frontend_thread); + thread__zput(tidq->decode_thread); zfree(&tidq->event_buf); zfree(&tidq->last_branch); zfree(&tidq->last_branch_rb); @@ -1083,47 +1080,43 @@ static u8 cs_etm__cpu_mode(struct cs_etm_queue *etm= q, u64 address, } } =20 -static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id, - u64 address, size_t size, u8 *buffer, - const ocsd_mem_space_acc_t mem_space) +static u32 __cs_etm__mem_access(struct cs_etm_queue *etmq, + u64 address, size_t size, u8 *buffer, + const ocsd_mem_space_acc_t mem_space, + ocsd_ex_level el, struct thread *thread) { u8 cpumode; u64 offset; int len; struct addr_location al; struct dso *dso; - struct cs_etm_traceid_queue *tidq; int ret =3D 0; =20 if (!etmq) return 0; =20 addr_location__init(&al); - tidq =3D cs_etm__etmq_get_traceid_queue(etmq, trace_chan_id); - if (!tidq) - goto out; =20 /* - * We've already tracked EL along side the PID in cs_etm__set_thread() - * so double check that it matches what OpenCSD thinks as well. It - * doesn't distinguish between EL0 and EL1 for this mem access callback - * so we had to do the extra tracking. Skip validation if it's any of - * the 'any' values. + * We track EL for the frontend and the backend when receiving context + * and range packets. OpenCSD doesn't distinguish between EL0 and EL1 + * for this mem access callback so we had to do the extra tracking. Skip + * validation if it's any of the 'any' values. */ if (!(mem_space =3D=3D OCSD_MEM_SPACE_ANY || mem_space =3D=3D OCSD_MEM_SPACE_N || mem_space =3D=3D OCSD_MEM_SPAC= E_S)) { if (mem_space & OCSD_MEM_SPACE_EL1N) { /* Includes both non secure EL1 and EL0 */ - assert(tidq->el =3D=3D ocsd_EL1 || tidq->el =3D=3D ocsd_EL0); + assert(el =3D=3D ocsd_EL1 || el =3D=3D ocsd_EL0); } else if (mem_space & OCSD_MEM_SPACE_EL2) - assert(tidq->el =3D=3D ocsd_EL2); + assert(el =3D=3D ocsd_EL2); else if (mem_space & OCSD_MEM_SPACE_EL3) - assert(tidq->el =3D=3D ocsd_EL3); + assert(el =3D=3D ocsd_EL3); } =20 - cpumode =3D cs_etm__cpu_mode(etmq, address, tidq->el); + cpumode =3D cs_etm__cpu_mode(etmq, address, el); =20 - if (!thread__find_map(tidq->thread, cpumode, address, &al)) + if (!thread__find_map(thread, cpumode, address, &al)) goto out; =20 dso =3D map__dso(al.map); @@ -1138,7 +1131,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *et= mq, u8 trace_chan_id, =20 map__load(al.map); =20 - len =3D dso__data_read_offset(dso, maps__machine(thread__maps(tidq->threa= d)), + len =3D dso__data_read_offset(dso, maps__machine(thread__maps(thread)), offset, buffer, size); =20 if (len <=3D 0) { @@ -1158,6 +1151,30 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *e= tmq, u8 trace_chan_id, return ret; } =20 +static u32 cs_etm__frontend_mem_access(struct cs_etm_queue *etmq, + struct cs_etm_traceid_queue *tidq, + struct cs_etm_packet *packet, + u64 address, size_t size, u8 *buffer) +{ + return __cs_etm__mem_access(etmq, address, size, buffer, 0, packet->el, + tidq->frontend_thread); +} + +static u32 cs_etm__decoder_mem_access(struct cs_etm_queue *etmq, u8 trace_= chan_id, + u64 address, size_t size, u8 *buffer, + const ocsd_mem_space_acc_t mem_space) +{ + struct cs_etm_traceid_queue *tidq; + + tidq =3D cs_etm__etmq_get_traceid_queue(etmq, trace_chan_id); + if (!tidq) + return 0; + + return __cs_etm__mem_access(etmq, address, size, buffer, + mem_space, tidq->decode_el, + tidq->decode_thread); +} + static struct cs_etm_queue *cs_etm__alloc_queue(void) { struct cs_etm_queue *etmq =3D zalloc(sizeof(*etmq)); @@ -1333,12 +1350,13 @@ void cs_etm__reset_last_branch_rb(struct cs_etm_tra= ceid_queue *tidq) } =20 static inline int cs_etm__t32_instr_size(struct cs_etm_queue *etmq, - u8 trace_chan_id, u64 addr) + struct cs_etm_traceid_queue *tidq, + struct cs_etm_packet *packet, u64 addr) { u8 instrBytes[2]; =20 - cs_etm__mem_access(etmq, trace_chan_id, addr, ARRAY_SIZE(instrBytes), - instrBytes, 0); + cs_etm__frontend_mem_access(etmq, tidq, packet, addr, + ARRAY_SIZE(instrBytes), instrBytes); /* * T32 instruction size is indicated by bits[15:11] of the first * 16-bit word of the instruction: 0b11101, 0b11110 and 0b11111 @@ -1371,16 +1389,16 @@ u64 cs_etm__last_executed_instr(const struct cs_etm= _packet *packet) } =20 static inline u64 cs_etm__instr_addr(struct cs_etm_queue *etmq, - u64 trace_chan_id, - const struct cs_etm_packet *packet, + struct cs_etm_traceid_queue *tidq, + struct cs_etm_packet *packet, u64 offset) { if (packet->isa =3D=3D CS_ETM_ISA_T32) { u64 addr =3D packet->start_addr; =20 while (offset) { - addr +=3D cs_etm__t32_instr_size(etmq, - trace_chan_id, addr); + addr +=3D cs_etm__t32_instr_size(etmq, tidq, packet, + addr); offset--; } return addr; @@ -1490,34 +1508,51 @@ cs_etm__get_trace(struct cs_etm_queue *etmq) return etmq->buf_len; } =20 -static void cs_etm__set_thread(struct cs_etm_queue *etmq, - struct cs_etm_traceid_queue *tidq, pid_t tid, - ocsd_ex_level el) +/* + * Convert a raw thread number to a thread struct and assign it to **threa= d. + */ +static int cs_etm__etmq_update_thread(struct cs_etm_queue *etmq, + ocsd_ex_level el, pid_t tid, + struct thread **thread) { struct machine *machine =3D cs_etm__get_machine(etmq, el); =20 + if (!machine || !*thread) + return -EINVAL; + if (tid !=3D -1) { - thread__zput(tidq->thread); - tidq->thread =3D machine__find_thread(machine, -1, tid); + thread__zput(*thread); + *thread =3D machine__find_thread(machine, -1, tid); } =20 /* Couldn't find a known thread */ - if (!tidq->thread) - tidq->thread =3D machine__idle_thread(machine); + if (!*thread) + *thread =3D machine__idle_thread(machine); =20 - tidq->el =3D el; + return 0; } =20 -int cs_etm__etmq_set_tid_el(struct cs_etm_queue *etmq, pid_t tid, - u8 trace_chan_id, ocsd_ex_level el) +/* + * Set the thread and EL of the decode context which is ahead in time of t= he + * frontend context. + */ +int cs_etm__etmq_update_decode_context(struct cs_etm_queue *etmq, + u8 trace_chan_id, + ocsd_ex_level el, pid_t tid) { struct cs_etm_traceid_queue *tidq; + int ret; =20 tidq =3D cs_etm__etmq_get_traceid_queue(etmq, trace_chan_id); if (!tidq) return -EINVAL; =20 - cs_etm__set_thread(etmq, tidq, tid, el); + ret =3D cs_etm__etmq_update_thread(etmq, el, tid, + &tidq->decode_thread); + if (ret) + return ret; + + tidq->decode_el =3D el; return 0; } =20 @@ -1527,8 +1562,8 @@ bool cs_etm__etmq_is_timeless(struct cs_etm_queue *et= mq) } =20 static void cs_etm__copy_insn(struct cs_etm_queue *etmq, - u64 trace_chan_id, - const struct cs_etm_packet *packet, + struct cs_etm_traceid_queue *tidq, + struct cs_etm_packet *packet, struct perf_sample *sample) { /* @@ -1545,14 +1580,14 @@ static void cs_etm__copy_insn(struct cs_etm_queue *= etmq, * cs_etm__t32_instr_size(). */ if (packet->isa =3D=3D CS_ETM_ISA_T32) - sample->insn_len =3D cs_etm__t32_instr_size(etmq, trace_chan_id, + sample->insn_len =3D cs_etm__t32_instr_size(etmq, tidq, packet, sample->ip); /* Otherwise, A64 and A32 instruction size are always 32-bit. */ else sample->insn_len =3D 4; =20 - cs_etm__mem_access(etmq, trace_chan_id, sample->ip, sample->insn_len, - (void *)sample->insn, 0); + cs_etm__frontend_mem_access(etmq, tidq, packet, sample->ip, + sample->insn_len, (void *)sample->insn); } =20 u64 cs_etm__convert_sample_time(struct cs_etm_queue *etmq, u64 cs_timestam= p) @@ -1579,6 +1614,7 @@ static inline u64 cs_etm__resolve_sample_time(struct = cs_etm_queue *etmq, =20 static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, struct cs_etm_traceid_queue *tidq, + struct cs_etm_packet *packet, u64 addr, u64 period) { int ret =3D 0; @@ -1588,15 +1624,15 @@ static int cs_etm__synth_instruction_sample(struct = cs_etm_queue *etmq, =20 perf_sample__init(&sample, /*all=3D*/true); event->sample.header.type =3D PERF_RECORD_SAMPLE; - event->sample.header.misc =3D cs_etm__cpu_mode(etmq, addr, tidq->el); + event->sample.header.misc =3D cs_etm__cpu_mode(etmq, addr, packet->el); event->sample.header.size =3D sizeof(struct perf_event_header); =20 /* Set time field based on etm auxtrace config. */ sample.time =3D cs_etm__resolve_sample_time(etmq, tidq); =20 sample.ip =3D addr; - sample.pid =3D thread__pid(tidq->thread); - sample.tid =3D thread__tid(tidq->thread); + sample.pid =3D thread__pid(tidq->frontend_thread); + sample.tid =3D thread__tid(tidq->frontend_thread); sample.id =3D etmq->etm->instructions_id; sample.stream_id =3D etmq->etm->instructions_id; sample.period =3D period; @@ -1604,7 +1640,7 @@ static int cs_etm__synth_instruction_sample(struct cs= _etm_queue *etmq, sample.flags =3D tidq->prev_packet->flags; sample.cpumode =3D event->sample.header.misc; =20 - cs_etm__copy_insn(etmq, tidq->trace_chan_id, tidq->packet, &sample); + cs_etm__copy_insn(etmq, tidq, tidq->packet, &sample); =20 if (etm->synth_opts.last_branch) sample.branch_stack =3D tidq->last_branch; @@ -1649,15 +1685,15 @@ static int cs_etm__synth_branch_sample(struct cs_et= m_queue *etmq, =20 event->sample.header.type =3D PERF_RECORD_SAMPLE; event->sample.header.misc =3D cs_etm__cpu_mode(etmq, ip, - tidq->prev_packet_el); + tidq->prev_packet->el); event->sample.header.size =3D sizeof(struct perf_event_header); =20 /* Set time field based on etm auxtrace config. */ sample.time =3D cs_etm__resolve_sample_time(etmq, tidq); =20 sample.ip =3D ip; - sample.pid =3D thread__pid(tidq->prev_packet_thread); - sample.tid =3D thread__tid(tidq->prev_packet_thread); + sample.pid =3D thread__pid(tidq->frontend_thread); + sample.tid =3D thread__tid(tidq->frontend_thread); sample.addr =3D cs_etm__first_executed_instr(tidq->packet); sample.id =3D etmq->etm->branches_id; sample.stream_id =3D etmq->etm->branches_id; @@ -1666,8 +1702,7 @@ static int cs_etm__synth_branch_sample(struct cs_etm_= queue *etmq, sample.flags =3D tidq->prev_packet->flags; sample.cpumode =3D event->sample.header.misc; =20 - cs_etm__copy_insn(etmq, tidq->trace_chan_id, tidq->prev_packet, - &sample); + cs_etm__copy_insn(etmq, tidq, tidq->prev_packet, &sample); =20 /* * perf report cannot handle events without a branch stack @@ -1788,7 +1823,6 @@ static int cs_etm__sample(struct cs_etm_queue *etmq, { struct cs_etm_auxtrace *etm =3D etmq->etm; int ret; - u8 trace_chan_id =3D tidq->trace_chan_id; u64 instrs_prev; =20 /* Get instructions remainder from previous packet */ @@ -1874,10 +1908,10 @@ static int cs_etm__sample(struct cs_etm_queue *etmq, * been executed, but PC has not advanced to next * instruction) */ - addr =3D cs_etm__instr_addr(etmq, trace_chan_id, - tidq->packet, offset - 1); + addr =3D cs_etm__instr_addr(etmq, tidq, tidq->packet, + offset - 1); ret =3D cs_etm__synth_instruction_sample( - etmq, tidq, addr, + etmq, tidq, tidq->packet, addr, etm->instructions_sample_period); if (ret) return ret; @@ -1959,7 +1993,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq, addr =3D cs_etm__last_executed_instr(tidq->prev_packet); =20 err =3D cs_etm__synth_instruction_sample( - etmq, tidq, addr, + etmq, tidq, tidq->prev_packet, addr, tidq->period_instructions); if (err) return err; @@ -2014,7 +2048,7 @@ static int cs_etm__end_block(struct cs_etm_queue *etm= q, addr =3D cs_etm__last_executed_instr(tidq->prev_packet); =20 err =3D cs_etm__synth_instruction_sample( - etmq, tidq, addr, + etmq, tidq, tidq->prev_packet, addr, tidq->period_instructions); if (err) return err; @@ -2051,9 +2085,9 @@ static int cs_etm__get_data_block(struct cs_etm_queue= *etmq) return etmq->buf_len; } =20 -static bool cs_etm__is_svc_instr(struct cs_etm_queue *etmq, u8 trace_chan_= id, - struct cs_etm_packet *packet, - u64 end_addr) +static bool cs_etm__is_svc_instr(struct cs_etm_queue *etmq, + struct cs_etm_traceid_queue *tidq, + struct cs_etm_packet *packet, u64 end_addr) { /* Initialise to keep compiler happy */ u16 instr16 =3D 0; @@ -2075,8 +2109,8 @@ static bool cs_etm__is_svc_instr(struct cs_etm_queue = *etmq, u8 trace_chan_id, * so below only read 2 bytes as instruction size for T32. */ addr =3D end_addr - 2; - cs_etm__mem_access(etmq, trace_chan_id, addr, sizeof(instr16), - (u8 *)&instr16, 0); + cs_etm__frontend_mem_access(etmq, tidq, packet, addr, + sizeof(instr16), (u8 *)&instr16); if ((instr16 & 0xFF00) =3D=3D 0xDF00) return true; =20 @@ -2091,8 +2125,8 @@ static bool cs_etm__is_svc_instr(struct cs_etm_queue = *etmq, u8 trace_chan_id, * +---------+---------+-------------------------+ */ addr =3D end_addr - 4; - cs_etm__mem_access(etmq, trace_chan_id, addr, sizeof(instr32), - (u8 *)&instr32, 0); + cs_etm__frontend_mem_access(etmq, tidq, packet, addr, + sizeof(instr32), (u8 *)&instr32); if ((instr32 & 0x0F000000) =3D=3D 0x0F000000 && (instr32 & 0xF0000000) !=3D 0xF0000000) return true; @@ -2108,8 +2142,8 @@ static bool cs_etm__is_svc_instr(struct cs_etm_queue = *etmq, u8 trace_chan_id, * +-----------------------+---------+-----------+ */ addr =3D end_addr - 4; - cs_etm__mem_access(etmq, trace_chan_id, addr, sizeof(instr32), - (u8 *)&instr32, 0); + cs_etm__frontend_mem_access(etmq, tidq, packet, addr, + sizeof(instr32), (u8 *)&instr32); if ((instr32 & 0xFFE0001F) =3D=3D 0xd4000001) return true; =20 @@ -2125,7 +2159,6 @@ static bool cs_etm__is_svc_instr(struct cs_etm_queue = *etmq, u8 trace_chan_id, static bool cs_etm__is_syscall(struct cs_etm_queue *etmq, struct cs_etm_traceid_queue *tidq, u64 magic) { - u8 trace_chan_id =3D tidq->trace_chan_id; struct cs_etm_packet *packet =3D tidq->packet; struct cs_etm_packet *prev_packet =3D tidq->prev_packet; =20 @@ -2140,7 +2173,7 @@ static bool cs_etm__is_syscall(struct cs_etm_queue *e= tmq, */ if (magic =3D=3D __perf_cs_etmv4_magic) { if (packet->exception_number =3D=3D CS_ETMV4_EXC_CALL && - cs_etm__is_svc_instr(etmq, trace_chan_id, prev_packet, + cs_etm__is_svc_instr(etmq, tidq, prev_packet, prev_packet->end_addr)) return true; } @@ -2178,7 +2211,6 @@ static bool cs_etm__is_sync_exception(struct cs_etm_q= ueue *etmq, struct cs_etm_traceid_queue *tidq, u64 magic) { - u8 trace_chan_id =3D tidq->trace_chan_id; struct cs_etm_packet *packet =3D tidq->packet; struct cs_etm_packet *prev_packet =3D tidq->prev_packet; =20 @@ -2204,7 +2236,7 @@ static bool cs_etm__is_sync_exception(struct cs_etm_q= ueue *etmq, * (SMC, HVC) are taken as sync exceptions. */ if (packet->exception_number =3D=3D CS_ETMV4_EXC_CALL && - !cs_etm__is_svc_instr(etmq, trace_chan_id, prev_packet, + !cs_etm__is_svc_instr(etmq, tidq, prev_packet, prev_packet->end_addr)) return true; =20 @@ -2228,7 +2260,6 @@ static int cs_etm__set_sample_flags(struct cs_etm_que= ue *etmq, { struct cs_etm_packet *packet =3D tidq->packet; struct cs_etm_packet *prev_packet =3D tidq->prev_packet; - u8 trace_chan_id =3D tidq->trace_chan_id; u64 magic; int ret; =20 @@ -2309,11 +2340,11 @@ static int cs_etm__set_sample_flags(struct cs_etm_q= ueue *etmq, if (prev_packet->flags =3D=3D (PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_INTERRUPT) && - cs_etm__is_svc_instr(etmq, trace_chan_id, - packet, packet->start_addr)) + cs_etm__is_svc_instr(etmq, tidq, packet, packet->start_addr)) { prev_packet->flags =3D PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_SYSCALLRET; + } break; case CS_ETM_DISCONTINUITY: /* @@ -2394,6 +2425,7 @@ static int cs_etm__set_sample_flags(struct cs_etm_que= ue *etmq, PERF_IP_FLAG_RETURN | PERF_IP_FLAG_INTERRUPT; break; + case CS_ETM_CONTEXT: case CS_ETM_EMPTY: default: break; @@ -2469,6 +2501,19 @@ static int cs_etm__process_traceid_queue(struct cs_e= tm_queue *etmq, */ cs_etm__sample(etmq, tidq); break; + case CS_ETM_CONTEXT: + /* + * Update context but don't swap packet. Keep the + * previous one for branch source address info, if + * tracing the kernel the context packet will be emitted + * between two ranges. + */ + ret =3D cs_etm__etmq_update_thread(etmq, tidq->packet->el, + tidq->packet->tid, + &tidq->frontend_thread); + if (ret) + goto out; + break; case CS_ETM_EXCEPTION: case CS_ETM_EXCEPTION_RET: /* @@ -2497,6 +2542,7 @@ static int cs_etm__process_traceid_queue(struct cs_et= m_queue *etmq, } } =20 +out: return ret; } =20 @@ -2620,7 +2666,7 @@ static int cs_etm__process_timeless_queues(struct cs_= etm_auxtrace *etm, if (!tidq) continue; =20 - if (tid =3D=3D -1 || thread__tid(tidq->thread) =3D=3D tid) + if (tid =3D=3D -1 || thread__tid(tidq->frontend_thread) =3D=3D tid) cs_etm__run_per_thread_timeless_decoder(etmq); } else cs_etm__run_per_cpu_timeless_decoder(etmq); @@ -3328,7 +3374,7 @@ static int cs_etm__create_queue_decoders(struct cs_et= m_queue *etmq) */ if (cs_etm_decoder__add_mem_access_cb(etmq->decoder, 0x0L, ((u64) -1L), - cs_etm__mem_access)) + cs_etm__decoder_mem_access)) goto out_free_decoder; =20 zfree(&t_params); diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index aa9bb4a32eca..b81099c2b301 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -158,6 +158,7 @@ enum cs_etm_sample_type { CS_ETM_DISCONTINUITY, CS_ETM_EXCEPTION, CS_ETM_EXCEPTION_RET, + CS_ETM_CONTEXT, }; =20 enum cs_etm_isa { @@ -184,6 +185,8 @@ struct cs_etm_packet { u8 last_instr_size; u8 trace_chan_id; int cpu; + int el; + pid_t tid; }; =20 #define CS_ETM_PACKET_MAX_BUFFER 1024 @@ -259,8 +262,9 @@ enum cs_etm_pid_fmt { #include int cs_etm__get_cpu(struct cs_etm_queue *etmq, u8 trace_chan_id, int *cpu); enum cs_etm_pid_fmt cs_etm__get_pid_fmt(struct cs_etm_queue *etmq); -int cs_etm__etmq_set_tid_el(struct cs_etm_queue *etmq, pid_t tid, - u8 trace_chan_id, ocsd_ex_level el); +int cs_etm__etmq_update_decode_context(struct cs_etm_queue *etmq, + u8 trace_chan_id, ocsd_ex_level el, + pid_t tid); bool cs_etm__etmq_is_timeless(struct cs_etm_queue *etmq); void cs_etm__etmq_set_traceid_queue_timestamp(struct cs_etm_queue *etmq, u8 trace_chan_id); --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 4938035839C for ; Wed, 3 Jun 2026 10:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481847; cv=none; b=s7gGpGlMinGvt7nue+xSlYceGtH5cwV+O4y4Zf8IBM/+F/rfB1yMlUJsDwBtcc5sUw6tWvHihtFHW/TXh6N6ZRWUSyaCLXeliQAdlUUsT/2fIqFldAlfxhrYr3PO8XvQ9X4Y2TMwFIMQz3gigrkAd+9nGN5zL/GSZZ/K2SBs/ZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481847; c=relaxed/simple; bh=aR1osBtg8+dXgkU8gRUvP5gNGrwRuwN2bVKWjW+bwQM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hYc1/uKbu/JDO7UT+d/vZM6mq0CY3bjO4jbtr6nzNb/1aG/cEu3imlniRH4LCNqoLJQsU5OMqPAfCaUuFLTapawdHMnxFOOpDObBIcEfRBl0xvT8S6l60+LR9NketUQmKS8CFWhCZe+nhSwYYGc10GLllghZMJ/wr74gVc3cl60= 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=OxC3VMbP; arc=none smtp.client-ip=209.85.128.53 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="OxC3VMbP" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490b8a97b11so5572655e9.0 for ; Wed, 03 Jun 2026 03:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481844; x=1781086644; 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=LYNGLIkJZMjRjHk0hF9NSWbns9QHjdminA/Y/0E/C8I=; b=OxC3VMbPggN8D7Yu+AaHpOXTyB+kUpz1vaDZg2hjKHsNywfV0FlNgppYStF05SgCQq cc5Qx2OPRWt5ir6zV6xBRdtcWnLCtNrKeEw50gag4v2KIgNg/WdqNrEq33Ju0+9BPjPk 9JtcgiICc8BiCi+BauXwB66xjrYnCgeApROGPj3J3rlx1gpftTB9BXRB8uD0fjDj8hD2 cO+USv11uEa5UvpoYR8+17j/bonnPfVdGhv108kc0fvJk9pdlPtPVHr2Isow2fKtKrIa xtxWUUzid+YUc7Tz0WQ4yIB1OQ/OUa47coAj/BLk69I2RSnG7qGYXyKQF1lzVdanD8ZE dBGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481844; x=1781086644; 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=LYNGLIkJZMjRjHk0hF9NSWbns9QHjdminA/Y/0E/C8I=; b=qeGmDUnywGvlJ/oaglBW2XdNWTBBwtuCvqfeIuNj0kb4oc7MYvg+usejTDpLP9KHyh CeMzgupSNzq06ZnHouHlJnyYaZPmqKgYJMpVXUqv5Pd+GZl3kBiNKMbyBf3ZvzLod2JY SDPYT12FTtPv8JOzhD7aIWhCan1IUcaAj25FU+B2u7bQTFO6oxvDFwnHrie6nNcKRIxo LsLKijt4GsLSgs2eDb3oMcUjftAam7EKOMUzUwFnMnm1H9EFq/1ddS9F3LvG7YHOpQWq J+9ZUKuPs2EJ6ujD112WPulDrs8Azalakkdvi1UHVvzJk3AhtTIl/NT5J8fI5GNToWpM H86w== X-Forwarded-Encrypted: i=1; AFNElJ9H0dmqnOvP4ch4bElVhvXKHdSFnxFR/V2UxgfAl3gHS3/ZSuon3JiXueuE7xrG5VHk7XMc7FUauz4BOzQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzraAv+10DeYjdgGQ1TKKEr0PCvO+AJyO1pmHb2cPE6ANvtwKgK HwATUWABw1hGFYukebX6OzHIPt4K6z99YobEJs7XieCVmZFeuUJhFvxRmS1HRdypJa0= X-Gm-Gg: Acq92OG7GSdnW+HHOponHj+ZahTB5qrMwkYCMDZtvlwtncp2hrHh/h3KDOhPFXfIqwp XppQWS+hU2qTKj9VM29A4c37xmRrB+IkHdvava0djpiMA6AY+iiuGmm3qQGWESzz0w/OZhu6rA1 /haHgWSbHkd7h1gsl0xckf3jKqEzVBGIeqvQuk8NyzmkrYujmpEaKHvX/pYtzv8V78K7UTZfpA2 wVFCc54JS4H/bk9+1kGuHAN9i5T5+Jz6Gp2KRBM4i/l815lPb6T473ciGYm+kUP8igpoX8y5pWO NwJtBdOYsewEKQhJHevlT1dd/jakIErWurzsQf74v8IrfyUM0WSzPbPei0BCkG3xNREZX927Wc8 gGf3Aa+gbiTXclXW5pEJde3GwZRLgdZrsKQxnKMQFR/DXHhLroJJS3gu4cwdWLOi2k73UOseHRx 731LHm1W2pDDolVv48kYqfLYDU4H+AhRTr9HF3mBS1f0Y= X-Received: by 2002:a05:600c:4f50:b0:488:d6eb:e63c with SMTP id 5b1f17b1804b1-490b5ea32a4mr51625575e9.15.1780481843826; Wed, 03 Jun 2026 03:17:23 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:23 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:06 +0100 Subject: [PATCH v3 02/19] perf test: Add workload-ctl 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: <20260603-james-cs-context-tracking-fix-v3-2-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Add a --workload-ctl=3Dfifo:ctl-fifo[,ack-fifo] option for 'perf test -w'. When set, run_workload() opens the named FIFO, writes enable before invoking the builtin workload, writes disable before returning, and waits for ack responses when an ack FIFO is provided to ensure that the workload doesn't run until the events are enabled. This can be used to limit the scope of the recording to only the workload execution and avoid recording Perf setup and teardown code if Perf record is started with events disabled (-D 1). Assisted-by: Codex:GPT-5.5 Signed-off-by: James Clark --- tools/perf/Documentation/perf-test.txt | 6 ++ tools/perf/tests/builtin-test.c | 184 +++++++++++++++++++++++++++++= +++- 2 files changed, 188 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentat= ion/perf-test.txt index 32da0d1fa86a..1faf30d4a7be 100644 --- a/tools/perf/Documentation/perf-test.txt +++ b/tools/perf/Documentation/perf-test.txt @@ -69,3 +69,9 @@ OPTIONS =20 --list-workloads:: List the available workloads to use with -w/--workload. + +--workload-ctl=3Dfifo:ctl-fifo[,ack-fifo]:: + Write 'enable' to ctl-fifo before running the workload and 'disable' + before returning. If ack-fifo is provided, the workload runner waits for + an 'ack' response after each command. This scopes the recording to only + the workload if used with 'perf record -D 1 --control ...'. diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index f2c135891477..a9e67d7da700 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -50,6 +50,7 @@ static bool sequential; static unsigned int runs_per_test =3D 1; const char *dso_to_test; const char *test_objdump_path =3D "objdump"; +static const char *workload_control; =20 /* * List of architecture specific tests. Not a weak symbol as the array len= gth is @@ -161,6 +162,11 @@ static struct test_workload *workloads[] =3D { #endif }; =20 +struct workload_control { + int ctl_fd; + int ack_fd; +}; + #define workloads__for_each(workload) \ for (unsigned i =3D 0; i < ARRAY_SIZE(workloads) && ({ workload =3D workl= oads[i]; 1; }); i++) =20 @@ -711,13 +717,185 @@ static int workloads__fprintf_list(FILE *fp) return printed; } =20 +static int perf_control_open_fifo(struct workload_control *ctl, const char= *str) +{ + char *s, *p; + int ret; + + if (strncmp(str, "fifo:", 5)) + return -EINVAL; + + str +=3D 5; + if (!*str || *str =3D=3D ',') + return -EINVAL; + + s =3D strdup(str); + if (!s) + return -ENOMEM; + + p =3D strchr(s, ','); + if (p) + *p =3D '\0'; + + ctl->ctl_fd =3D open(s, O_WRONLY | O_CLOEXEC); + if (ctl->ctl_fd < 0) { + ret =3D -errno; + pr_err("Failed to open workload control FIFO '%s': %m\n", s); + free(s); + return ret; + } + + if (p && *++p) { + ctl->ack_fd =3D open(p, O_RDONLY | O_CLOEXEC); + if (ctl->ack_fd < 0) { + ret =3D -errno; + pr_err("Failed to open workload control ack FIFO '%s': %m\n", p); + close(ctl->ctl_fd); + ctl->ctl_fd =3D -1; + free(s); + return ret; + } + } + + free(s); + return 0; +} + +static int perf_control_open(struct workload_control *ctl) +{ + int ret; + + if (!workload_control) + return 0; + + ret =3D perf_control_open_fifo(ctl, workload_control); + + if (ret =3D=3D -EINVAL) { + pr_err("Unsupported workload control spec '%s', expected fifo:ctl-fifo[,= ack-fifo]\n", + workload_control); + } + + return ret; +} + +static void perf_control_close(struct workload_control *ctl) +{ + if (ctl->ctl_fd >=3D 0) { + close(ctl->ctl_fd); + ctl->ctl_fd =3D -1; + } + if (ctl->ack_fd >=3D 0) { + close(ctl->ack_fd); + ctl->ack_fd =3D -1; + } +} + +static int perf_control_write_cmd(int fd, const char *cmd) +{ + size_t len =3D strlen(cmd); + ssize_t ret; + + while (len) { + ret =3D write(fd, cmd, len); + if (ret < 0) { + if (errno =3D=3D EINTR) + continue; + pr_err("Failed to write perf control command: %m\n"); + return -1; + } + + if (!ret) { + pr_err("Failed to write perf control command: short write\n"); + return -1; + } + + cmd +=3D ret; + len -=3D ret; + } + + return 0; +} + +static int perf_control_read_ack(int fd) +{ + char buf[16]; + ssize_t ret; + + do { + ret =3D read(fd, buf, sizeof(buf) - 1); + } while (ret < 0 && errno =3D=3D EINTR); + + if (ret < 0) { + pr_err("Failed to read perf control ack: %m\n"); + return -1; + } + + if (!ret) { + pr_err("Unexpected EOF while reading perf control ack\n"); + return -1; + } + + buf[ret] =3D '\0'; + for (ssize_t i =3D 0; i < ret; i++) { + if (buf[i] =3D=3D '\n' || buf[i] =3D=3D '\0') { + buf[i] =3D '\0'; + break; + } + } + + if (strcmp(buf, "ack")) { + pr_err("Unexpected perf control ack: %s\n", buf); + return -1; + } + + return 0; +} + +static int perf_control_send(struct workload_control *ctl, const char *cmd) +{ + if (ctl->ctl_fd < 0) + return 0; + + if (perf_control_write_cmd(ctl->ctl_fd, cmd)) + return -1; + + if (ctl->ack_fd >=3D 0 && perf_control_read_ack(ctl->ack_fd)) + return -1; + + return 0; +} + static int run_workload(const char *work, int argc, const char **argv) { struct test_workload *twl; =20 workloads__for_each(twl) { - if (!strcmp(twl->name, work)) - return twl->func(argc, argv); + struct workload_control ctl =3D { + .ctl_fd =3D -1, + .ack_fd =3D -1, + }; + int control_ret, ret; + + if (strcmp(twl->name, work)) + continue; + + ret =3D perf_control_open(&ctl); + if (ret) + return ret; + + if (perf_control_send(&ctl, "enable\n")) { + perf_control_close(&ctl); + return -1; + } + + ret =3D twl->func(argc, argv); + + control_ret =3D perf_control_send(&ctl, "disable\n"); + perf_control_close(&ctl); + if (control_ret) + return -1; + + return ret; } =20 pr_info("No workload found: %s\n", work); @@ -799,6 +977,8 @@ int cmd_test(int argc, const char **argv) OPT_UINTEGER('r', "runs-per-test", &runs_per_test, "Run each test the given number of times, default 1"), OPT_STRING('w', "workload", &workload, "work", "workload to run for testi= ng, use '--list-workloads' to list the available ones."), + OPT_STRING(0, "workload-ctl", &workload_control, "fifo:ctl-fifo[,ack-fifo= ]", + "Write enable to the fifo just before running the workload and disabl= e after, with optional ack from ack-fifo"), OPT_BOOLEAN(0, "list-workloads", &list_workloads, "List the available bui= ltin workloads to use with -w/--workload"), OPT_STRING(0, "dso", &dso_to_test, "dso", "dso to test"), OPT_STRING(0, "objdump", &test_objdump_path, "path", --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 8296C370D7C for ; Wed, 3 Jun 2026 10:17:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481848; cv=none; b=rJ2gNROFICm8/wrDwybk+OVejDvT/p/kzWevps1HJnY/LJZP77xY/sLJN85Gi2aZF7ICDhLUy+zBOC7kLePulwzsdsEHFl9BrXoVvtOYv/9de5v/4lWeP0n8T5niMs0GH5NxLA32XIqyCyE3XsOPEPWN7tk7X5wRwfR/KufAj+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481848; c=relaxed/simple; bh=6k19SDxCL9D1KuWrvkZA+rOT1XqhgBbavkC2y8a1YGE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R5opRR4bFvB882QpYxuS72C5kknAwqw2bOrYfU4VOTjYiAkc1XUgaMIuTIuFVLrRxbT6F4fZt2WWImrwK7TM+P2COfun2/dZ4sAgC038NdLmic51ctvXbx0S4ugfjcSZAnmi7X6NapNnm9nphPy4ytbtLN2pyxJxQyxxKJOobnA= 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=NRHjaWbH; arc=none smtp.client-ip=209.85.128.41 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="NRHjaWbH" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4903f7a90d1so114312155e9.2 for ; Wed, 03 Jun 2026 03:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481845; x=1781086645; 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=Bb5mYn/X2kb9euudhIWHaZoD8uTAINcjaTMlJ6g7asU=; b=NRHjaWbH/NosnK3mk4a1TSXb77uMj8/xnIVl66ntzIrcvmp+gXIE/tZnJrjA50lnhC LsjuavdjEfADvJFLi5ZZhBe3IB5bS9pRsmaZUpKQwYfiaQkBxEW2uj7OsWzAYqfk2JRS +0vw7yqQ/sYevhTHuf1y27WtyID0S5uYQZkSceIWQXzUEAeQwPdqgqOBZpPPR4whrPPm PqChzSBdievRPTdWZokbWxlQZTIXvuRsnRAb5CSVDiFnOq33crjzs+HF1Zcm+93hlxK0 55JZbJCTh7TB08MCieSmJ4NMjW9VwAV6YKi0t9n87eq1Z8LiuPJ3XvZFWd1WCigd7pSc u+ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481845; x=1781086645; 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=Bb5mYn/X2kb9euudhIWHaZoD8uTAINcjaTMlJ6g7asU=; b=ee9TjcL9FE1j64JpGivutJ7huCYPuOHc02ZopLJbHlHNaZKjmo89AiFu8f8tqrX4St y/NDacywPgKObdNH7hLyX1Pd0S4ed42C0On24mvbPVfGdgvQ4QPdxMBUneQh/13IxlTG w/zqm0o2OZ4++FjjdHFoFioP243OsDgbYRZC/BO97yRYxe2F9V6mlMxAhy3Cl+kX/77a 9QeTd2yboVDWohMgi18rjPv319fQ5loaAc3BZCWsC05vxDEqvr/VFDuxFs9mZLsmJvAY iZeajJHNUoAf9fYtEfoB9rXCWX+F3NuTKAX9PoOefmkP7lIbfIiVZ9MB8WjM3yF3jw6X igAw== X-Forwarded-Encrypted: i=1; AFNElJ/oAjdOgjoSgPeU0Y4ewLiKcX0RPNxHvDJb84tDJ+5dpuqJCsSaIDjUyGGU7md2xctALPzVLCdUpWUAs4k=@vger.kernel.org X-Gm-Message-State: AOJu0Yxaq1YttKra+SGIuRk15m4CDRxU40nFFEmsB1/JUgpeF4Or0cM5 v+XIcZapTf/BbhrtdSyZc5JALMRe95fFHCNSE8+bIKxaWol0AZM/KdSvzeQxg6N57mpCkFs4a5X 37Pq05+4= X-Gm-Gg: Acq92OGaAv3iQh1ZNXrx8uSamE+MP9R2tl16s6+i8pCMBOsROpcQ9cZ7zKLiaoVZRxT JuYQcpqPUj1RB89e3LUsQtgC99SLWahWT22FEp7/YCGCZrp2ljNFvc1NdRaUSCUup5uz1x+e/8d 4XCOXzjg5DigTizwv24cuZ1yTql7R5x1ena37l07JKsKI1lsnqISG3O21wupGlRXUrNgSyvxo+j hxu8X173zaLOD9ujxA5wG/99TG4wiG9TVjjl9GNJkSd4HBgau0JVgVyk/viNiCePE9nat1JzouM rDw+eR65U2hLTZDKSmY2auUt4rI35YAh4DbAwqm9Hgsj+4CE5CIGNylZ7KB2p8WwKawfL4ocFHb eql3rJNkVqco8rPHIPlEl3G+31qdQ5RxdTuAoiVtjFUS1UQF7G7vyiselnGAqBZLJ3pLFN/1xD7 /g6rGb6tt54eo5B0khxF+2FqKuGllYLkyKyiI+p6r77Fo5wvxZiwkDSQ== X-Received: by 2002:a05:600c:1c1e:b0:490:b35c:88ea with SMTP id 5b1f17b1804b1-490b5ed1429mr46254965e9.15.1780481844944; Wed, 03 Jun 2026 03:17:24 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:24 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:07 +0100 Subject: [PATCH v3 03/19] perf test: Add a workload that forces context switches 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: <20260603-james-cs-context-tracking-fix-v3-3-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 This workload launches two processes that block when reading and writing to each other forcing the other process to be scheduled for each read/write pair. Signed-off-by: James Clark --- tools/perf/Documentation/perf-test.txt | 7 +- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 1 + tools/perf/tests/workloads/context_switch_loop.c | 101 +++++++++++++++++++= ++++ 5 files changed, 108 insertions(+), 3 deletions(-) diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentat= ion/perf-test.txt index 1faf30d4a7be..9c0d7ac2bc64 100644 --- a/tools/perf/Documentation/perf-test.txt +++ b/tools/perf/Documentation/perf-test.txt @@ -55,15 +55,16 @@ OPTIONS =20 -w:: --workload=3D:: - Run a built-in workload, to list them use '--list-workloads', current one= s include: - noploop, thloop, leafloop, sqrtloop, brstack, datasym and landlock. + Run a built-in workload, to list them use '--list-workloads', current + ones include: noploop, thloop, leafloop, sqrtloop, brstack, datasym, + context_switch_loop and landlock. =20 Used with the shell script regression tests. =20 Some accept an extra parameter: =20 seconds: leafloop, noploop, sqrtloop, thloop - nrloops: brstack + nrloops: brstack, context_switch_loop =20 The datasym and landlock workloads don't accept any. =20 diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index a9e67d7da700..2830a431771f 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -156,6 +156,7 @@ static struct test_workload *workloads[] =3D { &workload__landlock, &workload__traploop, &workload__inlineloop, + &workload__context_switch_loop, =20 #ifdef HAVE_RUST_SUPPORT &workload__code_with_type, diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index ee00518bf36f..79f50bacfc94 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -242,6 +242,7 @@ DECLARE_WORKLOAD(datasym); DECLARE_WORKLOAD(landlock); DECLARE_WORKLOAD(traploop); DECLARE_WORKLOAD(inlineloop); +DECLARE_WORKLOAD(context_switch_loop); =20 #ifdef HAVE_RUST_SUPPORT DECLARE_WORKLOAD(code_with_type); diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/= Build index 2ef97f7affce..3bda6da04a35 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -9,6 +9,7 @@ perf-test-y +=3D datasym.o perf-test-y +=3D landlock.o perf-test-y +=3D traploop.o perf-test-y +=3D inlineloop.o +perf-test-y +=3D context_switch_loop.o =20 ifeq ($(CONFIG_RUST_SUPPORT),y) perf-test-y +=3D code_with_type.o diff --git a/tools/perf/tests/workloads/context_switch_loop.c b/tools/perf/= tests/workloads/context_switch_loop.c new file mode 100644 index 000000000000..173d770ae619 --- /dev/null +++ b/tools/perf/tests/workloads/context_switch_loop.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include +#include + +#include "../tests.h" + +static int loops =3D 100; +static char buf; +int context_switch_loop_work =3D 1234; + +#define write_block(fd) \ + do { \ + if (write(fd, &buf, 1) <=3D 0) \ + exit(1); \ + } while (0) + +#define read_block(fd) \ + do { \ + if (read(fd, &buf, 1) <=3D 0) \ + exit(1); \ + } while (0) + +/* Not static to avoid LTO clobbering the function name */ +void context_switch_loop_proc1(int in_fd, int out_fd); +noinline void context_switch_loop_proc1(int in_fd, int out_fd) +{ + for (int i =3D 0; i < loops; i++) { + read_block(in_fd); + context_switch_loop_work +=3D i * 3; + write_block(out_fd); + } +} + +void context_switch_loop_proc2(int in_fd, int out_fd); +noinline void context_switch_loop_proc2(int in_fd, int out_fd) +{ + for (int i =3D 0; i < loops; i++) { + write_block(out_fd); + context_switch_loop_work +=3D i * 7; + read_block(in_fd); + } +} + +/* + * Launches two processes that take turns to execute a multiplication N ti= mes + */ +static int context_switch_loop(int argc, const char **argv) +{ + int a_to_b[2], b_to_a[2]; + pid_t proc1_pid; + int status; + + if (argc > 0) { + loops =3D atoi(argv[0]); + if (loops < 0) { + fprintf(stderr, "Invalid number of loops: %s\n", argv[0]); + return 1; + } + } + + if (pipe(a_to_b) || pipe(b_to_a)) { + perror("Pipe error"); + return 1; + } + + proc1_pid =3D fork(); + if (proc1_pid < 0) { + perror("Fork error"); + return 1; + } + + if (!proc1_pid) { + close(a_to_b[0]); + close(b_to_a[1]); + prctl(PR_SET_NAME, "proc1", 0, 0, 0); + context_switch_loop_proc1(b_to_a[0], a_to_b[1]); + close(a_to_b[1]); + close(b_to_a[0]); + exit(0); + } + + close(a_to_b[1]); + close(b_to_a[0]); + prctl(PR_SET_NAME, "proc2", 0, 0, 0); + context_switch_loop_proc2(a_to_b[0], b_to_a[1]); + close(a_to_b[0]); + close(b_to_a[1]); + + if (waitpid(proc1_pid, &status, 0) !=3D proc1_pid || !WIFEXITED(status) || + WEXITSTATUS(status)) + return 1; + + return 0; +} + +DEFINE_WORKLOAD(context_switch_loop); --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 C1DD0357739 for ; Wed, 3 Jun 2026 10:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481850; cv=none; b=AECFYqVeokuftiuhgyyP27wEtSyQQ+aZu0SrBj7MtNavTHUgx1TVgaVZEtO37VGu9ZzYAx/UHTT+xIkACha+QtQBD/MUM0cLhAIC1TPi6vGscVrKxdJ+vJJPgyrOJAbR43csLD9RZ4mxIGtnbsq+oecdaSWONbCKh1F0/XdOYgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481850; c=relaxed/simple; bh=iQVBxA25lW6A4uA0ACC2OMef9MHB9JOIgp6xmgt6rqE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A/nntPzBaQgrGbSz8TAuNCaXZJikOsgG9sofv6uQfr64oB0yNmdk3I1ARztQCaRQAiXUWw3mLX5huznVk1fF8ry69l361Fyzk2BMx557tZg9kr1z8hmczJVfTblZ/sRNCE9Yu2b7+Q5rex7Bspea/gFLzjpx1xVX++zqNpAWSVc= 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=YcIi0puf; arc=none smtp.client-ip=209.85.128.47 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="YcIi0puf" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-490ae94a89eso25612235e9.1 for ; Wed, 03 Jun 2026 03:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481846; x=1781086646; 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=EO8/K9YxgiEJpvhD7v23MJuqc72Imxv7cQ7m/8nhtl0=; b=YcIi0puf/rr0LOsttgmuR9cl0YySyBjDmDO4eRwzLbZMiFhyMD1lnjCQC1DA1GCpKZ PgQ2fcQMt8iR+CFbhigAcSvvOMjlImHjJZUGhkGBIkLhKk0xd/u7gm6fK24e9spUNMuN NRZgqSVVB3Lf97xPhlI1G6koP+jZy4NLdSP2yqoyYRn5M6/6Kbuboc3CmEPoD9bwGjZh iLiOaaE4TD1n6JUJH7dtGTgmEnRspON4bbxK6VK9kmT1VLUtF2rWdkAeobOEv7nndYup mOHmwY8mW1MrVzC14Ca80mN7JDiFDmCVF1akGKzz2NZY7YY5oPBAKlFnIuVPtq/X/dIZ 9QVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481846; x=1781086646; 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=EO8/K9YxgiEJpvhD7v23MJuqc72Imxv7cQ7m/8nhtl0=; b=sgNJlAbZob7DGTzzzprfEwp2OX7KVs44InJ9YfX5Peqkqd+8Sown0SdvSzVSgL6lL3 bkYHqGMdZKYCfbfxF1x096s+2CREvySV8jJadZHA3nTtb3iqXcu3e6yEAd4M3F7WxLnq 6Kf/iIxId1Aqp7fM5qzUZgP0I7MBEl0POR1JDBT9rshhXQ0LcNp3agWR5NaHD8GtU4hN U+geoEe9pSqVrCmeEqUMTDr64OvIC428j7j6Godo+soohqO0i1j3tVsXqkruwxdRh+ay Ud9TB16BNqWYzY75iYqVlYe2dJEN390AUEh8lwPRLTdtYoAhDpmsIXPhHtDAkKI7/xMt KgxQ== X-Forwarded-Encrypted: i=1; AFNElJ+hXHRXPWn3GANeR2jYf72g7mwoYw8sposQ8bEuODUIQO1F8f8qAhOSMpAGBVy8WVK0RzveSZ0TzgO7tdE=@vger.kernel.org X-Gm-Message-State: AOJu0YznA7W/cNrIMw5VBi5aJP92K7w97X2P3eIVyLI0eVoipmw9KvZF hiuTHWrrT6MWkzBRmehVbZ7Gv67IDT0FBBjc5IDi+cwFvaReiZv3SAbvJhCm/+Qz3Cs= X-Gm-Gg: Acq92OHGqpBzLwRPZLFAtVUkdVvB8dVpsQr+E4kG44kmlnMAMs+8bjk9rbyi/uiSq8F i61kriDK5U2tkMskcTFDe5L9IxOQJLTbnhXanPf9b7c2NRiJ30PbOL9ahGf4XtK6LiUKDF8ePEb EPm3Zz9SMqqBTns+413VM2hnt+q0WwNg06TgCZGIQhTPyLckMrjyr0VleD9bRW3l5IpOMS14nME tJtptyN+3ZWi+o/sNX1FAm2Qrj0ZrliRkhhEHyjh4IQuOhmsJkokN3u63VdI49d/r8RbOGVQQqI 4UVdus4SNUlCo/2HoLdNPpyrSHg7Ld2EDi7XbNYZvLkLA0oq4HfcYtA1+2xHVOfzIB3vvMxtrzo sNl9AJ3oQJTuGQGohy1lzJRqdovgdjLVIC5Lplx2JdwXvwoWtr9ikilI3rQbkYNptGEzbhSvm0R 9HZE5HMEpi2dw2T8uxNkjBNCvDytyza90VPZupG1BMXuU= X-Received: by 2002:a05:600c:458b:b0:490:6e12:542d with SMTP id 5b1f17b1804b1-490b5fe0af4mr45931785e9.19.1780481846203; Wed, 03 Jun 2026 03:17:26 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:25 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:08 +0100 Subject: [PATCH v3 04/19] perf test cs-etm: Test process attribution 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: <20260603-james-cs-context-tracking-fix-v3-4-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Run the context switch workload on one CPU and trace it to test that symbols are attributed to the correct process and that the attribution changes at the exact point that the context switch happened. Signed-off-by: James Clark --- .../tests/shell/coresight/context_switch_thread.sh | 69 ++++++++++++++++++= ++++ 1 file changed, 69 insertions(+) diff --git a/tools/perf/tests/shell/coresight/context_switch_thread.sh b/to= ols/perf/tests/shell/coresight/context_switch_thread.sh new file mode 100755 index 000000000000..0992c35a329d --- /dev/null +++ b/tools/perf/tests/shell/coresight/context_switch_thread.sh @@ -0,0 +1,69 @@ +#!/bin/bash -e +# Coresight context switch thread attribution (exclusive) + +# SPDX-License-Identifier: GPL-2.0 + +# If Coresight is not available, skip the test +perf list pmu | grep -q cs_etm || exit 2 + +if [ "$(id -u)" !=3D 0 ]; then + # Requires root for "-C 0" in record command + echo "[Skip] No root permission" + exit 2 +fi + +tmpdir=3D$(mktemp -d /tmp/__perf_test.coresight_context_switch.XXXXX) + +cleanup() { + rm -rf "${tmpdir}" + trap - EXIT TERM INT +} + +trap_cleanup() { + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +check_samples() { + owner_samples=3D$(grep -c "proc1.*context_switch_loop_proc1" "$tmpdir/scr= ipt" || true) + next_samples=3D$(grep -c "proc2.*context_switch_loop_proc2" "$tmpdir/scri= pt" || true) + + if [ "$owner_samples" -eq 0 ] || [ "$next_samples" -eq 0 ]; then + echo "No samples found" + cleanup + exit 1 + fi + + if grep "proc2.*context_switch_loop_proc1" "$tmpdir/script"; then + echo "Thread1 symbol was attributed to proc2" + cleanup + exit 1 + fi + + if grep "proc1.*context_switch_loop_proc2" "$tmpdir/script"; then + echo "Thread2 symbol was attributed to proc1" + cleanup + exit 1 + fi +} + +cf=3D"$tmpdir/ctl" +af=3D"$tmpdir/ack" +mkfifo "$cf" "$af" + +# Pin to one CPU so the two threads alternate running but record into the = same +# trace buffer. Start disabled and use the control FIFO to only record the +# workload and not startup. +perf record -o "$tmpdir/data" -e cs_etm/timestamp=3D0/u -C 0 -D -1 --contr= ol fifo:"$cf","$af" -- \ + taskset --cpu-list 0 perf test --workload-ctl fifo:"$cf","$af" \ + -w context_switch_loop > /dev/null 2>&1 + +# Test both instruction and branch sample generation modes. +perf script -i "$tmpdir/data" --itrace=3Di4 -F comm,pid,tid,ip,sym > "$tmp= dir/script" 2>/dev/null +check_samples +perf script -i "$tmpdir/data" --itrace=3Db -F comm,pid,tid,ip,sym > "$tmpd= ir/script" 2>/dev/null +check_samples + +cleanup +exit 0 --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 B6B0E3A872C for ; Wed, 3 Jun 2026 10:17:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481850; cv=none; b=AmrBm9Esmk2syZ/2QsSNja1KN6hOjRh5M7dkJ1IKsUKkCJycN7Z/iXv/j+1c9t7yKDfJpJHO1GbiB/pjglW69KrQaFmmzvbdPRDNaVTghfyE2glHI5LS/KNN72qxiuH1ew9LTj7nlFQVYvqN4TJ/x1HZqkYoIbqVu1P82yxnbbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481850; c=relaxed/simple; bh=EgF9wlG8ZbGpA6Fw8M+WUSk6oGa9DEGTh/b30THx494=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UAQw/vvLv65hbA5HUrum8iqj1xplbO0m8vAdouCbEmA6qu5juWlEKeNlrMasyMJ1arHGX+xQx/Ot0JXEv7nI96L1wAeoAd+7BxjYWWPUSWPUZiyxB+z/Kz+Sg76hDBZ8BcrjwshdzyGiRg7iFoOFmkicXjdlp40VCDvmzle/iwU= 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=e2fPNk1D; arc=none smtp.client-ip=209.85.128.44 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="e2fPNk1D" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so94281575e9.0 for ; Wed, 03 Jun 2026 03:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481847; x=1781086647; 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=uIva9g/gVoYEr2OQuQ3ZFE/kcOOWkyDfg5JnXdWNeQY=; b=e2fPNk1DEIBKYzujsa/lNs9C8rNSdvctop1VRd+FE8AVBd3i+pRrsmUFI9tehMj2sW XFQmIyx0vKY3o36ZLRfkEuN8At25TKXs6h0SeMXmw5OLFkyov1u5+qEN5m8m1LlMbDZi JaPMNhVg6n45RosiIFC1hiPvU7pIeFICQaFwLjHZ2paXtK6chm3eskSnBsobFRslJ2S/ wSo87Xaau2h3Lx/IWktl+QM85/5l2SfnMmMXnQUHxkla0eb9YwJxaN7ASXGBUPWG8xVo lmQyxRt3hfALPibKgi6aWyemgvNn72UbObysOURJvUQTgyODJSYjjYCqPs5GJrewMKGq lbOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481847; x=1781086647; 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=uIva9g/gVoYEr2OQuQ3ZFE/kcOOWkyDfg5JnXdWNeQY=; b=HLAd4+WblPr0Y24GDzTjVcFBZY2eRWAtnA7iF9sYbUkubldW5q/Lw3qyjkHqnYKm2W RwTZJupx1ZfWoMFOD74yuY6mFUTwmi//qF5TbSP/eZENUfzWu3F/IrBoEU8FIbKbe9nf vEFephZaGYFfki4ogbQTq/x897qi4OnNzsUEYnFYCaw8rD25kh6dPn1OkSskjGqkESfy h5961OnVs9lCVlM0V/tQw6uW/66eKnXvPSWBgd+sPtj4rF7SBp+oHSsXKVCbAAlcorYW ZhdOqatT9Kss3WMwbiF0iOb4O5On+bPGilXvY3GL8DOqT2OdwB1O5Cf57g4ZiVRGYM05 WCRA== X-Forwarded-Encrypted: i=1; AFNElJ+HvJHwmyqRCXXzyTDiGv9wVdUXTAm8/IF3wNir2MSDwuppqtw2wgBe+zSGl0uCP+nqvWJq+UUK71WN4OA=@vger.kernel.org X-Gm-Message-State: AOJu0Ywm5s7ilvo4sR4I7bg469tIKo3hPLL3tMfHJaEfCxqDNLuPmDED ixlBK4p3/+K/0xeq6MPbu28P/5QhrH6dZlObxPQBVaOfRBj0wbyDYJVu5zkpt6Yo8DU= X-Gm-Gg: Acq92OF7lSxCnltSUzxlgJbXuG++3qdm2x4zKgHRP1N1NOIHSVzjnzpaTKxrLhKFPIl xR4RA2JAZ/cyQ6A/o7hNsP8HEirHhSfl1C7sfwFk0tMd9vsHVKmmxsjGMQ0yYuUxdFULokXbjut muOcoibSIs8/NiyVROLPSVJoNP1J99xAc7AduOVpy+AF9MH3EYxXmo4TAzMZighBbVVoZGZM4RJ 0jOxObxDt7b6fwQPl0w7aYWPVSxoINotkciKBW3rpiM99O/1ddHu0AQPUoC5RYWhfCJSqRkAaCS 3ovPGIGB9EnIit1T2DX3FxDXop3pQaNjuI9Dn2cER8cbBvc5wf7Ghkq3uYEzN9PuXVcfGvr66yZ QAwu7TcstPUQtH5YgsXe+9v8alGEjqMHLu/TkjjOiJBRAdtcNcq21DUMpFXE4Zvdpo47DqVoFZ3 S7vXvmFWk6SAiy/3PPRSTMc+ZhhhA/lawQMlg3IMtg41LE2xiCNGbFDQ== X-Received: by 2002:a05:600c:3490:b0:490:b7a2:8864 with SMTP id 5b1f17b1804b1-490b7a28a0amr33243145e9.0.1780481847229; Wed, 03 Jun 2026 03:17:27 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:26 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:09 +0100 Subject: [PATCH v3 05/19] perf test: Add deterministic workload 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: <20260603-james-cs-context-tracking-fix-v3-5-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Add a workload that does the same thing every time for testing CPU trace decoding. Signed-off-by: James Clark --- tools/perf/Documentation/perf-test.txt | 4 +-- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 2 ++ tools/perf/tests/workloads/deterministic.c | 39 ++++++++++++++++++++++++++= ++++ 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentat= ion/perf-test.txt index 9c0d7ac2bc64..7ec70c054cac 100644 --- a/tools/perf/Documentation/perf-test.txt +++ b/tools/perf/Documentation/perf-test.txt @@ -57,7 +57,7 @@ OPTIONS --workload=3D:: Run a built-in workload, to list them use '--list-workloads', current ones include: noploop, thloop, leafloop, sqrtloop, brstack, datasym, - context_switch_loop and landlock. + context_switch_loop, deterministic and landlock. =20 Used with the shell script regression tests. =20 @@ -66,7 +66,7 @@ OPTIONS seconds: leafloop, noploop, sqrtloop, thloop nrloops: brstack, context_switch_loop =20 - The datasym and landlock workloads don't accept any. + The datasym, landlock and deterministic workloads don't accept any. =20 --list-workloads:: List the available workloads to use with -w/--workload. diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 2830a431771f..5a2ab67cd85d 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -157,6 +157,7 @@ static struct test_workload *workloads[] =3D { &workload__traploop, &workload__inlineloop, &workload__context_switch_loop, + &workload__deterministic, =20 #ifdef HAVE_RUST_SUPPORT &workload__code_with_type, diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 79f50bacfc94..f8bba2d68769 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -243,6 +243,7 @@ DECLARE_WORKLOAD(landlock); DECLARE_WORKLOAD(traploop); DECLARE_WORKLOAD(inlineloop); DECLARE_WORKLOAD(context_switch_loop); +DECLARE_WORKLOAD(deterministic); =20 #ifdef HAVE_RUST_SUPPORT DECLARE_WORKLOAD(code_with_type); diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/= Build index 3bda6da04a35..cca7ad354227 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -10,6 +10,7 @@ perf-test-y +=3D landlock.o perf-test-y +=3D traploop.o perf-test-y +=3D inlineloop.o perf-test-y +=3D context_switch_loop.o +perf-test-y +=3D deterministic.o =20 ifeq ($(CONFIG_RUST_SUPPORT),y) perf-test-y +=3D code_with_type.o @@ -22,3 +23,4 @@ CFLAGS_brstack.o =3D -g -O0 -fno-inline -U_FORTI= FY_SOURCE CFLAGS_datasym.o =3D -g -O0 -fno-inline -U_FORTIFY_SOURCE CFLAGS_traploop.o =3D -g -O0 -fno-inline -U_FORTIFY_SOURCE CFLAGS_inlineloop.o =3D -g -O2 +CFLAGS_deterministic.o =3D -g -O0 -U_FORTIFY_SOURCE diff --git a/tools/perf/tests/workloads/deterministic.c b/tools/perf/tests/= workloads/deterministic.c new file mode 100644 index 000000000000..3caea8564043 --- /dev/null +++ b/tools/perf/tests/workloads/deterministic.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include "../tests.h" + +int dt_work =3D 1234; + +static noinline void function1(void) +{ + dt_work *=3D 7; + dt_work *=3D 7; + dt_work *=3D 7; +} + +static noinline void function2(void) +{ + dt_work *=3D 7; + dt_work *=3D 7; + dt_work *=3D 7; +} + +static int deterministic(int argc __maybe_unused, + const char **argv __maybe_unused) +{ + dt_work *=3D 7; + dt_work *=3D 7; + dt_work *=3D 7; + + function1(); + + dt_work *=3D 7; + dt_work *=3D 7; + dt_work *=3D 7; + + function2(); + + return 0; +} + +DEFINE_WORKLOAD(deterministic); --=20 2.34.1 From nobody Mon Jun 8 04:25:58 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 C13F9383323 for ; Wed, 3 Jun 2026 10:17:29 +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=1780481851; cv=none; b=VKQKUzRg9h67SjZoAQCDCkiKAh45AFitNj42GqIuhGi0kL/upZ0O0ahmtKq+9wj7hGSVzna+nPRG0r4uCDkumXt6i49hLQAXnYwADaiFPKua9pKt1l8Jd9OclCoIsupClmt1m8zL2q5+KXNcSvj2w4jpQ69x7OGkmnt9Bnno3LE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481851; c=relaxed/simple; bh=ESmfjIh7MN23IeBJPxwPdBU7xBIa18aM//caXhGjZcM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gI0lcnBkfhre3KUfNwDvBZIB2BDdEcnWBgu/YWcDFbtBuXb7Z+FYHb96dA/N392Sg07km8mCCIwj/WAqzU25oHAOB2t5L0lJHSy3ffLpVAPfMgdliK4FWTQPwM9Xwo9+y+JVdJZzpdqhz9sRCWJEnQSnLocWE+NTKRQG2yXYTnE= 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=lgaUu2iy; 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="lgaUu2iy" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490b4e1ade7so10084985e9.0 for ; Wed, 03 Jun 2026 03:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481848; x=1781086648; 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=pXjR0tiVSlnNG0AciIMM1oZd4f63sbXFpo0GMT42zX4=; b=lgaUu2iyJyDxzbErkikl8wB/pDiinjfL0zeL7gnrNA7CSJ94VhQO9qwD6GRebkLPIT MXrdBvE+XaORPDcsxwky0UQlpa+NkwAKKdwFuirOGeaURI8CGJ1MhGUWQOWH4BHuAZSM CSVbRraoUVtde0gldYuovAtao/ouCcySKkHL6wNFvmPQ9MHmNCCHVReajd7Xm2Utxc/J vzCBNOI+fYHzrUErFM/zcf3QERZdnZqR1z088D3NKnacbPuszWGAfM1t+qbKRaILnW6B cY1TUhGCo/1hDtIEUQnkmyKq9OLciL5IAvpC9d6+J+aJ8G7q3j2r8ytr2fDtYBcbAmJ4 G9og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481848; x=1781086648; 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=pXjR0tiVSlnNG0AciIMM1oZd4f63sbXFpo0GMT42zX4=; b=cMO1DaDpqrWSpuesAZ/rLkR+z0M2ZYNC7UckllKgcpdkgfYuzGdDXXrHvsrpjE0xMR pIhk/foxxzTNBxbaCZPrSs9n9N6XpshPivPH6mp29mYX29XvNTVqrfxsBYU4EoFVZYH3 oY1kB/84+o4U5JggQ/01VqPsq86GfkRnxACbQUEqTbHe9z3gOlubzJ3qlDlgSaW87JwP Bk4ZTM19hME+fwG1nqsLYJ95drzFhUrVEOZmrzx8vK6M/YopFe6ZxpkS67BNniRoSU8K T0qeQAIGCVXUN0EDiIcr49xVJEXUhjjyTkd7RZa15m++idmtflfmOEBUGvjkYW3/10gg Urlg== X-Forwarded-Encrypted: i=1; AFNElJ9xaqid7ptrv/7XUkZByCGOKQRTIB//6RfVpvxw2xml/8oJ3S9p5syWu3KZuik0ff1YYWSglw9xepulWVU=@vger.kernel.org X-Gm-Message-State: AOJu0YzDuyNi6AwYDyM/fStd+NL7ZqezyUeDA6Z1oOLmJntynmeZW1BH /VK3pAU2/6o9+2TwC5FHhoRBWu6pIcVMfgizV6bq6rAWUCZS4GYSMl8+vmsO2TW82Sk= X-Gm-Gg: Acq92OE4UpCcoaHEhJ7ViQ/dFrA3F2AZ6EsC5JNNWiIjOEJWhHnkBJNYtZAs6LdDpgZ Y0diQhPEgtd+e38/AOXtHtwEQeOxQgtb1vT1bmS2vxOxNONQZEhjVv9nkVXnUGgheXdN2+vbXn8 nQSGdVDYQGrXL+M338Nx1O8JU0cFrpxBslYXDEY6O2+v1NXY4qCteM1V5qq47n7Ceqb2ac5D9T4 kHIXaE+Wb0efiioFgRi7RTPe/+mNDmvIHLfnv2Rls2KkwTcYkxH6rarojEBAyPqv4i3ufIs21bZ w+gA2a3TY9u4WZObWF6qTU24o1mzM87/TWnx9H3dNLRItrQyut5EEKr3UbCpbW0HpXbfIh5ySq+ YZegNZOJj9g7Vcy/3d0Qo09MVpaareTZeksGGpNcY4U9BfmbzaBWkPj3q/A3sGSua7VuGaYZ3NC ekdadpLYLHr98eNZJ3IIhh6wgN1nr5uMBc5V+n48wEDAmvPQ+GE5xm5Q== X-Received: by 2002:a05:600c:859b:b0:490:4b89:535d with SMTP id 5b1f17b1804b1-490b5e96157mr35768765e9.1.1780481848349; Wed, 03 Jun 2026 03:17:28 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:27 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:10 +0100 Subject: [PATCH v3 06/19] perf test cs-etm: Replace unroll loop thread with deterministic decode test 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: <20260603-james-cs-context-tracking-fix-v3-6-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Testing a long sequence without branches seems like it would be better as a decoder unit test, and this test doesn't test decoding either, so it's not clear what bugs this is trying to catch. The new deterministic workload has somewhat long sequences when built unoptimized, and we can always increase them later if we want to. But now we test that decoding always gives the same result for the same sequence of code which we've never had before. Signed-off-by: James Clark --- tools/perf/tests/shell/coresight/deterministic.sh | 71 ++++++++++++++++++= ++++ .../tests/shell/coresight/unroll_loop_thread_10.sh | 22 ------- 2 files changed, 71 insertions(+), 22 deletions(-) diff --git a/tools/perf/tests/shell/coresight/deterministic.sh b/tools/perf= /tests/shell/coresight/deterministic.sh new file mode 100755 index 000000000000..52e033fd6b82 --- /dev/null +++ b/tools/perf/tests/shell/coresight/deterministic.sh @@ -0,0 +1,71 @@ +#!/bin/bash -e +# Coresight deterministic workload decode (exclusive) + +# SPDX-License-Identifier: GPL-2.0 + +# If Coresight is not available, skip the test +perf list pmu | grep -q cs_etm || exit 2 + +tmpdir=3D$(mktemp -d /tmp/__perf_test.coresight_deterministic.XXXXX) + +cleanup() { + rm -rf "${tmpdir}" + trap - EXIT TERM INT +} + +trap_cleanup() { + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +cf=3D"$tmpdir/ctl" +af=3D"$tmpdir/ack" +mkfifo "$cf" "$af" + +# Start disabled and use the control FIFO to only record the workload and = not +# startup. +perf record -o "$tmpdir/data" -e cs_etm//u -D -1 --control fifo:"$cf","$af= " -- \ + perf test --workload-ctl fifo:"$cf","$af" -w deterministic > /dev/null 2>= &1 + +perf script -i "$tmpdir/data" --itrace=3Di1i -F ip,srcline | \ + grep "deterministic.c" | uniq > "$tmpdir/script" 2>/dev/null + + +# Remove open brace lines as they may not be hit depending on the compiler +sed -i \ + -e '/deterministic.c:8$/d' \ + -e '/deterministic.c:15$/d' \ + -e '/deterministic.c:23$/d' \ + "$tmpdir/script" + +cat > "$tmpdir/expected" << EOF + deterministic.c:24 + deterministic.c:25 + deterministic.c:26 + deterministic.c:28 + deterministic.c:9 + deterministic.c:10 + deterministic.c:11 + deterministic.c:12 + deterministic.c:30 + deterministic.c:31 + deterministic.c:32 + deterministic.c:34 + deterministic.c:16 + deterministic.c:17 + deterministic.c:18 + deterministic.c:19 + deterministic.c:36 + deterministic.c:37 +EOF + +if ! diff -q "$tmpdir/script" "$tmpdir/expected"; then + echo "FAIL: line numbers don't match expected: " + head -n 100 "$tmpdir/script" + cleanup + exit 1 +fi + +cleanup +exit 0 diff --git a/tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh b/to= ols/perf/tests/shell/coresight/unroll_loop_thread_10.sh deleted file mode 100755 index cb3e97a0a89f..000000000000 --- a/tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -e -# CoreSight / Unroll Loop Thread 10 (exclusive) - -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 - -TEST=3D"unroll_loop_thread" - -# shellcheck source=3D../lib/coresight.sh -. "$(dirname $0)"/../lib/coresight.sh - -ARGS=3D"10" -DATV=3D"10" -# shellcheck disable=3DSC2153 -DATA=3D"$DATD/perf-$TEST-$DATV.data" - -perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS - -perf_dump_aux_verify "$DATA" 10 10 10 - -err=3D$? -exit $err --=20 2.34.1 From nobody Mon Jun 8 04:25:58 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 31C963AFAEB for ; Wed, 3 Jun 2026 10:17:31 +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=1780481859; cv=none; b=m493DSE7r7095BrhopNA4KnZeh78flZGNIk/4qsmr3XxUVqRyBrf1b+77yxaDS3bEiIPbNLkzj1PaADyO1cUTuaj/I5faURaG6MNpA0TC7GB1FVpcG6wo/ofyY74TQKfZvNKzmxkfV8LSAL/EOz6AcD7j3rzlB8pxDZ/aRWzS2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481859; c=relaxed/simple; bh=Bet7dcog4cI1OWFbkgHySPvLYRaBjOEAmnyguA5dwLY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HMMugGTsKx3hp272A6S8gTKNwPCImzc5Ms07L8M3gRAikRLuMR0d1r1hfTMqUZyaEdM4DRl14R7yJTxLRPQKm5MnI1NoGO9YroXVaDooR+91MYGW1nzc+uAa3B0yfruDWPrRP3wilbTFSeDEKXBP0T2c5+sLCuqXrDSuD+dBCpA= 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=OU9L44sN; 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="OU9L44sN" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-45eeba68948so4795719f8f.1 for ; Wed, 03 Jun 2026 03:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481849; x=1781086649; 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=8mOc2t8dZN0s1J71IBgMzN0QR+1naOVex0M+qvmJCq0=; b=OU9L44sNb0MQl6xNfYkLA2jUiWL7Ltbcbg0P6kv5ygVI8uOqIqlZG9MI1/eLhZgYLh 1sQd4bmjlGNwCBiyqK6tbtVdpIR+1XDMJivOqU0bjkr4q09bEJFrl+kSnJbhut1D+fWd LFXxFqJJo9rsChhsNIXgNs2QwGPG+h7I3bVIGSkkGg8S9SwYg0VZffhgvZVNMYcwC47Z pxdY4C99v6vn4hOhUCTKROVt4CclCqexvm3POh67O1Grrlc/YZxBTW/l0zDeevo3qKjF 7E66pGg4qD1dOLrJmFlXf7GDA5G0dRLOJ8rgsSc+nuWNzCuoXQyv1fM7VMK8912c38Xl 0qUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481849; x=1781086649; 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=8mOc2t8dZN0s1J71IBgMzN0QR+1naOVex0M+qvmJCq0=; b=A7SN/Gdm1yS0mWJ1a4HS/FHbe/A6AEuxURPFLm74baNL15XWCpdSz5Cuqfj+hkadHs AYJgD2Az7BcDRwgIk3RbDJMUMTW0V11mB+5X1pNK6J8IqcLUSu1R7g5eyt+wT2Wsm+wK KTBIR+HeKZBmjpu+228NVSN8fCaevUrIV/M4kImtQjgJepyxyzPMq3p+6xLzV66rcOE7 H3J7MQ2TvHgh3yLWi9bGIzhtZAdIcaqPu7bMl9fKCdoxvEY+sMJUKwKtK40W3qESD6Q2 IOWLDxsDB3puZjJcbarKJ+8nfKLEAwCIAsPBnTrnHp6rNrZPXOWcTI53hv3ewWDl+Fnq FEfg== X-Forwarded-Encrypted: i=1; AFNElJ8mivOZbARrCSH4+xpVJ1TMUwkLRhT47e3DwSr+ftsZJnI+ZSQA3WrwWvykV3fMzNik43SloSeJ7h+OlK8=@vger.kernel.org X-Gm-Message-State: AOJu0YxHdun2orCRga8u/Jxc2c2RWH1jsvM04HPLO3X+CqS8sUXUEwvy PHSmjdxqynoeKaROCWJTKDv4iv2fViBhvv1Wl288/P4lO9PtbpuIPnpvNO23AWJvmqg= X-Gm-Gg: Acq92OFZpEjI3tuJEA1uwL2Vi/hNJIPo5T2ycVEHGXGmLYLBsMSKn+HqX06L6W48SCW LSdciYzBuzDvUd1x3B6fGNP9Edg24+/jzu58BX+Id/7d2VWYyURPo/M2g7gb9WrBNUqiNgnUSAv kIR8hQVkE2BxvzzcYmV9daLw3FHRfBowGjjpJQuLIothSs8B/Ft4sT5/nmEFBuJT83QmMxfdSpg YB/wq30PVA6wiHXPi7LncoABGveO4dP1KnjeH7Ge1rDKR5Sb2imXWNFE4IaqVWAV1dWYm9+7yYU nsH8WDyybtSShAwRtjFoXwxhZwDKNi8VFjERKh0ClFdI3WP9LvZHcexaEMeMIxiHYDLw2waqMGX syj7JXvBNz24JCGX/uVuy0XUk2zc6VvO9TDC0A9zj0ASPa+KtQWUdSUiW88LJkpACu/1uK2J1GE WHGOAiwz2KoKrJyrTZvzGYtMoJ3qeSlcijvmgful8bDkk= X-Received: by 2002:a05:600c:154d:b0:490:adb6:793d with SMTP id 5b1f17b1804b1-490b5fda5b7mr44655035e9.26.1780481849590; Wed, 03 Jun 2026 03:17:29 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:28 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:11 +0100 Subject: [PATCH v3 07/19] perf test cs-etm: Remove asm_pure_loop test 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: <20260603-james-cs-context-tracking-fix-v3-7-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 It's not obvious what this test is for so remove it. It's not a stress test because it doesn't output lots of data and it's not a functional test because it only looks for raw trace output. It seems to imply that a program written in assembly influences whether trace would be generated by the CPU or not, but the CPU doesn't know what language the program is written in. We already have lots of Coresight tests that test the full pipeline including decoding, and in many more modes of operation than this one, so if no trace was collected they will already fail leaving this one redundant. Signed-off-by: James Clark --- tools/perf/tests/shell/coresight/asm_pure_loop.sh | 22 -------------------= --- 1 file changed, 22 deletions(-) diff --git a/tools/perf/tests/shell/coresight/asm_pure_loop.sh b/tools/perf= /tests/shell/coresight/asm_pure_loop.sh deleted file mode 100755 index 0301904b9637..000000000000 --- a/tools/perf/tests/shell/coresight/asm_pure_loop.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -e -# CoreSight / ASM Pure Loop (exclusive) - -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 - -TEST=3D"asm_pure_loop" - -# shellcheck source=3D../lib/coresight.sh -. "$(dirname $0)"/../lib/coresight.sh - -ARGS=3D"" -DATV=3D"out" -# shellcheck disable=3DSC2153 -DATA=3D"$DATD/perf-$TEST-$DATV.data" - -perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS - -perf_dump_aux_verify "$DATA" 10 10 10 - -err=3D$? -exit $err --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 55D0D44A701 for ; Wed, 3 Jun 2026 10:17:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481859; cv=none; b=VqymdHlEsDk+bDTTfopPY4rq3O3MF/hIgsZ78sHkdhMZEdms+e+PLZrx5nXX2auq8y9gDBlsuJ4ez1rCcEgKy1GXIro1e2PIbSovl85ay6BG6Kt5TyMNsIR81znd+/DTdCYK3NomTnCJj2ASALpxGrU8VGvh3CqGdwFtzeJRdvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481859; c=relaxed/simple; bh=AU+sY8Tp8BoY/5+w+fRDQW7PbvnqFbEYKQkcr4EdCQo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A9fzR8KA7QhqEHBItHYnbVslr5a2rOEncroiSpDiw/AqPGJkVeLZ5T46oGwfRl2HyF2sb8S0MEGW3cpa9g91Fc/a89dt+iAzoxhKlcdkyGW5kccXsoKiShrqjvNBKPfMIx7Q8WcLaVSRA6qAQhky3c10ETmiUXY9+gmLGRA1ep8= 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=OFn9BEw4; arc=none smtp.client-ip=209.85.128.41 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="OFn9BEw4" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4908b92904fso71966965e9.0 for ; Wed, 03 Jun 2026 03:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481851; x=1781086651; 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=+q+4Ed/TH/GWugEEpgBe8aXsgoIABynsgFsrNm9YETo=; b=OFn9BEw4HbeUrGBqquFQXvAXofh1eDoK3IzdPrBsa1Vxey2jj0XUhSO85tOQHDsES5 WlscMkdaMDJADj5KSEzT6Si5h0Pq9q1sIIQg3m+BmGZ6Y7rdFEETNJ3I/QoUS/ctPleO vZfGKTeW+jafpLb/t0FPQL7hZUIyX/iYt+zf71jp80yVxiLXKK3GWjBOK9Twnjk0PGyU QEt+3XgirZ6Ve0cy/vQ9YeBGE10Anb7nJUNEwNWC2ACj0VdOa34epBE8M9QS7jFXGT2+ MvbV70h7d8r1tCPV6Hb5mYQIK4xMV4biiuFMRDw1W20Xl5EeO95osUODFqZkDFf6mi03 EzEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481851; x=1781086651; 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=+q+4Ed/TH/GWugEEpgBe8aXsgoIABynsgFsrNm9YETo=; b=arDnwQnvLrSrc03thPm1yAhHmTAdIDeAScqmU7ZZmQ0vjtQsBTMk8+H92kOW+d7F/r QWfAuL4104xYLCruo9oz5QcQeauZZilam7KD1Muq6o6m1//WIml8V3AFDzsnje/5hYDV 3eAdt/N2aL0qhhsI3f2pEDsJBe2nlVQw6OdmHCT3SGIj/I89ZXzFXJYOCR+jwFtJr9MU pg32chuwaRjFSc+PS5G43Gl32YD+JBgstwmClSoQpsJ6qEip3IylPgs4WAVSx2vXPDRG aKZAuZr3anJMNAlU563wH+jrxbevTyoduF5X+57YifUFTyQrgdE9IKsDiZb1ZDntSv2B j2rA== X-Forwarded-Encrypted: i=1; AFNElJ/5pNQNKiujIeyP0uIJyCm3ZJmkAqNXE3IC8RusWMU1dtWyRoOXGgY6MxHVC9gQQX/g9huTNqc2r/7T+rw=@vger.kernel.org X-Gm-Message-State: AOJu0YwZGyl2aqlvJsuH0o+UzVE5lS2VDpF7wxUHqg+q6omeZGjQRrNs RdyPXrgw61z+1uRrh2kjPvAdUVJ9wGvvsMtmiFLn4+qksrVkoptK/e0yyQl3s9LBKds= X-Gm-Gg: Acq92OHAjBlcu2WVW1hhm9flCIbhxKoxlpSkHr4xdco9Eh+B8dAwCk//ChcoF7KE72A 0f8ibEtQo/j0Wk/fA/q+ZqDZf0MWjCLHrdaneCx10++PCFAc+93vR3INb4r7YRTi4WM4zb/nllX wq9zNaVU7J9qKsOLkYkPVHWhfE6NCqxYI0w3vEFvS9AFivJZQxKjWfnJz/ZIf9TkrtzUvy7qw1j hgiga8rNkAX1jjmRrw30yMvw3RGdaGDFuw1eLAN/qyJvcrW2f5vGH2KJFlwl88fwCiMmCjtycCx K9zUyMnEvYPEOMk7AYX7q7qkJ0MmuUIp85SWJc6TY/jeUOBu3d1NPtxCoGl3aciKXQnnSkOK09v joQAEkuP1yJ3ivdpni0nioovToB2Z9QBRrfSVAWGV4D0GXNv87Q7WR9JwFwYt5GrWGvVmli0Hko CVd5TMaORkVthFVnMwovZrQXp/1TDpI66nxyOGRTVE/Vo= X-Received: by 2002:a05:600c:5288:b0:490:9d1b:f06a with SMTP id 5b1f17b1804b1-490b5ecd8e2mr43354935e9.10.1780481850796; Wed, 03 Jun 2026 03:17:30 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:30 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:12 +0100 Subject: [PATCH v3 08/19] perf test cs-etm: Replace memcpy test with raw dump stress test 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: <20260603-james-cs-context-tracking-fix-v3-8-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Like asm_pure_loop, this memcpy test only checks that 10 of each of a few trace packet types occur after recording a lot of trace, which isn't more specific than other existing Coresight tests. Assume it was supposed to be a stress test for dumping and replace it with one that doesn't require a custom binary and checks for a specific amount of raw output. Don't bother checking for packets because the other tests that test decoding will catch issues with malformed data. This also adds coverage for exit snapshot mode which was missing. Signed-off-by: James Clark --- .../tests/shell/coresight/memcpy_thread_16k_10.sh | 22 ---------- .../perf/tests/shell/coresight/raw_dump_stress.sh | 48 ++++++++++++++++++= ++++ 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh b/too= ls/perf/tests/shell/coresight/memcpy_thread_16k_10.sh deleted file mode 100755 index 1f765d69acc3..000000000000 --- a/tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -e -# CoreSight / Memcpy 16k 10 Threads (exclusive) - -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 - -TEST=3D"memcpy_thread" - -# shellcheck source=3D../lib/coresight.sh -. "$(dirname $0)"/../lib/coresight.sh - -ARGS=3D"16 10 1" -DATV=3D"16k_10" -# shellcheck disable=3DSC2153 -DATA=3D"$DATD/perf-$TEST-$DATV.data" - -perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS - -perf_dump_aux_verify "$DATA" 10 10 10 - -err=3D$? -exit $err diff --git a/tools/perf/tests/shell/coresight/raw_dump_stress.sh b/tools/pe= rf/tests/shell/coresight/raw_dump_stress.sh new file mode 100755 index 000000000000..025584472513 --- /dev/null +++ b/tools/perf/tests/shell/coresight/raw_dump_stress.sh @@ -0,0 +1,48 @@ +#!/bin/bash -e +# Coresight raw dump stress (exclusive) + +# SPDX-License-Identifier: GPL-2.0 + +if [ "$(id -u)" !=3D 0 ]; then + # Requires root for larger buffer size + echo "[Skip] No root permission" + exit 2 +fi + +# If Coresight is not available, skip the test +perf list pmu | grep -q cs_etm || exit 2 + +tmpdir=3D$(mktemp -d /tmp/__perf_test.coresight_raw_dump_stress.XXXXX) + +cleanup() { + rm -r "${tmpdir}" + trap - EXIT TERM INT +} + +trap_cleanup() { + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +# Use exit snapshot to record 2M of trace to make about 80MB of raw dump d= ata. +echo "Recording..." +perf record -e cs_etm/timestamp=3D0/u -m,2M -Se -o "$tmpdir/data" -- \ + perf test -w brstack 20000 > /dev/null 2>&1 + +# Test raw dump runs to completion but don't decode because that's too slo= w for +# a test +echo "Dumping raw trace..." +perf report --dump-raw-trace -i "$tmpdir/data" 2>/dev/null > "$tmpdir/rawd= ump" +err=3D$? + +size=3D$(stat -c%s "$tmpdir/rawdump") +if [ $size -gt $((50 * 1024 * 1024)) ]; then + echo "PASS: Raw dump file is larger than 50MB" + cleanup + exit 0 +fi + +echo "FAIL: Got less than 50MB (${size} bytes)" +cleanup +exit 1 --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 8CD8F44E02A for ; Wed, 3 Jun 2026 10:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481860; cv=none; b=LeIf3605PNOzs+pVfqgMIg1JjXBXaqbDLQ7t/PUOYwKOXxm9kG+N5FC33a8GzU7tWnomXlmgvZiHjbdsjNg7fcUn+ejuOKr5otlGH0ajXqb/N9sNXonRPebCavaJqy05mauJinhwRT8xcx1N80/o20vzqpDODMGQmPjZQqvsoP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481860; c=relaxed/simple; bh=f7nYZOjqRymoF8HLdou2qxt3lFfZBlP2peDzjQpRTcU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DSY40eXt4EM2dZQhOZ3me6ssARv/qUgoftp+XjvTwMH4kwpBPgkinxXBhCQEjP1mtgEDViYDTAlBjR4z0I43eHDOl4WTh+pYjOjqro6lAaxX5Cj77UWaVVihpN0Z+jDvIqv9khrjema02lJXLyu4JWU0RlqbY3uS8WTswhkv8l4= 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=QEnahXil; arc=none smtp.client-ip=209.85.128.44 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="QEnahXil" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-490b613a17bso7354135e9.3 for ; Wed, 03 Jun 2026 03:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481852; x=1781086652; 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=mfmfQz4GZFVkBiOlSPmMGw2k+07TI77rK2unIhsiSv4=; b=QEnahXilFEZNlerG7QjRhF6wmmc29cowLUHh9dP0zFnenw746LHgktPY1LmIXbdLnm mz+LwJX/hQ8dSuGGjyJpmk31XyVwgdcDmxm9kn/VH3guKZ1yAfxG+o+3IclHaIfKpkaV bAHzx2SmtsJqez4axkXoo6QNQpEYtSSPUCODg8q+nkEW7mW+8hUlBVMKZkrqIqsTyhoF SSuWcAgzcjrUO3ujpvqgxtYptz1BsEBha8mYZKPSjcC244bkgfupgywiRhAbvXVjCICq VlXG7DgxxWSnSHXmI+LIXbgLVr4L1QJHd1OjDuZP1Pn3P4TVr2k+kfAHUjJSXCGO9akT Y0OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481852; x=1781086652; 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=mfmfQz4GZFVkBiOlSPmMGw2k+07TI77rK2unIhsiSv4=; b=LFruFp78GhYhBC5ITDVLYHJtAgwcQ94i4UG8pFWH+NgCjQeF4RTQBH4Pmb2Ygwk4+K jd2Vb+BoS288rQ9DQZKR/2S9cDXoGzLECUE9S9JA844bYvHPzIzWm59n25gUxunfKOzm 2MGvg1dNgBq+Sagz/38YZjtHur3jm9gwpy85nCaB9jF78OTq7BOgAGUpPcMOHuAkVUkt Up+88rJYuR821jzuvPctn6Lbr7pU9vgzLKv8V4FcGaNd4+sx07uaJ0m7IV6NbEe/g+9s kB/+HJ1wSMTTY2d5Ms6xMzmx7YOTa1Sv1P7d5asPSNZv4UmrsMe7vFK/Ks6B2Z/wNuMP 8c0g== X-Forwarded-Encrypted: i=1; AFNElJ/kwj173Kwg+b804Wnd50qGsnjLoScgptZc7Vb4i0Io+MwOOxo58HoqIscN7NHC0CtZxXiYZBJQZowfvn4=@vger.kernel.org X-Gm-Message-State: AOJu0YztScuZ8AEON9rgPr58zu6634GAOxH23+Nvq28n7jeaPMhSvsmw TQjx80HzQDf4KMRrgtemhzFHG5wHIJL2XYqaOwxnNMl4hmeGebemS1GEqEu4HU+bCUI= X-Gm-Gg: Acq92OE2Sueae31GQ10h0oSXjQMYCI2K6mvAW4p4zIgJwSVsG/MmK3765Y+lHcg/mPZ 1ch2m3bpObq94yI4HDxrusG1c0wRnIhVXuZhOfv9MATY2VbKbn2TwIxDc+3BmMyGGveVVnerg6s 0ot5gcqUXGjMekw40hwX9J060rk8k8wKfJRRfSL1aVYZYI4S0u7osVAou0Nz6UyoTSR8mxHaTWk 49dwKYurk9X0P2axzpjzg6PjkUUsFEXNExlAuKE2ZSjZB+K8lB9CmhKVQ6EfEOOYVDAaxDY3oeP t3prNOyOzmRgqgMuJCktzz9qyWiBkGQ/MpsKf9QHZfW21bI+ilb3vDf501b4by6Q+qM92FlYgxO a8rxH8UL9Ke5ieNknVSJW7L4COv3ef9FjGxCDyyH9PpxfQlzMpI5flvTeK11FXiULy5yPxzbdWs CKGwus36nU7n+Xdq5DxVYi79GrKu8bwPG6pWjT9nx4rxs= X-Received: by 2002:a05:600c:630f:b0:490:b025:f324 with SMTP id 5b1f17b1804b1-490b60e41a8mr46919575e9.32.1780481851759; Wed, 03 Jun 2026 03:17:31 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:31 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:13 +0100 Subject: [PATCH v3 09/19] perf test: Add named_threads workload 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: <20260603-james-cs-context-tracking-fix-v3-9-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Add a workload that runs X threads that run a unique function named "named_threads_thread[x]" which performs a multiplication in a loop for Y loops. Each thread sets its name to "thread[x]". This can be used to test that processor trace decoding handles concurrent threads correctly and the correct symbols and thread names are assigned to samples. Signed-off-by: James Clark --- tools/perf/Documentation/perf-test.txt | 5 +- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 1 + tools/perf/tests/workloads/named_threads.c | 109 +++++++++++++++++++++++++= ++++ 5 files changed, 116 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentat= ion/perf-test.txt index 7ec70c054cac..778c37f6efdb 100644 --- a/tools/perf/Documentation/perf-test.txt +++ b/tools/perf/Documentation/perf-test.txt @@ -57,7 +57,7 @@ OPTIONS --workload=3D:: Run a built-in workload, to list them use '--list-workloads', current ones include: noploop, thloop, leafloop, sqrtloop, brstack, datasym, - context_switch_loop, deterministic and landlock. + context_switch_loop, deterministic, named_threads and landlock. =20 Used with the shell script regression tests. =20 @@ -66,6 +66,9 @@ OPTIONS seconds: leafloop, noploop, sqrtloop, thloop nrloops: brstack, context_switch_loop =20 + 'named_threads' accepts the number of threads and the number of loops to + do in each thread. + The datasym, landlock and deterministic workloads don't accept any. =20 --list-workloads:: diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 5a2ab67cd85d..2fee93858c86 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -149,6 +149,7 @@ static struct test_suite *generic_tests[] =3D { static struct test_workload *workloads[] =3D { &workload__noploop, &workload__thloop, + &workload__named_threads, &workload__leafloop, &workload__sqrtloop, &workload__brstack, diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index f8bba2d68769..ef3c3a269132 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -235,6 +235,7 @@ struct test_workload workload__##work =3D { \ /* The list of test workloads */ DECLARE_WORKLOAD(noploop); DECLARE_WORKLOAD(thloop); +DECLARE_WORKLOAD(named_threads); DECLARE_WORKLOAD(leafloop); DECLARE_WORKLOAD(sqrtloop); DECLARE_WORKLOAD(brstack); diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/= Build index cca7ad354227..7db5eea713a3 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -2,6 +2,7 @@ =20 perf-test-y +=3D noploop.o perf-test-y +=3D thloop.o +perf-test-y +=3D named_threads.o perf-test-y +=3D leafloop.o perf-test-y +=3D sqrtloop.o perf-test-y +=3D brstack.o diff --git a/tools/perf/tests/workloads/named_threads.c b/tools/perf/tests/= workloads/named_threads.c new file mode 100644 index 000000000000..dc8070a98df4 --- /dev/null +++ b/tools/perf/tests/workloads/named_threads.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include +#include "../tests.h" + +#define MAX_THREADS 25 + +static int iterations =3D 500; +int named_threads_work =3D 1234; + +typedef void *(*thread_fn_t)(void *); + +#define DEFINE_THREAD(n) \ +noinline void *named_threads_thread##n(void *arg __maybe_unused) \ +{ \ + pthread_setname_np(pthread_self(), "thread" #n); \ + for (int i =3D 0; i < iterations; i++) \ + named_threads_work *=3D 3; \ + \ + return NULL; \ +} + +#define THREAD_LIST(macro) \ + macro(1) \ + macro(2) \ + macro(3) \ + macro(4) \ + macro(5) \ + macro(6) \ + macro(7) \ + macro(8) \ + macro(9) \ + macro(10) \ + macro(11) \ + macro(12) \ + macro(13) \ + macro(14) \ + macro(15) \ + macro(16) \ + macro(17) \ + macro(18) \ + macro(19) \ + macro(20) \ + macro(21) \ + macro(22) \ + macro(23) \ + macro(24) \ + macro(25) + +#define DECLARE_THREAD(n) void *named_threads_thread##n(void *arg); + +THREAD_LIST(DECLARE_THREAD) +THREAD_LIST(DEFINE_THREAD) + +#define THREAD_ENTRY(n) named_threads_thread##n, + +static thread_fn_t thread_fns[MAX_THREADS] =3D { + THREAD_LIST(THREAD_ENTRY) +}; + +/* + * Creates argv[0] threads that run a unique function named "thread[x]" wh= ich performs + * a multiplication in a loop for argv[1] loops. + */ +static int named_threads(int argc, const char **argv) +{ + pthread_t threads[MAX_THREADS]; + int nr_threads =3D 1; + int err =3D 0; + + if (argc > 0) + nr_threads =3D atoi(argv[0]); + + if (nr_threads <=3D 0 || nr_threads > MAX_THREADS) { + fprintf(stderr, "Error: num threads must be 1 - %d\n", MAX_THREADS); + return 1; + } + + if (argc > 1) + iterations =3D atoi(argv[1]); + + if (iterations < 0) { + fprintf(stderr, "Error: iterations must be non-negative\n"); + return 1; + } + + for (int i =3D 0; i < nr_threads; i++) { + int ret; + + ret =3D pthread_create(&threads[i], NULL, thread_fns[i], NULL); + if (ret) { + fprintf(stderr, "Error: failed to create thread%d: %s\n", + i + 1, strerror(ret)); + return 1; + } + } + + for (int i =3D 0; i < nr_threads; i++) + pthread_join(threads[i], NULL); + + return err; +} + +DEFINE_WORKLOAD(named_threads); --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 8D93144E043 for ; Wed, 3 Jun 2026 10:17:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481860; cv=none; b=cq+Wve+ASZjz9pRFYC+uBmubndgcvi6BT1hakfBhpMY/e2KI1PcxGy4ba43EO97LvG625TxeAiFloS7hjYhpKpfz56L9UpqyXW74vfLJtBppPHc5lHy3MrRjgz+8jZRTM8ZaW0GTbdWp/l5u5TKQop5+vVGqtkoLoyrco40RDX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481860; c=relaxed/simple; bh=+NVyoMoDiCeBbRcKsQIV0kaH0gzBxCHgeoMNyjllUrQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BTjgJ1DLUeGjx/VrFK1A+I7aO/L9krbTM4SVUlxrZuaMSRWP8BmzkduMZncLFPGU1gSwW58Ww45tUe9v1q37ElK3LRJGkwd7KcBCxnHhLt3ZTmprhfac3iP7E7v/3SYRPM9BD9pOsyH83KC106lSBi3+Di/kv/SaAMjdJrygFYY= 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=rKg0UATc; arc=none smtp.client-ip=209.85.128.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="rKg0UATc" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-490a765d410so39588865e9.1 for ; Wed, 03 Jun 2026 03:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481853; x=1781086653; 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=lBRnQlPosMN+k8SaoyM/0M+4oXOyWiGOMBDGTHkddk8=; b=rKg0UATcJ2Ntr8NWJiKo+qT1nE1mGGhEzHdTsNoelyMwxdoPtxQE5qb0LMeRLb+Esr 1UGiCRWbzTRlvz4IFVBA+Gx6gPl8Q3AOREsjjNPR2OU05XwMGloFQV89McPVH2R+KCXJ nABv0SMICEGo6aTnfz1CAhQCvHjp6UQbn3CKyjxgyBo2lNEcvqJLkZYlrarkur0W0+5Y /0TkQ30PiZebzDgj22ezy4J9in7OdCmlEIlI9rVWeWIDloy4y7sbYjqfHR7WUFiwz31V JCLVFSY16yLCDSTLqDaF4fxVw9u6+ZT6oL9T+gLTKDmwTGt7tqNZG/0rv+LL/9E/VMvX 439w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481853; x=1781086653; 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=lBRnQlPosMN+k8SaoyM/0M+4oXOyWiGOMBDGTHkddk8=; b=ECbaas6r5xyQPu44d2mWUXbKbZzl7ucwSqGKEMEq1uimnFXSQ60RAkBXQNI5Oq+aoy oLCLbowS4XmjF0oikndCwXl0Mt+6vuKW487s1+ErZfU1XEiZKbNQSrJ2DcbsIMVhF0sy oFNZabBXtZLEoQ3j+Yje0UALQ6aolEUvlpZrK2dFJPPMpyVq7bbXMNqht9D4rNjk8eIj XJb1kJDBlkRglL/dRYCIGoHDuE3DG00gWIXk6wZmUyX6GiTOGibFl5Nh9OtI8fXgxMj3 7a0QyH608Gb1upMtt8Uyppvyiebc8xb4MiKtFObZ9RT3GyR9SDMbkAmj97NDYbkovbj/ 6MBw== X-Forwarded-Encrypted: i=1; AFNElJ8xyjSx4IlaeNEy07EqIs//wNSAQM8g5FyYr96WrtpzeNWDG+m9cwlOpRch5u7DfYhtAKxndojHju1+lWU=@vger.kernel.org X-Gm-Message-State: AOJu0YwYU0EszhO7UOg9JWmDKvitzpI8UTWWz7hnQ1d+iwxOyqK9oq+Q owd9wDQ0Ues5szydN4DHwllzjYm0TSKbVN9BzCGv1sYB3aDmz6XTrwjNV59Tcra+LOo= X-Gm-Gg: Acq92OHvJFw8jAbUe+PaPl4RwPomg24UmiuNjODlYeITMyWyOKrDKso+pyVH7RlWuhl pzNW2100fzcH22UlFImrctnk0QZrGl3ybJneG19wGll4Si+XoVjlSGoGfOZFn8RzXBQpCbflqRR DfpbLnnIzykA7unh9491TBaKW+8rveE1HmhrgFS3x4tfNFwhFGbfCyQ7EEDj+SzPTEHuJa/I/L8 8BAQU8zGjPd/qoGkv23gVLg4lWRPFiRR1qVkTowM30M0py98Mvk7IGHNCqW0xCdtfhGnTsihy+0 reMBXUo5wgxYB77mFxx8mf/bMdwne1hZm/aUxgcwLHpsKqNDbTIkR9zrCy+hj5OAvWx27cBEAwi bPrKjJZkw5jqZaxxX/hBU7P8fOHgDciYnXb6GYzINXPEafV3SZQ15J3m1yZfZf6kiNG/yKHngz8 3SAgGxPgy0sIfcuKQVV1QC5lxa9zr4Cn9UD7IF4GirOF8= X-Received: by 2002:a05:600c:3f18:b0:490:b2f2:9aac with SMTP id 5b1f17b1804b1-490b5d1a9b7mr57327915e9.0.1780481852836; Wed, 03 Jun 2026 03:17:32 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:32 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:14 +0100 Subject: [PATCH v3 10/19] perf test cs-etm: Test decoding for concurrent threads test 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: <20260603-james-cs-context-tracking-fix-v3-10-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 The thread_loop test only looks for context IDs in the raw trace. There's a lot more that can go wrong when decoding these, so replace it with a test that looks at the final output for matching thread names and symbols. In the future we might use timestamps and context switch events to track threads, so looking at context IDs in the raw trace wouldn't always work. Signed-off-by: James Clark --- .../tests/shell/coresight/concurrent_threads.sh | 45 ++++++++++++++++++= ++++ .../shell/coresight/thread_loop_check_tid_10.sh | 23 ----------- .../shell/coresight/thread_loop_check_tid_2.sh | 23 ----------- 3 files changed, 45 insertions(+), 46 deletions(-) diff --git a/tools/perf/tests/shell/coresight/concurrent_threads.sh b/tools= /perf/tests/shell/coresight/concurrent_threads.sh new file mode 100755 index 000000000000..bf34d4ee77a6 --- /dev/null +++ b/tools/perf/tests/shell/coresight/concurrent_threads.sh @@ -0,0 +1,45 @@ +#!/bin/bash -e +# Coresight concurrent threads (exclusive) + +# SPDX-License-Identifier: GPL-2.0 + +# If Coresight is not available, skip the test +perf list pmu | grep -q cs_etm || exit 2 + +tmpdir=3D$(mktemp -d /tmp/__perf_test.coresight_concurrent_threads.XXXXX) + +cleanup() { + rm -rf "${tmpdir}" + trap - EXIT TERM INT +} + +trap_cleanup() { + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +cf=3D"$tmpdir/ctl" +af=3D"$tmpdir/ack" +mkfifo "$cf" "$af" + +nthreads=3D10 + +# Timestamps off to reduce trace size, start disabled and use the control = FIFO +# to only record the workload and not startup. +perf record -o "$tmpdir/data" -e cs_etm/timestamp=3D0/u -D -1 --control fi= fo:"$cf","$af" \ + -- perf test --workload-ctl fifo:"$cf","$af" -w named_threads $nthreads 1= > /dev/null 2>&1 + +perf script -i "$tmpdir/data" > "$tmpdir/script" 2>/dev/null + +# Check all threads were traced and they have the correct thread name and = symbol +for i in $(seq 1 $nthreads); do + if ! grep -q "thread${i} .* named_threads_thread${i}" "$tmpdir/script"; t= hen + echo "Error: thread${i} missing" >&2 + cleanup + exit 1 + fi +done + +cleanup +exit 0 diff --git a/tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh b= /tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh deleted file mode 100755 index 7f43a93a2ac2..000000000000 --- a/tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -e -# CoreSight / Thread Loop 10 Threads - Check TID (exclusive) - -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 - -TEST=3D"thread_loop" - -# shellcheck source=3D../lib/coresight.sh -. "$(dirname $0)"/../lib/coresight.sh - -ARGS=3D"10 1" -DATV=3D"check-tid-10th" -# shellcheck disable=3DSC2153 -DATA=3D"$DATD/perf-$TEST-$DATV.data" -STDO=3D"$DATD/perf-$TEST-$DATV.stdout" - -SHOW_TID=3D1 perf record -s $PERFRECOPT -o "$DATA" "$BIN" $ARGS > $STDO - -perf_dump_aux_tid_verify "$DATA" "$STDO" - -err=3D$? -exit $err diff --git a/tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh b/= tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh deleted file mode 100755 index a94d2079ed06..000000000000 --- a/tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -e -# CoreSight / Thread Loop 2 Threads - Check TID (exclusive) - -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 - -TEST=3D"thread_loop" - -# shellcheck source=3D../lib/coresight.sh -. "$(dirname $0)"/../lib/coresight.sh - -ARGS=3D"2 20" -DATV=3D"check-tid-2th" -# shellcheck disable=3DSC2153 -DATA=3D"$DATD/perf-$TEST-$DATV.data" -STDO=3D"$DATD/perf-$TEST-$DATV.stdout" - -SHOW_TID=3D1 perf record -s $PERFRECOPT -o "$DATA" "$BIN" $ARGS > $STDO - -perf_dump_aux_tid_verify "$DATA" "$STDO" - -err=3D$? -exit $err --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 8D35637B41E for ; Wed, 3 Jun 2026 10:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481861; cv=none; b=tx8XrEEb9sEUwQlkxrf4P4F8n50Yk5PhiNUXlRoT9owicW6TT+dUB7S6Hm8co2f3F0leC2PUheSD9KHkGGaXZUSoIVuHesj581oVpFBif9wCG8TsQKbFXXUY9AN1DCL0wxc3Hzyl0BhwXruvsfarQ4+NWG6pTDgAedU/j0y1nEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481861; c=relaxed/simple; bh=6RkEL4S8aCNR1yq1ytIaKt2GAbArNadH93U51mYQEOc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b6ajl1GrC9W4Lc0kU+h+2TsbP9ytn0rj3PYQSH+9doxebZ4+mCizQvWrvuJ7EcBxd2MKbBOHx38I1hfB8o9rrTzNqxvdrFVk7hdlJT4QV8oMNq6fnHjC3OdddK8NRPi7JHqv2Cds9f9YxUudiL938qA9VAjM2LKG/SDz+5OO2XU= 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=fKL6dXBe; arc=none smtp.client-ip=209.85.128.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="fKL6dXBe" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49068493267so73841865e9.1 for ; Wed, 03 Jun 2026 03:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481854; x=1781086654; 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=mRJuOllU43noyyBid/foFoLzbBafPMlwyDVK+1tfH00=; b=fKL6dXBeb0QOPV84Xr4/c/qzcTEMV7MGGE2wWkZM/PeIHTfqOI0k+TG/00cach6DTK pvIU2YNTePCbNe/iFCRiQw7oNOnvjgqB0uBpYWt1AOpxaPRs+db/Meg/att3FFiL7Dhn LUsHHXzC70N00HbLVDnsoxpb5TDgPR2lFMmA0QTzBvau4+Aq8P3R+IBHLPUkXTWWEIsE 2SdWvecbPySa77O94Tky0qtDeLs7XMLRIAzEh3AyVBkq8myilM3kbuBXqjT9g7fotAg3 LTEmDMGVfRe3EFLl2QmblgwakKHhPR7kC8b7cBe4saYKKv3Yj83aiW1lfRloNl8p/wUI C9hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481854; x=1781086654; 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=mRJuOllU43noyyBid/foFoLzbBafPMlwyDVK+1tfH00=; b=aWZpDZZSPz+k9qnv8dLjkapJNm1K2pOvbGygMBlrxV+lhq8LcIReCV+Ip0FyLxfArN Ovm3LE2rHGJRtLCzJ7DBlvURH+03xyPBuK8gnsn6WTlb223aVMAp5eQ+RZb6C5j5PuL1 L6jrJHt+xM5hjYwRfgNPslSLGjTiGNtcxBD8IO6I1yB3lLGaK4j3ZqnLQ4OYwAuSM4U9 viWf4DsOQJQSMrSOoLGtkCh2UF1B1LXbogj9t3B1AH7McKPUo/zRC3jcbxp2LgcpMFWl hl2VKE9+OosAsZyR13wq+MoXlwA1hn8cE53xlBecKhk2Kue+CHYIGvW1/+h61Hon/3Vn COvg== X-Forwarded-Encrypted: i=1; AFNElJ8fHh9JgKjvc3n6AKP81Qv+fieKyS4017iF7PXMWV30ZpdZuDYDhZrjHzOP70njXikWQ+pqvJLD9POyOC4=@vger.kernel.org X-Gm-Message-State: AOJu0YyeiVYK7UgzFx2ZTEulSL8su5AXGVLDQjsWLnsXqDoI9p8QfxRC 7natQIsRx71ZGHMkNuuNr1uBC9Z1QZn/F8g0cv7k4hgJJx4LIbYkBgg6G/bnReS/3bg= X-Gm-Gg: Acq92OEjtQMl/pYpGmtY5YsXx/jcwxyy5DFusfOAD2txTVoRS1c5HBAnvVoHuZG8JY3 mZZbiJwsgcOV67waXU1TX0YX3NT1CRL0XsteEnElRg850Inyph6doseZbsUdlsV0tAi96G3fLa2 VIgBjolILdkEpCYFhVWIf3GiZ4e+O9Yuq/tYxzZOVwX48G/ONfX73RmIFhrp/tqbXZfQaqMpgun baud7tocETZThoayfOfleUUfvv3sq+T7JSPqfEWk/702WsNW9ayHLU5vgj9gxUWMgAEmixy0Qu7 PXCWiWw1tKGgNrjU7hF/f86/TMSHN6FUXZM2DUfmH1NOPTEgozjo/rOa+jkA1bKW18xZXRQaw7Y w2m9i7t5asThwLbK0SfStNkhpMxYCKeCFE2a/dqdQkP6PEa8W+Iyw1ghI4qb/VSD+L54lgydn1j J9I5wrxs3xTK9E16BudKBPzhrRmOwFWBh1/A+nwdlsmak= X-Received: by 2002:a05:600c:1392:b0:490:a964:14f8 with SMTP id 5b1f17b1804b1-490b5e94f3cmr42451065e9.8.1780481853968; Wed, 03 Jun 2026 03:17:33 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:33 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:15 +0100 Subject: [PATCH v3 11/19] perf test cs-etm: Remove duplicate branch tests 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: <20260603-james-cs-context-tracking-fix-v3-11-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 We already test branch output in perf script mode, but then retest it in Perf report mode. This is more of a test of Perf itself than Coresight because Perf uses the same samples to generate both outputs. Also we're already testing instruction output in Perf report mode. Remove this test for a speedup. On the systemwide test also remove the Perf report test because systemwide mode records a lot more data so running multiple tests on it has a big runtime impact. Signed-off-by: James Clark --- tools/perf/tests/shell/test_arm_coresight.sh | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/test= s/shell/test_arm_coresight.sh index bbf89e944e7b..39553702c1f3 100755 --- a/tools/perf/tests/shell/test_arm_coresight.sh +++ b/tools/perf/tests/shell/test_arm_coresight.sh @@ -52,17 +52,6 @@ perf_script_branch_samples() { grep -E " +$1 +[0-9]+ .* +branches:(.*:)? +" > /dev/null 2>&1 } =20 -perf_report_branch_samples() { - echo "Looking at perf.data file for reporting branch samples:" - - # Below is an example of the branch samples reporting: - # 73.04% 73.04% touch libc-2.27.so [.] _dl_addr - # 7.71% 7.71% touch libc-2.27.so [.] getenv - # 2.59% 2.59% touch ld-2.27.so [.] strcmp - perf report --stdio -i ${perfdata} 2>&1 | \ - grep -E " +[0-9]+\.[0-9]+% +[0-9]+\.[0-9]+% +$1 " > /dev/null 2>&1 -} - perf_report_instruction_samples() { echo "Looking at perf.data file for instruction samples:" =20 @@ -123,7 +112,6 @@ arm_cs_iterate_devices() { =20 record_touch_file $device_name $2 && perf_script_branch_samples touch && - perf_report_branch_samples touch && perf_report_instruction_samples touch =20 err=3D$? @@ -154,9 +142,7 @@ arm_cs_etm_system_wide_test() { =20 # System-wide mode should include perf samples so test for that # instead of ls - perf_script_branch_samples perf && - perf_report_branch_samples perf && - perf_report_instruction_samples perf + perf_script_branch_samples perf =20 err=3D$? arm_cs_report "CoreSight system wide testing" $err @@ -179,7 +165,6 @@ arm_cs_etm_snapshot_test() { wait $PERFPID =20 perf_script_branch_samples dd && - perf_report_branch_samples dd && perf_report_instruction_samples dd =20 err=3D$? @@ -191,7 +176,6 @@ arm_cs_etm_basic_test() { perf record -o ${perfdata} "$@" -m,8M -- ls > /dev/null 2>&1 =20 perf_script_branch_samples ls && - perf_report_branch_samples ls && perf_report_instruction_samples ls =20 err=3D$? --=20 2.34.1 From nobody Mon Jun 8 04:25:58 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 7B5093264D2 for ; Wed, 3 Jun 2026 10:17:36 +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=1780481862; cv=none; b=O9Da5V4me3bi1rbTLAk1WxhQbk+K18tGpOMpyOOp54y6mmKL1SbPOhmA5aONC9fUgeaDiPDZmER0dDW9WehtJu6yZ5Zjbbf8IYio6yN5TXirqkDz/znYC3vd+MFnbOcIYHMfAH6nUG4rQXgejlDu7/35v8o3ZKrbjeALDBbqnBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481862; c=relaxed/simple; bh=T/G2GHn/7fUMe7/PnmdOHhquh1KwWwdOujJXllzzUEA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SDxrkFO1ZEw7+iAVpBFI5HXujQfdzE6cBU6mNR5GFnAq2kSU7KC2fBNGepJV4y8cR2QBEdr9kKAmBpqjnQzRROnJ0OZvGFyO42pSc9QlRzoCZTNeziIFGAFP4XBLBfFlJzOOyjeIY4Ydh3YQylNj9r4EUIY7c3jSuFPe9ayX8h0= 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=OcZLfZdW; 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="OcZLfZdW" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-45f3cf907ceso2030166f8f.2 for ; Wed, 03 Jun 2026 03:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481855; x=1781086655; 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=CWgAW+orRpeoFszPA6ybNAPpRullqPhLMJ72GoaGas4=; b=OcZLfZdW3Dkmb4vic1r5a18+QzSWtcl9J9p8eSinsktFZivX2elXBDwUyatrz+eQxD mBwalMpNowGsOTK6jHNDDVkrre42fK4vXHFhoWouuTY5vsl68jbP1J5N3fWm/dKE+YJm aEs7Z3zCbgZayxVCM2TlNNw69qAvJe/ywLqq4f7+z8bj9qxINFQnbIVzUEjMlr2yDk0X GfyeU6aXXENjpatNF+R+CagHCM8DZIqSm2K+UlQg5+C5iCBmkxTokrDXOf1Bvba3vTCF O1YLEt5+RvqkR+srxyOSHGb8LNpBDaVDXJc9HMPCkgN4roeDWV9PEas+GIV8yDQt56XC DuUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481855; x=1781086655; 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=CWgAW+orRpeoFszPA6ybNAPpRullqPhLMJ72GoaGas4=; b=R7t+LB/fuK8oGWTdr6jXnZHYNxSfSSuH1NkaZ6wb+7JeGyew9azWE8aIzJ8iFtmn+U HgZAeaIwV1RJcBKvev0RUSAN8F/rIQa1rimDnigS7gwzN2btFL8GySCV9Gw09RVWPp5R +Qdy+FI+APUbYwjQwXJmsAGxpWbQU0l84kwMNwXkLWsm+W5+f/U4ecGeueLy8J8W4AYe Cg1UActlUpcDHZF8mPDIWM3wVV6pn73V2gTP1Q/mls1o762OFpPfkTkCRIGsFGTFwyJQ L1EG2EaXVIkWzlD2jGQz0m4bpWls1Lxm3S/mPn2c3QvcTUIy9gdwCAvY+EasWbBXXooB hTww== X-Forwarded-Encrypted: i=1; AFNElJ8fJBSLpvbPXIthm1TaiNrD7AYcEHD7fPkeCBrbGO7jVKIUxaUiPcIBy8IzKjHvgiRS/SegBkfjlNi33uc=@vger.kernel.org X-Gm-Message-State: AOJu0YwvX8gbmqtGvOd+UayPFITVsu8U3xBYH8meH0jOIW3ZSwhTTjKm YRmVRlAv69dEtGVdfZ2GRMM9Uge/aGh7Ao7Z0gHrlEvr4IxX+bOKGdqq1Vb0rr1biJM= X-Gm-Gg: Acq92OHG6XvUkK87FDYecy/CxFEQq+BzJNV7JdFZFtdW0+rT87+/C1rXF2QBfNsgdUL ukyt6imPwT6u+BtHonuhbOp2+x+GF4ka+OdgCEyqmkxWCsaO2TUTAZ7gPck6JNvvTODjWvxTD1K c46lhuIf7TsUp+DfJxUVeqaiQ0jpTjUOW8fUgeJQDjbtCB4TPopJUNfz0pXT19E78+suNg7GITS uWI8JAor8mXmmYpYwXgg3IXrjt+6E8Y+4Yn0kzTs82Um6fKGHhh3S6BRMDBA57geUkce2qZTnHK UaHsmZ3lh2HKyWc7IVlIFdXdsCoEAljjHpT86oP3iR1I3K3SMpxVgk2LXbgDx+LE4wMmnabC0pK Rj7gYbAsXCzGbGllOmkbS+/PUuNqXAjAxIcj+DbFchyQgAsunzTMcYULZXnRuYvok3jjbCR+mTF /EzXLZJKZqWCp9t14CIg48RHWWp5cQgmzG10iswbMHq3E= X-Received: by 2002:a05:600c:1551:b0:490:5466:8576 with SMTP id 5b1f17b1804b1-490b5e9fca9mr46134395e9.1.1780481855020; Wed, 03 Jun 2026 03:17:35 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:34 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:16 +0100 Subject: [PATCH v3 12/19] perf test cs-etm: Skip if not root 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: <20260603-james-cs-context-tracking-fix-v3-12-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Use the common idiom for skipping tests if not running as root, which is required for this test. Signed-off-by: James Clark --- tools/perf/tests/shell/test_arm_coresight.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/test= s/shell/test_arm_coresight.sh index 39553702c1f3..8ed2c934c87d 100755 --- a/tools/perf/tests/shell/test_arm_coresight.sh +++ b/tools/perf/tests/shell/test_arm_coresight.sh @@ -20,6 +20,12 @@ skip_if_no_cs_etm_event() { =20 skip_if_no_cs_etm_event || exit 2 =20 +if [ "$(id -u)" !=3D 0 ]; then + # Requires root for -C and system wide tests + echo "[Skip] No root permission" + exit 2 +fi + perfdata=3D$(mktemp /tmp/__perf_test.perf.data.XXXXX) file=3D$(mktemp /tmp/temporary_file.XXXXX) =20 --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 6920936A02E for ; Wed, 3 Jun 2026 10:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481860; cv=none; b=MuuYfoqvDubO+hZqkLNzXX4z5wjzV9yEjhaF1DzbNqt3ic7epVwHOoTR2C5aoXSX1m/o4L0SXts6B6yErRJXQJ1zarl1rx+mLwohsepoZF3vgRMDnEE1k2rFY9w7VyF9U3PxabUSBIboZvjTa/VLg5HHtQTuZd/9nwQ5CY7i+NU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481860; c=relaxed/simple; bh=bBCpsHP6pxxOKGXqUqpPdX+SmhYJI6iRxQWCSYCtC/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ki4Mh0ur6N3rlZZoDQyY736xe0/AeL1hZIsOCykVATXQgWjCeNI3pLlkTyvlWJ7U9tKQoOtDcG9uGphF39lWOwSb/7BwejGnAG59hETvWV2hkwTx7wIPGbey9BkDljmaZgIDZVOROaQtOJ/5HjEkSKxtbFrA/1t3Hy93lGHzOJo= 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=pij6g+/1; arc=none smtp.client-ip=209.85.128.54 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="pij6g+/1" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-490b2b037d2so14727695e9.3 for ; Wed, 03 Jun 2026 03:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481856; x=1781086656; 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/tFhBvkW5lHa9f/mqQAj4otAbWa3BZTThp9kdngA0w=; b=pij6g+/1MGujnNTCknim+cjuFNgO4He/hv4aeOFN5348PZmqBIvc4RojIJadRTNXz8 n8loZ3TCZiW2mfD3E7XOJnRRx5maXZ40CnUQPxKYIXyXWQNE9/55AuG5+tnSxE0g2N8Z 2xNxhOB0WKKL+KbEG2kluXhgUq/V7XWMbmHWhEvysnwIyFF3UBUjdGIrhD4QpIRpWJY1 HjAh70y4+NgXeN50VZt5sGGG88pDnO3vYAQDkHn83Ka6/SKbkzMVC5BvvWZHp3gKF865 6i7YI9iNlRgoCo8XTduGjRvvxChFoSas53Wjb+kMblRTuc4euVRPSzVcW9qsRTFKpMSC dIbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481856; x=1781086656; 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/tFhBvkW5lHa9f/mqQAj4otAbWa3BZTThp9kdngA0w=; b=PgjS+wQoo7HP1LLsWLPgFmMrsMELt7E6t8YkqnwLE2BqAE/rF4gKeX3CxBC8AWVDdO HdqDDTuxfqVpKyEd+ZH+Zimwm6aRSshJbPE/wzmo1km+tMtgmuy8c0s5N2R0nISOK6u4 CHX9rrOnpno3QhyuPBtdqZcn4gyaaQBhWS/iuHS+J6NFvkaysUpz4IzYHv8OtF5WQ4DB xLEshskqy6pXvA5IbB8O9BKbxfsPmWFY0Au+EnO7fYexKY5ogeLLZ/O2jNYGDoUQcjWM +ShcoYFaj+DZfn9/7ukZcu6x0NesnnIIVe4jIBNGyY5Xw8s05vy2OrGFuA8PI3BTngKb 84Gw== X-Forwarded-Encrypted: i=1; AFNElJ8BS6FCgWYd+gVAd4uuFniogznhGYGXVvUnD7XxHL8CbAL8wWycCCla2I5YrpCo83tZ6MEwpwCLXz3BEFU=@vger.kernel.org X-Gm-Message-State: AOJu0YyO+NmT9R9UP+V03s//IA0pa7WrF8Nhxka2BuELSKddgvfcsPXE Zbfqj6zDw7uVabwIcJcIVOJZaGP+icoUnrIFjClbz+Nr994peqv9BzD7WUOGniuLI5Tj0Y2wzow FkRD1yyk= X-Gm-Gg: Acq92OG8m6Nvpszx8MDlF1fcwvl6/8oVx+BaRTEZOho/7STEpdsbHozcYrgZUWi/oh8 1CrHxSOSgnTdUGqRIrZ+UqDaGRzu9O0I8JdwYIp00FJ9zLDRNo+hiDu3IS3HeK8Gyd9d14RTyFF hoF3qkqLUzkLtfcRmtpKDQnN2KT83wjLR+zItygq4yj9apUFxiFoMjy+vAcYIEyP7+bGd4nBkGn mtpZ31kXHRmXGQlBlvAWPN/17iIbzCBCEENB5U4bLuExFdcL4jpWxWGWe/6RAXVLzJthZ4PPr1M omJai1mKvh+5sYlDL5Gyt8uG/uUOkF3oHGXDo8qTX3jdiqFcJnPUFuea/TLiv0m+SYmXGK11ws8 DQ2XLPYlcaVvj10V6w2Zf+Z6FW1unb5DkC/BgZFCO8xfuHEaBfLYOmvCEibMbVvitk7dCTibK0V nwqVUac4fUT0la53dkX5m8xhURA5QQEgMZkkmVVCXD76/zRaD90PV/Kw== X-Received: by 2002:a05:600c:859b:b0:490:4b89:535d with SMTP id 5b1f17b1804b1-490b5e96157mr35776485e9.1.1780481856126; Wed, 03 Jun 2026 03:17:36 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:35 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:17 +0100 Subject: [PATCH v3 13/19] perf test cs-etm: Reduce snapshot size 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: <20260603-james-cs-context-tracking-fix-v3-13-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 The default buffer size for root is 4MB which is very slow to decode. We only need a few KB to verify that the dd process is hit so reduce the size to 128KB. Signed-off-by: James Clark --- tools/perf/tests/shell/test_arm_coresight.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/test= s/shell/test_arm_coresight.sh index 8ed2c934c87d..da2f599393e2 100755 --- a/tools/perf/tests/shell/test_arm_coresight.sh +++ b/tools/perf/tests/shell/test_arm_coresight.sh @@ -156,7 +156,7 @@ arm_cs_etm_system_wide_test() { =20 arm_cs_etm_snapshot_test() { echo "Recording trace with snapshot mode" - perf record -o ${perfdata} -e cs_etm// -S \ + perf record -o ${perfdata} -e cs_etm// -S -m,128K \ -- dd if=3D/dev/zero of=3D/dev/null > /dev/null 2>&1 & PERFPID=3D$! =20 --=20 2.34.1 From nobody Mon Jun 8 04:25:58 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 C6D3F3ADBA5 for ; Wed, 3 Jun 2026 10:17:38 +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=1780481864; cv=none; b=kjysY2JU3WVJI9MgDjeOH/XX575Ah/UR/AwO8Npm7t0I6VhxtrT2wdUPKFj9Ky5WJCkDj4uR19ptuO+ogbNrR0rmYltaBF0B2hwqjCVXRYFqYJGHus6hJE0xZpmBhnNz4X3G2DI6yJ1TK6nPt5cGZFPIFLLCpT+H1eHA2EizQv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481864; c=relaxed/simple; bh=/bo6v3kFcoolHnOpj+EbZhoQzm7A8RsOcpjrkQcAFBE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pFRJvfXqWr9zsj+3yLeEnDEksvdUFn/ZLJUSNTTZCZjPLrZSwPH5IsSzGCq1XxWrgiAmkzP1lmwf4As7bYam3xfGjzrl+uUuFVQW54Gnptzdz3c1rYkjd+fMTkf6HztZ7/AmNbDi9+HHo38yCs2D1JfWNSUYj1RLVnEed65D0d4= 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=HSuFkwie; 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="HSuFkwie" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-490ae94a89eso25614395e9.1 for ; Wed, 03 Jun 2026 03:17:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481857; x=1781086657; 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=3o0yW6uQ1LnJTQVmIzRpXA5Z0rqK8P+8rneFQb3y1o4=; b=HSuFkwieom49EnqFHf5yKwzZiTc6O0OONc6Q4sHdIq0yQud4hFz8qiMeGsS6K9mGR1 w7LQVeiXvewmSR5U6h7QgfvCOBbZWDYE9r26pZNyPZImAnJ08R9A2/wpxnYyWcCMi/Oo IP97sRHRanPqm+cj66iZyvDVEphgDPyVc7t0ri0VloVKz/FgOEvITkCeEZqrADWAbk3L 5wjmStrUaXEiss6N60Qg2rLCVZTYUwAGIxEBcZNujd7fNZctx6tJg16K0T27WwNrjJac NPAhCy4HWp8sQmTzfSZuLCKBz4SYgln0y/MRGQJpHIpOBCXY89h1VV+yoNTW0SNfTmlt Z2jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481857; x=1781086657; 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=3o0yW6uQ1LnJTQVmIzRpXA5Z0rqK8P+8rneFQb3y1o4=; b=KHUQProY1sntV6ZdGq6PTarXGKxFUK0zmAv1VVfC6lZboCVWdKrW2zJwnlNj3MSEqg 98I4QvJ314ZyhQZC6njFBsgPQcc5VlWsISHQEi5musiJ/qMhNDgnhYJkyjCn7r1na4HA JCCNesyKCmDH/BSICUPHe5o1JSUZwuyDB4/OC7PeaBTVvdiPQAD3FqBvEcNi4S4OmW6U Latqs1qYZS9Nj6zWTDhYDHMGOJbX2GLcuKhRsrYrP/vYHG3SihY95t/6QvjbDCx4rZfO etBpvIneAA4E8i43KnMAwG+yGZvFPimOy8eDjN8RDn/RTeTyS8fz68pziOjFc9LPHZ+l xq3g== X-Forwarded-Encrypted: i=1; AFNElJ9pmQe3Ffqz0boUwnbcgeuXHhZsjkP3AdrmQSsXncayue0BZUT6aZJTZsR1VcGiXFNTU6uFmXMeI00l2Bw=@vger.kernel.org X-Gm-Message-State: AOJu0YwzlnB66YLkKQjV71hMK/v2H1ayje8srIMM3I77pYFfhVrflX85 xl/jYiROfETUyzMj0M9G9CdJhE0JjvmSObAzY7G/QAWpxownM3vA2ie8ZPwISCLa6qI= X-Gm-Gg: Acq92OHfbB191GQp3a+lnavMssBurMtdbGvnHFEYF8ebStmZD+EDYhnEpvpYWG0AF0x YpVP/rl0FQBOr4gZtolpXjaZUmQnKntEiRyZXP/jlq1S5H17WAPbjIsdEUJa73uDP+kKVgeftwr u8ZU60o9AW9tlpEuR0GLiBLxe+df4GBCy7/ipZeR0sSDi3P6SSzbsKdgsafBO+Xco+1AXZebsfV b3InUsLZzOT6TFPXCUjCfDC2obGyOBvkHQ9bj3Lvo1lSTvWPKFzOhisLjUUtMwh3XNOAh6dfLC4 TOJsNjdRXjgyah2mRu67M/U3ZuLpDnFN7vtaWfOcYa63umm5MycAnynkw7Vql5MGMKUT3Tk1ADH gBp7tV9WWjbFwdFmpg6uZYkszNeLP+3gsW6JZ1MBXtqj0+xFcjgHRlAJKZ2auu2LkhLebwbotlW QAw6VHGy/N3/DHc4sQOp/7NBjin5695rnrVBEr7PBuEfH48XrQO+Ye8A== X-Received: by 2002:a05:600c:470c:b0:490:ba0a:1178 with SMTP id 5b1f17b1804b1-490ba0a1480mr19125935e9.28.1780481857184; Wed, 03 Jun 2026 03:17:37 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:36 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:18 +0100 Subject: [PATCH v3 14/19] perf test cs-etm: Speed up basic test 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: <20260603-james-cs-context-tracking-fix-v3-14-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Like the name says, this should be the most basic test possible. Kernel recording is slow and already has coverage on the systemwide test. Perf report output also has coverage elsewhere. 'ls' also produces more trace than 'true'. We only want to test if the combination of recording options works at all, so fix all of these things to make it as fast as possible. Signed-off-by: James Clark --- tools/perf/tests/shell/test_arm_coresight.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/test= s/shell/test_arm_coresight.sh index da2f599393e2..83295a8fe179 100755 --- a/tools/perf/tests/shell/test_arm_coresight.sh +++ b/tools/perf/tests/shell/test_arm_coresight.sh @@ -179,10 +179,9 @@ arm_cs_etm_snapshot_test() { =20 arm_cs_etm_basic_test() { echo "Recording trace with '$*'" - perf record -o ${perfdata} "$@" -m,8M -- ls > /dev/null 2>&1 + perf record -o ${perfdata} "$@" -- true > /dev/null 2>&1 =20 - perf_script_branch_samples ls && - perf_report_instruction_samples ls + perf_script_branch_samples true =20 err=3D$? arm_cs_report "CoreSight basic testing with '$*'" $err @@ -246,12 +245,12 @@ arm_cs_etm_snapshot_test =20 # Test all combinations of per-thread, system-wide and normal mode with # and without timestamps -arm_cs_etm_basic_test -e cs_etm/timestamp=3D0/ --per-thread -arm_cs_etm_basic_test -e cs_etm/timestamp=3D1/ --per-thread -arm_cs_etm_basic_test -e cs_etm/timestamp=3D0/ -a -arm_cs_etm_basic_test -e cs_etm/timestamp=3D1/ -a -arm_cs_etm_basic_test -e cs_etm/timestamp=3D0/ -arm_cs_etm_basic_test -e cs_etm/timestamp=3D1/ +arm_cs_etm_basic_test -e cs_etm/timestamp=3D0/u --per-thread +arm_cs_etm_basic_test -e cs_etm/timestamp=3D1/u --per-thread +arm_cs_etm_basic_test -e cs_etm/timestamp=3D0/u -a +arm_cs_etm_basic_test -e cs_etm/timestamp=3D1/u -a +arm_cs_etm_basic_test -e cs_etm/timestamp=3D0/u +arm_cs_etm_basic_test -e cs_etm/timestamp=3D1/u =20 arm_cs_etm_sparse_cpus_test =20 --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 4F7F13A6B6D for ; Wed, 3 Jun 2026 10:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481865; cv=none; b=X2UOonPw6JSDAb7ybdp+HvKtxNnynmF2PA/tdPlE/+hUyn38b1w8WNI8PbcCksnVu1s2ZltKcKDOuCsU9c6FIYzsW1skYxiembVr7dgddhi7p01pVhFFqjCUc/jXxV3hxQhWPU3rOJgPQ8SaH8x6ebBqFQBbTaLVRx2U37G7Mx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481865; c=relaxed/simple; bh=iK+EPeGCJUL4Rd0+dg6SeeSLGmL00IoQ7KXBGN6a9ko=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oZtzRdqxw1P9zcFWN/4DccZ1NTx0glUe8F0WanhTOzUgcZzen2ZEYUxsX9poFNFXN6pZhC0cyYSilLzuspU/HQapEHw1C3I79p2Xgq87w+qWGG7587TpDeeO63yL8Xj5ZncqfkAMP8cCaj1xLAqauZ0fHGcvyhEkk9oSYaZid8I= 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=baON0Odg; arc=none smtp.client-ip=209.85.128.54 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="baON0Odg" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-49068493267so73842765e9.1 for ; Wed, 03 Jun 2026 03:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481858; x=1781086658; 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=rizj2QOS7B7uZxjiTToPLLngMMrz1F5sdLliowsZ7eA=; b=baON0OdgXvT5ilb0IVXgZ0SoaM/vPqrc6a4ju3yw4GbjQiZkbMS0kiq1+RQ2l7GTfF 2jj70Qt/Gy1nqECuBrsy5f058pKmPUhnXNnIZaM3yFOW0emhkN4Oi7MapNrhvt0Q4Kqf GbpdTcPgIFwn9nqKf8esbmt8243PY9svVfEXo8j61ViY3cnulMROAFsU0r0uP4NvbfeA Y5Jeltxc73JGD6w6UHQzG4gDkweKC5dYVi/tYbgKpmioWFA+ooKausxHYXv7P97S2Boq P2HyLgrQn0HUFwFQOnPJHzuok0bMQldtyk1tKSbdckTlzBzbASRh+2B+T3lmHSZQcQ5+ o4Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481858; x=1781086658; 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=rizj2QOS7B7uZxjiTToPLLngMMrz1F5sdLliowsZ7eA=; b=ZLhPAPDYWEwcGBS4UUBQ3vnCIOjbHJsQdZchJeoZxPnC1ZnVkwkdI6dvDz0Q/3szxb GwL0e0df8RuXk5+r8T0S7klRYTGtBBAdWjV0r3uWundy7L7c/2PQrilAJoLu01eIFRkL QHP+YIIQvj8XScFBfZUywrzCUlB+kEchc9yhPLf6p6bjsUizYegkAuCt0HPRGrLwf7p2 SHArv1jUvsTdEZjh2/MNna3TrT7IXYG9niuFBEIrRHZjA9X+0+d/3oGsnpzg/txh3wgY 9ekAMqRmIzDuNR4KgOAbwBqKLssMBOOgVPKGk9HMwv5kyhpYqnKCm/HPNFyWl2Nz9H4L IGOA== X-Forwarded-Encrypted: i=1; AFNElJ9ttnaxyjaJ7iz/O6aeknYyJMuectBBUJvHk6YLqXZapvAzwJglxtu33shNBgtxeDBaO7PAYojwbwjqX4g=@vger.kernel.org X-Gm-Message-State: AOJu0YxEvtd63npAyAUWQcJRQvQIJ+YNSyduzj3YqA1Dm76m9j7aqlLA u9zPQTWBq8Wa4Vnst2+jts+Z1FvoLSYLn77t/TMkLCj++VO+lSvqO1C/KjR6Ip+qrVQ= X-Gm-Gg: Acq92OHcjWiXw4ocbiJu270yFbL6Pt+TJ9ohcVvk8+0nDmGgesMfbVcZ7NZzY/gvkei +v3404zsrUY6r/OWyzaV3PNZ7DfpgA86p0SRl1LsAQ79WszPxXbxmvbzkUxKV8a4L8FeyFAtv9V QrafQGzJYzOmXEamty501p3ba1z7FYurOeo3S+LYh0PLa7lwxUSPKmsQCswxyJKndNISaM7PHat 2f9TA5g53Lc6RfOEbQznqy7Te6xXSi+xFwGBamEwUSOZuRsILeqbyklNM7uzH59FZXgQSwGhwRi MAwyWLcEbusajwLmfj3RH6l3rC61WX/AzidCzXlkWAu+IQfm6GS/6qHh2kQrFOKDSqQk7UQDU+C TveMZASY0UgZfhIF/luZO4bUxHXUlLfV3StNzwfy5oraWSq9H3/OqL9nYKAi9Y1dKbT5W/AkITm NklD0E4ad+MWLwj+pT8cDsftyvh7ZPoG3VpDsSJUAkLz4= X-Received: by 2002:a05:600c:154f:b0:490:af90:f9c2 with SMTP id 5b1f17b1804b1-490b5eae33dmr45700215e9.12.1780481858265; Wed, 03 Jun 2026 03:17:38 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:37 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:19 +0100 Subject: [PATCH v3 15/19] perf test cs-etm: Remove unused Coresight workloads 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: <20260603-james-cs-context-tracking-fix-v3-15-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 These are now unused and had various issues like not working with out of source builds and being slow to compile. Delete them. Signed-off-by: James Clark --- Documentation/trace/coresight/coresight-perf.rst | 78 +----------- MAINTAINERS | 1 - tools/perf/Makefile.perf | 14 +-- tools/perf/tests/shell/coresight/Makefile | 29 ----- .../perf/tests/shell/coresight/Makefile.miniconfig | 14 --- .../tests/shell/coresight/asm_pure_loop/.gitignore | 1 - .../tests/shell/coresight/asm_pure_loop/Makefile | 34 ------ .../shell/coresight/asm_pure_loop/asm_pure_loop.S | 30 ----- .../tests/shell/coresight/memcpy_thread/.gitignore | 1 - .../tests/shell/coresight/memcpy_thread/Makefile | 33 ----- .../shell/coresight/memcpy_thread/memcpy_thread.c | 80 ------------ .../tests/shell/coresight/thread_loop/.gitignore | 1 - .../tests/shell/coresight/thread_loop/Makefile | 33 ----- .../shell/coresight/thread_loop/thread_loop.c | 85 ------------- .../shell/coresight/unroll_loop_thread/.gitignore | 1 - .../shell/coresight/unroll_loop_thread/Makefile | 33 ----- .../unroll_loop_thread/unroll_loop_thread.c | 75 ------------ tools/perf/tests/shell/lib/coresight.sh | 134 -----------------= ---- 18 files changed, 5 insertions(+), 672 deletions(-) diff --git a/Documentation/trace/coresight/coresight-perf.rst b/Documentati= on/trace/coresight/coresight-perf.rst index 30be89320621..0a77741a431e 100644 --- a/Documentation/trace/coresight/coresight-perf.rst +++ b/Documentation/trace/coresight/coresight-perf.rst @@ -112,78 +112,6 @@ Example for triggering AUX pause and resume with PMU e= vent:: Perf test - Verify kernel and userspace perf CoreSight work ----------------------------------------------------------- =20 -When you run perf test, it will do a lot of self tests. Some of those -tests will cover CoreSight (only if enabled and on ARM64). You -generally would run perf test from the tools/perf directory in the -kernel tree. Some tests will check some internal perf support like: - - Check Arm CoreSight trace data recording and synthesized samples - Check Arm SPE trace data recording and synthesized samples - -Some others will actually use perf record and some test binaries that -are in tests/shell/coresight and will collect traces to ensure a -minimum level of functionality is met. The scripts that launch these -tests are in the same directory. These will all look like: - - CoreSight / ASM Pure Loop - CoreSight / Memcpy 16k 10 Threads - CoreSight / Thread Loop 10 Threads - Check TID - etc. - -These perf record tests will not run if the tool binaries do not exist -in tests/shell/coresight/\*/ and will be skipped. If you do not have -CoreSight support in hardware then either do not build perf with -CoreSight support or remove these binaries in order to not have these -tests fail and have them skip instead. - -These tests will log historical results in the current working -directory (e.g. tools/perf) and will be named stats-\*.csv like: - - stats-asm_pure_loop-out.csv - stats-memcpy_thread-16k_10.csv - ... - -These statistic files log some aspects of the AUX data sections in -the perf data output counting some numbers of certain encodings (a -good way to know that it's working in a very simple way). One problem -with CoreSight is that given a large enough amount of data needing to -be logged, some of it can be lost due to the processor not waking up -in time to read out all the data from buffers etc.. You will notice -that the amount of data collected can vary a lot per run of perf test. -If you wish to see how this changes over time, simply run perf test -multiple times and all these csv files will have more and more data -appended to it that you can later examine, graph and otherwise use to -figure out if things have become worse or better. - -This means sometimes these tests fail as they don't capture all the -data needed. This is about tracking quality and amount of data -produced over time and to see when changes to the Linux kernel improve -quality of traces. - -Be aware that some of these tests take quite a while to run, specifically -in processing the perf data file and dumping contents to then examine what -is inside. - -You can change where these csv logs are stored by setting the -PERF_TEST_CORESIGHT_STATDIR environment variable before running perf -test like:: - - export PERF_TEST_CORESIGHT_STATDIR=3D/var/tmp - perf test - -They will also store resulting perf output data in the current -directory for later inspection like:: - - perf-asm_pure_loop-out.data - perf-memcpy_thread-16k_10.data - ... - -You can alter where the perf data files are stored by setting the -PERF_TEST_CORESIGHT_DATADIR environment variable such as:: - - PERF_TEST_CORESIGHT_DATADIR=3D/var/tmp - perf test - -You may wish to set these above environment variables if you wish to -keep the output of tests outside of the current working directory for -longer term storage and examination. +There are a set of Perf tests for CoreSight which can be run with:: + + sudo perf test coresight diff --git a/MAINTAINERS b/MAINTAINERS index b539be153f6a..7efb893edcbb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2751,7 +2751,6 @@ F: tools/perf/arch/arm/util/cs-etm.h F: tools/perf/arch/arm/util/pmu.c F: tools/perf/tests/shell/*coresight* F: tools/perf/tests/shell/coresight/* -F: tools/perf/tests/shell/lib/*coresight* F: tools/perf/util/cs-etm-decoder/* F: tools/perf/util/cs-etm.* =20 diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 4ac2a0cec9ee..e4f8c979f47b 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -508,16 +508,7 @@ arm64-sysreg-defs-clean: $(Q)$(MAKE) -C $(arm64_gen_sysreg_dir) O=3D$(arm64_gen_sysreg_outdir) \ prefix=3D subdir=3D clean > /dev/null =20 -TESTS_CORESIGHT_DIR :=3D $(srctree)/tools/perf/tests/shell/coresight - -tests-coresight-targets: FORCE - $(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) - -tests-coresight-targets-clean: - $(call QUIET_CLEAN, coresight) - $(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) O=3D$(OUTPUT) clean >/dev/null - -all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PRO= GRAMS) tests-coresight-targets +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PRO= GRAMS) =20 # Create python binding output directory if not already present $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') @@ -896,7 +887,6 @@ install-tests: all install-gtk $(INSTALL) tests/shell/base_report/*.txt '$(DESTDIR_SQ)$(perfexec_instdi= r_SQ)/tests/shell/base_report'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/co= resight' ; \ $(INSTALL) tests/shell/coresight/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_S= Q)/tests/shell/coresight' - $(Q)$(MAKE) -C tests/shell/coresight install-tests =20 install-bin: install-tools install-tests =20 @@ -939,7 +929,7 @@ endif =20 clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-cl= ean $(LIBPERF)-clean \ arm64-sysreg-defs-clean fixdep-clean python-clean bpf-skel-clean \ - tests-coresight-targets-clean pmu-events-clean + pmu-events-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive \ $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '*.a' -delete -o \ diff --git a/tools/perf/tests/shell/coresight/Makefile b/tools/perf/tests/s= hell/coresight/Makefile deleted file mode 100644 index fa08fd9a5991..000000000000 --- a/tools/perf/tests/shell/coresight/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# Carsten Haitzler , 2021 -include ../../../../../tools/scripts/Makefile.include -include ../../../../../tools/scripts/Makefile.arch -include ../../../../../tools/scripts/utilities.mak - -SUBDIRS =3D \ - asm_pure_loop \ - memcpy_thread \ - thread_loop \ - unroll_loop_thread - -all: $(SUBDIRS) -$(SUBDIRS): - @$(MAKE) -C $@ >/dev/null - -INSTALLDIRS =3D $(SUBDIRS:%=3Dinstall-%) - -install-tests: $(INSTALLDIRS) -$(INSTALLDIRS): - @$(MAKE) -C $(@:install-%=3D%) install-tests >/dev/null - -CLEANDIRS =3D $(SUBDIRS:%=3Dclean-%) - -clean: $(CLEANDIRS) -$(CLEANDIRS): - $(call QUIET_CLEAN, test-$(@:clean-%=3D%)) $(MAKE) -C $(@:clean-%=3D%) cl= ean >/dev/null - -.PHONY: all clean $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) diff --git a/tools/perf/tests/shell/coresight/Makefile.miniconfig b/tools/p= erf/tests/shell/coresight/Makefile.miniconfig deleted file mode 100644 index 5f72a9cb43f3..000000000000 --- a/tools/perf/tests/shell/coresight/Makefile.miniconfig +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# Carsten Haitzler , 2021 - -ifndef DESTDIR -prefix ?=3D $(HOME) -endif - -DESTDIR_SQ =3D $(subst ','\'',$(DESTDIR)) -INSTALL =3D install -INSTDIR_SUB =3D tests/shell/coresight - -include ../../../../../scripts/Makefile.include -include ../../../../../scripts/Makefile.arch -include ../../../../../scripts/utilities.mak diff --git a/tools/perf/tests/shell/coresight/asm_pure_loop/.gitignore b/to= ols/perf/tests/shell/coresight/asm_pure_loop/.gitignore deleted file mode 100644 index 468673ac32e8..000000000000 --- a/tools/perf/tests/shell/coresight/asm_pure_loop/.gitignore +++ /dev/null @@ -1 +0,0 @@ -asm_pure_loop diff --git a/tools/perf/tests/shell/coresight/asm_pure_loop/Makefile b/tool= s/perf/tests/shell/coresight/asm_pure_loop/Makefile deleted file mode 100644 index 206849e92bc9..000000000000 --- a/tools/perf/tests/shell/coresight/asm_pure_loop/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 - -include ../Makefile.miniconfig - -# Binary to produce -BIN=3Dasm_pure_loop -# Any linking/libraries needed for the binary - empty if none needed -LIB=3D - -all: $(BIN) - -$(BIN): $(BIN).S -ifdef CORESIGHT -ifeq ($(ARCH),arm64) -# Build line - this is raw asm with no libc to have an always exact binary - $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) -endif -endif - -install-tests: all -ifdef CORESIGHT -ifeq ($(ARCH),arm64) -# Install the test tool in the right place - $(call QUIET_INSTALL, tests) \ - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)= /$(BIN)'; \ - $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(= BIN)/$(BIN)' -endif -endif - -clean: - $(Q)$(RM) -f $(BIN) - -.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/coresight/asm_pure_loop/asm_pure_loop.S= b/tools/perf/tests/shell/coresight/asm_pure_loop/asm_pure_loop.S deleted file mode 100644 index 577760046772..000000000000 --- a/tools/perf/tests/shell/coresight/asm_pure_loop/asm_pure_loop.S +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Tamas Zsoldos , 2021 */ - -.globl _start -_start: - mov x0, 0x0000ffff - mov x1, xzr -loop: - nop - nop - cbnz x1, noskip - nop - nop - adrp x2, skip - add x2, x2, :lo12:skip - br x2 - nop - nop -noskip: - nop - nop -skip: - sub x0, x0, 1 - cbnz x0, loop - - mov x0, #0 - mov x8, #93 // __NR_exit syscall - svc #0 - -.section .note.GNU-stack, "", @progbits diff --git a/tools/perf/tests/shell/coresight/memcpy_thread/.gitignore b/to= ols/perf/tests/shell/coresight/memcpy_thread/.gitignore deleted file mode 100644 index f8217e56091e..000000000000 --- a/tools/perf/tests/shell/coresight/memcpy_thread/.gitignore +++ /dev/null @@ -1 +0,0 @@ -memcpy_thread diff --git a/tools/perf/tests/shell/coresight/memcpy_thread/Makefile b/tool= s/perf/tests/shell/coresight/memcpy_thread/Makefile deleted file mode 100644 index 2db637eb2c26..000000000000 --- a/tools/perf/tests/shell/coresight/memcpy_thread/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 -include ../Makefile.miniconfig - -# Binary to produce -BIN=3Dmemcpy_thread -# Any linking/libraries needed for the binary - empty if none needed -LIB=3D-pthread - -all: $(BIN) - -$(BIN): $(BIN).c -ifdef CORESIGHT -ifeq ($(ARCH),arm64) -# Build line - $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) -endif -endif - -install-tests: all -ifdef CORESIGHT -ifeq ($(ARCH),arm64) -# Install the test tool in the right place - $(call QUIET_INSTALL, tests) \ - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)= /$(BIN)'; \ - $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(= BIN)/$(BIN)' -endif -endif - -clean: - $(Q)$(RM) -f $(BIN) - -.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c= b/tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c deleted file mode 100644 index 7e879217be30..000000000000 --- a/tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c +++ /dev/null @@ -1,80 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// Carsten Haitzler , 2021 -#include -#include -#include -#include -#include - -struct args { - unsigned long loops; - unsigned long size; - pthread_t th; - void *ret; -}; - -static void *thrfn(void *arg) -{ - struct args *a =3D arg; - unsigned long i, len =3D a->loops; - unsigned char *src, *dst; - - src =3D malloc(a->size * 1024); - dst =3D malloc(a->size * 1024); - if ((!src) || (!dst)) { - printf("ERR: Can't allocate memory\n"); - exit(1); - } - for (i =3D 0; i < len; i++) - memcpy(dst, src, a->size * 1024); - - return NULL; -} - -static pthread_t new_thr(void *(*fn) (void *arg), void *arg) -{ - pthread_t t; - pthread_attr_t attr; - - pthread_attr_init(&attr); - pthread_create(&t, &attr, fn, arg); - return t; -} - -int main(int argc, char **argv) -{ - unsigned long i, len, size, thr; - struct args args[256]; - long long v; - - if (argc < 4) { - printf("ERR: %s [copysize Kb] [numthreads] [numloops (hundreds)]\n", arg= v[0]); - exit(1); - } - - v =3D atoll(argv[1]); - if ((v < 1) || (v > (1024 * 1024))) { - printf("ERR: max memory 1GB (1048576 KB)\n"); - exit(1); - } - size =3D v; - thr =3D atol(argv[2]); - if ((thr < 1) || (thr > 256)) { - printf("ERR: threads 1-256\n"); - exit(1); - } - v =3D atoll(argv[3]); - if ((v < 1) || (v > 40000000000ll)) { - printf("ERR: loops 1-40000000000 (hundreds)\n"); - exit(1); - } - len =3D v * 100; - for (i =3D 0; i < thr; i++) { - args[i].loops =3D len; - args[i].size =3D size; - args[i].th =3D new_thr(thrfn, &(args[i])); - } - for (i =3D 0; i < thr; i++) - pthread_join(args[i].th, &(args[i].ret)); - return 0; -} diff --git a/tools/perf/tests/shell/coresight/thread_loop/.gitignore b/tool= s/perf/tests/shell/coresight/thread_loop/.gitignore deleted file mode 100644 index 6d4c33eaa9e8..000000000000 --- a/tools/perf/tests/shell/coresight/thread_loop/.gitignore +++ /dev/null @@ -1 +0,0 @@ -thread_loop diff --git a/tools/perf/tests/shell/coresight/thread_loop/Makefile b/tools/= perf/tests/shell/coresight/thread_loop/Makefile deleted file mode 100644 index ea846c038e7a..000000000000 --- a/tools/perf/tests/shell/coresight/thread_loop/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 -include ../Makefile.miniconfig - -# Binary to produce -BIN=3Dthread_loop -# Any linking/libraries needed for the binary - empty if none needed -LIB=3D-pthread - -all: $(BIN) - -$(BIN): $(BIN).c -ifdef CORESIGHT -ifeq ($(ARCH),arm64) -# Build line - $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) -endif -endif - -install-tests: all -ifdef CORESIGHT -ifeq ($(ARCH),arm64) -# Install the test tool in the right place - $(call QUIET_INSTALL, tests) \ - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)= /$(BIN)'; \ - $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(= BIN)/$(BIN)' -endif -endif - -clean: - $(Q)$(RM) -f $(BIN) - -.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/coresight/thread_loop/thread_loop.c b/t= ools/perf/tests/shell/coresight/thread_loop/thread_loop.c deleted file mode 100644 index 86f3f548b006..000000000000 --- a/tools/perf/tests/shell/coresight/thread_loop/thread_loop.c +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// Carsten Haitzler , 2021 - -// define this for gettid() -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#ifndef SYS_gettid -// gettid is 178 on arm64 -# define SYS_gettid 178 -#endif -#define gettid() syscall(SYS_gettid) - -struct args { - unsigned int loops; - pthread_t th; - void *ret; -}; - -static void *thrfn(void *arg) -{ - struct args *a =3D arg; - int i =3D 0, len =3D a->loops; - - if (getenv("SHOW_TID")) { - unsigned long long tid =3D gettid(); - - printf("%llu\n", tid); - } - asm volatile( - "loop:\n" - "add %w[i], %w[i], #1\n" - "cmp %w[i], %w[len]\n" - "blt loop\n" - : /* out */ - : /* in */ [i] "r" (i), [len] "r" (len) - : /* clobber */ - ); - return (void *)(long)i; -} - -static pthread_t new_thr(void *(*fn) (void *arg), void *arg) -{ - pthread_t t; - pthread_attr_t attr; - - pthread_attr_init(&attr); - pthread_create(&t, &attr, fn, arg); - return t; -} - -int main(int argc, char **argv) -{ - unsigned int i, len, thr; - struct args args[256]; - - if (argc < 3) { - printf("ERR: %s [numthreads] [numloops (millions)]\n", argv[0]); - exit(1); - } - - thr =3D atoi(argv[1]); - if ((thr < 1) || (thr > 256)) { - printf("ERR: threads 1-256\n"); - exit(1); - } - len =3D atoi(argv[2]); - if ((len < 1) || (len > 4000)) { - printf("ERR: max loops 4000 (millions)\n"); - exit(1); - } - len *=3D 1000000; - for (i =3D 0; i < thr; i++) { - args[i].loops =3D len; - args[i].th =3D new_thr(thrfn, &(args[i])); - } - for (i =3D 0; i < thr; i++) - pthread_join(args[i].th, &(args[i].ret)); - return 0; -} diff --git a/tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore= b/tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore deleted file mode 100644 index 2cb4e996dbf3..000000000000 --- a/tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore +++ /dev/null @@ -1 +0,0 @@ -unroll_loop_thread diff --git a/tools/perf/tests/shell/coresight/unroll_loop_thread/Makefile b= /tools/perf/tests/shell/coresight/unroll_loop_thread/Makefile deleted file mode 100644 index 6264c4e3abd1..000000000000 --- a/tools/perf/tests/shell/coresight/unroll_loop_thread/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 -include ../Makefile.miniconfig - -# Binary to produce -BIN=3Dunroll_loop_thread -# Any linking/libraries needed for the binary - empty if none needed -LIB=3D-pthread - -all: $(BIN) - -$(BIN): $(BIN).c -ifdef CORESIGHT -ifeq ($(ARCH),arm64) -# Build line - $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) -endif -endif - -install-tests: all -ifdef CORESIGHT -ifeq ($(ARCH),arm64) -# Install the test tool in the right place - $(call QUIET_INSTALL, tests) \ - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)= /$(BIN)'; \ - $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(= BIN)/$(BIN)' -endif -endif - -clean: - $(Q)$(RM) -f $(BIN) - -.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loo= p_thread.c b/tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loo= p_thread.c deleted file mode 100644 index 8f4e1c985ca3..000000000000 --- a/tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_threa= d.c +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// Carsten Haitzler , 2021 -#include -#include -#include -#include -#include - -struct args { - pthread_t th; - unsigned int in; - void *ret; -}; - -static void *thrfn(void *arg) -{ - struct args *a =3D arg; - unsigned int i, in =3D a->in; - - for (i =3D 0; i < 10000; i++) { - asm volatile ( -// force an unroll of thia add instruction so we can test long runs of code -#define SNIP1 "add %w[in], %w[in], #1\n" -// 10 -#define SNIP2 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 -// 100 -#define SNIP3 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 -// 1000 -#define SNIP4 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 -// 10000 -#define SNIP5 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 -// 100000 - SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 - : /* out */ - : /* in */ [in] "r" (in) - : /* clobber */ - ); - } - - return NULL; -} - -static pthread_t new_thr(void *(*fn) (void *arg), void *arg) -{ - pthread_t t; - pthread_attr_t attr; - - pthread_attr_init(&attr); - pthread_create(&t, &attr, fn, arg); - return t; -} - -int main(int argc, char **argv) -{ - unsigned int i, thr; - struct args args[256]; - - if (argc < 2) { - printf("ERR: %s [numthreads]\n", argv[0]); - exit(1); - } - - thr =3D atoi(argv[1]); - if ((thr > 256) || (thr < 1)) { - printf("ERR: threads 1-256\n"); - exit(1); - } - for (i =3D 0; i < thr; i++) { - args[i].in =3D rand(); - args[i].th =3D new_thr(thrfn, &(args[i])); - } - for (i =3D 0; i < thr; i++) - pthread_join(args[i].th, &(args[i].ret)); - return 0; -} diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/she= ll/lib/coresight.sh deleted file mode 100644 index 184d62e7e5bd..000000000000 --- a/tools/perf/tests/shell/lib/coresight.sh +++ /dev/null @@ -1,134 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Carsten Haitzler , 2021 - -# This is sourced from a driver script so no need for #!/bin... etc. at the -# top - the assumption below is that it runs as part of sourcing after the -# test sets up some basic env vars to say what it is. - -# This currently works with ETMv4 / ETF not any other packet types at thi -# point. This will need changes if that changes. - -# perf record options for the perf tests to use -PERFRECMEM=3D"-m ,16M" -PERFRECOPT=3D"$PERFRECMEM -e cs_etm//u" - -TOOLS=3D$(dirname $0) -DIR=3D"$TOOLS/$TEST" -BIN=3D"$DIR/$TEST" -# If the test tool/binary does not exist and is executable then skip the t= est -if ! test -x "$BIN"; then exit 2; fi -# If CoreSight is not available, skip the test -perf list pmu | grep -q cs_etm || exit 2 -DATD=3D"." -# If the data dir env is set then make the data dir use that instead of ./ -if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then - DATD=3D"$PERF_TEST_CORESIGHT_DATADIR"; -fi -# If the stat dir env is set then make the data dir use that instead of ./ -STATD=3D"." -if test -n "$PERF_TEST_CORESIGHT_STATDIR"; then - STATD=3D"$PERF_TEST_CORESIGHT_STATDIR"; -fi - -# Called if the test fails - error code 1 -err() { - echo "$1" - exit 1 -} - -# Check that some statistics from our perf -check_val_min() { - STATF=3D"$4" - if test "$2" -lt "$3"; then - echo ", FAILED" >> "$STATF" - err "Sanity check number of $1 is too low ($2 < $3)" - fi -} - -perf_dump_aux_verify() { - # Some basic checking that the AUX chunk contains some sensible data - # to see that we are recording something and at least a minimum - # amount of it. We should almost always see Fn packets in just about - # anything but certainly we will see some trace info and async - # packets - DUMP=3D"$DATD/perf-tmp-aux-dump.txt" - perf report --stdio --dump -i "$1" | \ - grep -o -e I_ATOM_F -e I_ASYNC -e I_TRACE_INFO > "$DUMP" - # Simply count how many of these packets we find to see that we are - # producing a reasonable amount of data - exact checks are not sane - # as this is a lossy process where we may lose some blocks and the - # compiler may produce different code depending on the compiler and - # optimization options, so this is rough just to see if we're - # either missing almost all the data or all of it - ATOM_FX_NUM=3D$(grep -c I_ATOM_F "$DUMP") - ASYNC_NUM=3D$(grep -c I_ASYNC "$DUMP") - TRACE_INFO_NUM=3D$(grep -c I_TRACE_INFO "$DUMP") - rm -f "$DUMP" - - # Arguments provide minimums for a pass - CHECK_FX_MIN=3D"$2" - CHECK_ASYNC_MIN=3D"$3" - CHECK_TRACE_INFO_MIN=3D"$4" - - # Write out statistics, so over time you can track results to see if - # there is a pattern - for example we have less "noisy" results that - # produce more consistent amounts of data each run, to see if over - # time any techinques to minimize data loss are having an effect or - # not - STATF=3D"$STATD/stats-$TEST-$DATV.csv" - if ! test -f "$STATF"; then - echo "ATOM Fx Count, Minimum, ASYNC Count, Minimum, TRACE INFO Count, Mi= nimum" > "$STATF" - fi - echo -n "$ATOM_FX_NUM, $CHECK_FX_MIN, $ASYNC_NUM, $CHECK_ASYNC_MIN, $TRAC= E_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" - - # Actually check to see if we passed or failed. - check_val_min "ATOM_FX" "$ATOM_FX_NUM" "$CHECK_FX_MIN" "$STATF" - check_val_min "ASYNC" "$ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" - check_val_min "TRACE_INFO" "$TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$ST= ATF" - echo ", Ok" >> "$STATF" -} - -perf_dump_aux_tid_verify() { - # Specifically crafted test will produce a list of Tread ID's to - # stdout that need to be checked to see that they have had trace - # info collected in AUX blocks in the perf data. This will go - # through all the TID's that are listed as CID=3D0xabcdef and see - # that all the Thread IDs the test tool reports are in the perf - # data AUX chunks - - # The TID test tools will print a TID per stdout line that are being - # tested - TIDS=3D$(cat "$2") - # Scan the perf report to find the TIDs that are actually CID in hex - # and build a list of the ones found - FOUND_TIDS=3D$(perf report --stdio --dump -i "$1" | \ - grep -o "CID=3D0x[0-9a-z]\+" | sed 's/CID=3D//g' | \ - uniq | sort | uniq) - # No CID=3Dxxx found - maybe your kernel is reporting these as - # VMID=3Dxxx so look there - if test -z "$FOUND_TIDS"; then - FOUND_TIDS=3D$(perf report --stdio --dump -i "$1" | \ - grep -o "VMID=3D0x[0-9a-z]\+" | sed 's/VMID=3D//g' | \ - uniq | sort | uniq) - fi - - # Iterate over the list of TIDs that the test says it has and find - # them in the TIDs found in the perf report - MISSING=3D"" - for TID2 in $TIDS; do - FOUND=3D"" - for TIDHEX in $FOUND_TIDS; do - TID=3D$(printf "%i" $TIDHEX) - if test "$TID" -eq "$TID2"; then - FOUND=3D"y" - break - fi - done - if test -z "$FOUND"; then - MISSING=3D"$MISSING $TID" - fi - done - if test -n "$MISSING"; then - err "Thread IDs $MISSING not found in perf AUX data" - fi -} --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 12340453497 for ; Wed, 3 Jun 2026 10:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481863; cv=none; b=XYS+khZ9fVDG6/X0gfILHrbctjEtafTcrEgkoP49294zui8bjcg7IfHKDr6s2fbGWa0iV5JJiELVkR0/p3lQOyMVCmJ3q2LvxcrAI/k4NJ+eLH+Xghus4pmHr86lRfiMaMBjZGU+BCJGB1u/HFY4PTgkmMOLpcVlVLze6QUojcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481863; c=relaxed/simple; bh=Vebm4GlJiLVnJYDjVjznOc3fuBf50TfDyVZ1u6hrZBk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HVR4DpAbSUmDyvzns9mvxu7TrrTKX4Jz8jfrTqBv7uP2GOx2wxfNGYNesAEKQrSDD8vDqQ6XfDl5nCm4mqf3Nw1wHC+O1EeJQK/rUeDKSLB+4lQJytH/fWEX8yqt56Zg1NFEmHkM2JU5th95RhfERzwE16tqul4jnnfrNLMO9O4= 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=T/ftEwW0; arc=none smtp.client-ip=209.85.128.44 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="T/ftEwW0" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-49050ff7cbdso116635915e9.2 for ; Wed, 03 Jun 2026 03:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481859; x=1781086659; 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=k+iZ6FY03jm4PeAHyOI8fNsNwbPR2PmNKt6aEgZZmgI=; b=T/ftEwW0pEl9jLnRfSiTjheoJsYaybkAD4Uc85R7oX26Fb4CC2j5+lGx9t/k++xmlD 8uDStFHufFOj1xMdp4ugPk71FpBwsHBZ1J6XB1RrmR3SMqAP5mu/SU5j5nQ6YXEf8/6j gMg2T01bRrbnEPK4C+lam8v1p+OBeUSZdHX2Ehyzgpk2PN9NLURK5PjX/N8+KNQ4Zh08 jduB8ScMgdrXltlQJ4/gK+tkFi4/fo6Tu8Su8rxKI5fvxrX3ReZahxMrFqCnELSoxWrx N/3LgsYeomoOGu9xa7EN4dXqlxpE5Mgt8gNeHJfQbQSrXMAosR7g8Y4CniqKhGJgZB7i q9Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481859; x=1781086659; 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=k+iZ6FY03jm4PeAHyOI8fNsNwbPR2PmNKt6aEgZZmgI=; b=GuGInUWmTAR/Zta1Tua1LOERdgM9HdMLtJQv44p5WYVlmk6bcbVy3FKn0VzXvdaf53 gTG1gilXcKnw8V0GFx+6KUn3EdpJgDys0d21mDLesXZiyTEDh2xK2d1yZ/y8AgGs2arN yuceBChzLricSs3lWyBqpYPdQamijZktH3qsU8Vr114mGc3+FMco5sMO0DbAZb9NiOz7 B30oMDm74eOhkHSS31fW0U5XTbA6jDzU0ztA/lkyDGXOPPpW/+uLvs73vMHCTFI23mtC 8K030QYqKjbV86MniEnCzy8E3TQ3GyP4JIShFko6mr0dmkntCpimbEUvn8f9tkWwwE6y 7WCw== X-Forwarded-Encrypted: i=1; AFNElJ9JbfOxDH6KVXJUsP/9bFXJr15Pwj4663dt45erLnnBcJJiwehyg5v3WuLN8nBxWX32/ziCBUzmttvcL4g=@vger.kernel.org X-Gm-Message-State: AOJu0YwwK0MEa6BDF8tdDNjiwaqc5m98SvHNwfpcXufRz+XI59euQWiU i2LFvdyWAMJFElydZ/E/gUU00XxpdJkMOOFr3WlvoBvyZ2tE8/VImIPwlWvN9ngxX/U= X-Gm-Gg: Acq92OFYB+z1+Y6BqeOEkOa/NU9gtoAp5vWpBVTZ2f+wVJmA7OCgO8GqrxJLSGiPu6R tSoqXXYwWBWnK/6DCZBk1Vx2/yW9gpR/qbrYQJcS5pDFTmoJgjwjTNWXQuOwWeSX+fLVIbSvB7U emms/kcpHGYAMje/MZ/XZh1VxLshe/ZfmxY8bbpeMbA/xBqgwOLO/hE6YFslv6Z2B08T1nhjgXL WMCcmzGQOcEWcNLpoQvWjtnZHAoY+oZJk1wBdQEDzUBoYpek0fLukAJB2CF49e87mbLHmz6lT+J 5DJivv0ahQm8KpHVYUPuZhTyTrXtgc4+63YQz5BLeyd3EY476LhekorBhqx2A5yl1WzYs7nW629 Lfxzr2s7kiNN1n6Gdr9/CCRbXZoSaWMclVvvk7Udz0YkBEwnKwhmIm5FsGVALzqhGoBm5UUS9mi 8PUzQhtAD9tgwBaxtwRR+NdaDWLYFuI2NkmzroDF7hw5M= X-Received: by 2002:a05:600c:1c1e:b0:48e:6db3:ff3a with SMTP id 5b1f17b1804b1-490b5eb137bmr45865975e9.16.1780481859388; Wed, 03 Jun 2026 03:17:39 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:38 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:20 +0100 Subject: [PATCH v3 16/19] perf test cs-etm: Make disassembly test use kcore 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: <20260603-james-cs-context-tracking-fix-v3-16-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Hits in modules return empty disassembly with vmlinux as an input to objdump. Make the disassembly test more reliable by always using kcore. And update the comments to say that this is supported by the script. Signed-off-by: James Clark --- tools/perf/scripts/python/arm-cs-trace-disasm.py | 20 ++++++++++-------= --- tools/perf/tests/shell/test_arm_coresight_disasm.sh | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/= scripts/python/arm-cs-trace-disasm.py index ba208c90d631..8f6fa4a007b4 100755 --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py @@ -18,29 +18,29 @@ from perf_trace_context import perf_sample_srccode, per= f_config_get =20 # Below are some example commands for using this script. # Note a --kcore recording is required for accurate decode -# due to the alternatives patching mechanism. However this -# script only supports reading vmlinux for disassembly dump, -# meaning that any patched instructions will appear -# as unpatched, but the instruction ranges themselves will -# be correct. In addition to this, source line info comes -# from Perf, and when using kcore there is no debug info. The -# following lists the supported features in each mode: +# due to the alternatives patching mechanism. In addition to this, +# source line info comes from Perf, and when using kcore there is +# no debug info. The following lists the supported features in each mode: # # +-----------+-----------------+------------------+------------------+ # | Recording | Accurate decode | Source line dump | Disassembly dump | # +-----------+-----------------+------------------+------------------+ # | --kcore | yes | no | yes | -# | normal | no | yes | yes | +# | normal | no | yes (inaccurate) | yes (inaccurate) | # +-----------+-----------------+------------------+------------------+ # # Output disassembly with objdump and auto detect vmlinux -# (when running on same machine.) +# (when running on same machine.): # perf script -s scripts/python/arm-cs-trace-disasm.py -d # # Output disassembly with llvm-objdump: # perf script -s scripts/python/arm-cs-trace-disasm.py \ # -- -d llvm-objdump-11 -k path/to/vmlinux # +# Output accurate disassembly by passing kcore to script: +# perf script -s scripts/python/arm-cs-trace-disasm.py \ +# -- -d -k perf.data/kcore_dir/kcore +# # Output only source line and symbols: # perf script -s scripts/python/arm-cs-trace-disasm.py =20 @@ -57,7 +57,7 @@ def int_arg(v): =20 args =3D argparse.ArgumentParser() args.add_argument("-k", "--vmlinux", - help=3D"Set path to vmlinux file. Omit to autodetect if running on sam= e machine") + help=3D"Set path to vmlinux or kcore file. Omit to autodetect if runni= ng on same machine") args.add_argument("-d", "--objdump", nargs=3D"?", const=3Ddefault_objdump(= ), help=3D"Show disassembly. Can also be used to change the objdump path"= ), args.add_argument("-v", "--verbose", action=3D"store_true", help=3D"Enable= debugging log") diff --git a/tools/perf/tests/shell/test_arm_coresight_disasm.sh b/tools/pe= rf/tests/shell/test_arm_coresight_disasm.sh index 0dfb4fadf531..8b5c60a09012 100755 --- a/tools/perf/tests/shell/test_arm_coresight_disasm.sh +++ b/tools/perf/tests/shell/test_arm_coresight_disasm.sh @@ -46,7 +46,7 @@ if [ -e /proc/kcore ]; then echo "Testing kernel disassembly" perf record -o ${perfdata} -e cs_etm//k --kcore -- touch $file > /dev/nul= l 2>&1 perf script -i ${perfdata} -s python:${script_path} -- \ - -d --stop-sample=3D30 2> /dev/null > ${file} + -d --stop-sample=3D30 -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${fi= le} grep -q -e ${branch_search} ${file} echo "Found kernel branches" else --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 EFD5345349C for ; Wed, 3 Jun 2026 10:17:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481864; cv=none; b=OWm4ayhvQBEzBM6yVG01203AUaRXZ1kkEkQVfSf/3xoc3LCe4uPEBUNBsGBoqvp3NZBfFD+UY9esIBbRcAzLAZyBuQIq8sRxjC0gdzoPtVu/k5kx94NGF/EeNmIhpc0f2G7RqEBc48iHeGyHTmECtXNKXv3N2WrULvLwFX6lPd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481864; c=relaxed/simple; bh=kiF2OTFMHPFSfKgoJlJ6LUHEtfynLX2Gc37z45ui+yM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O+4JrldLFCgKd2Omu9OI5YhDpfw21PfQrphfihqSTPVLFI9RCaewz91D/i2sE+tIfdc12AlApNUCcQVIzi12Uy67tL14CoDzJTwp95IOCP35aWQ/ZX8cbgGh6MFH7z9VOilTCxPoRs9XlrzA0lhjzFgfUDV5SKPAu2jKMP2Z/a8= 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=vQTVNg7z; arc=none smtp.client-ip=209.85.128.53 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="vQTVNg7z" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490b12270b3so12543295e9.1 for ; Wed, 03 Jun 2026 03:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481860; x=1781086660; 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=wlDlLwXjKsadrJWN67gG6GxzbQU2KCIjPSaxtLGJjnQ=; b=vQTVNg7zStkvZtjOEzfnPUZbwL4C0rRgvMgi05qRx18yWEItjWOvVZdTqukQfZpgxc K19U0Juqq8GZVBTajnkoFI6VWoTL5kealx5w80UzjG8c5t+pyJEbJZ5m/ijhuSWOc0/s vidD+ViK4kZyhAuHeH+lzYmvGpGxzSkRgFKuO8tHEnnFCZ4K+wQFwbClXBFg/yiMPKhA V3lEvoLoo3gBG8QyTsQkd8LEObYCbvjmVDB2Aa9Z1uMDoHlievme8veeKMpgwj/t22th S9nxDecgQ5oY7JOpxFUP9nHcvHJ3Y8/mZbOJNJKDHHA0JrmjZuURn29aL7FVbmUc0oTv mG9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481860; x=1781086660; 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=wlDlLwXjKsadrJWN67gG6GxzbQU2KCIjPSaxtLGJjnQ=; b=cFj+a30uhTDLmScBmUoc+Q5h7rPnplL+kcLLizI2PAtUN8PF2R+EtZkk/IrooA0JCU swic4mbt0m4YzgFG/26p7kXFirscI/FDRmb0WgePHtrbRVkaGTPsZe53+ScBMzBF0v+M DxHxeVSndXjcgmSmGyQ91/H2ng1zgPpKbxpseGTs1FGFLYEm8rbKtKIe80t75ORifWa3 kPJgRDN5YVWVMmIBIjjyRF79lfNKr83XfcOg7X21wLtKkQh2wULshUmMxn2aF0yMzolC t5erdfmqgp7rOVjI5VfRq9+3xTOnqDQT/adcmlKPtYk+n5sa/VPYkM2SGj52DvcS7ZFm C8PQ== X-Forwarded-Encrypted: i=1; AFNElJ8WpfAdOoWWW7DZ2egwotlm6pf4ZcEBA6as8iJ4Y9l/vGPvUO7GEM37hccM/Up9Hf5QZ50cPS+0R0HHNwI=@vger.kernel.org X-Gm-Message-State: AOJu0YzgW7eu8UAdj7yLTwtMcpQMpRtQSuEwxjeAsfHnwIdBzD1Mw27y +TkFo2gmpXxtx02B6JxQNYDYtsBycs+6Fl3GAnu9rHOOdpaH6pWq9iBqmnLECRgp270= X-Gm-Gg: Acq92OHA8MejizRyX4TmVQjOlBkD5F1A29CAg5ABQTXB/Zb04B9MnJmAT9l1s6D+omi AD1WHvo3Pnc+n1IpgdKOuJSH+S7wXR8HNvEjrM81ZbYXeEiyrHemgruxxqcsGgeQvw8vOg7Cf74 cWnrN4T3/KXVdqIdqcJeykr6Q6V0XXSZBmgf4xLS/fzrmpRMVGbeFBXHwD2qhhdE4ak13Sdby6H q0zWIkYCjAYk0CH5VJh5zkIjoBbRBzSuBm9704b5oP7Vr2lgp4toF4lyhYG+LWAn4u90nc5qvs6 5VTyYaXdmKkDu6S68V/LWSVxHKMj9sBpRJJoBx1IWJz7rwUPEovbICLra78w0ayg7h8mjyKnlzF YsBSOEAmO6Xil5M1rHRlE+DHmQrknMGxBSyJ1b27Su6aBlT+M/sb3uFHPDdsnbiZSiLQcUMrCGv 60Wbe039TVUbBUxge8lNMlE8vOe0Sbm2VCOIo+y+K/Byk= X-Received: by 2002:a05:600c:1c13:b0:490:b642:ce29 with SMTP id 5b1f17b1804b1-490b642cea1mr43638275e9.8.1780481860386; Wed, 03 Jun 2026 03:17:40 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:40 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:21 +0100 Subject: [PATCH v3 17/19] perf test cs-etm: Add all branch instructions to test 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: <20260603-james-cs-context-tracking-fix-v3-17-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 If we reduce the number of samples searched to speed up the test, then there will be less chance of hitting one of these branches. Extend the regex to cover all branches so the test will always pass. Signed-off-by: James Clark --- tools/perf/tests/shell/test_arm_coresight_disasm.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_coresight_disasm.sh b/tools/pe= rf/tests/shell/test_arm_coresight_disasm.sh index 8b5c60a09012..5ee87eb7973e 100755 --- a/tools/perf/tests/shell/test_arm_coresight_disasm.sh +++ b/tools/perf/tests/shell/test_arm_coresight_disasm.sh @@ -38,8 +38,7 @@ cleanup_files() trap cleanup_files EXIT TERM INT =20 # Ranges start and end on branches, so check for some likely branch instru= ctions -sep=3D"\s\|\s" -branch_search=3D"\sbl${sep}b${sep}b.ne${sep}b.eq${sep}cbz\s" +branch_search=3D'[[:space:]](bl|b(\.(eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|g= t|le|al))?|br|blr|ret|cbz|cbnz|tbz|tbnz|svc|eret)([[:space:]]|$)' =20 ## Test kernel ## if [ -e /proc/kcore ]; then @@ -47,7 +46,7 @@ if [ -e /proc/kcore ]; then perf record -o ${perfdata} -e cs_etm//k --kcore -- touch $file > /dev/nul= l 2>&1 perf script -i ${perfdata} -s python:${script_path} -- \ -d --stop-sample=3D30 -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${fi= le} - grep -q -e ${branch_search} ${file} + grep -q -E ${branch_search} ${file} echo "Found kernel branches" else # kcore is required for correct kernel decode due to runtime code patching @@ -59,7 +58,7 @@ echo "Testing userspace disassembly" perf record -o ${perfdata} -e cs_etm//u -- touch $file > /dev/null 2>&1 perf script -i ${perfdata} -s python:${script_path} -- \ -d --stop-sample=3D30 2> /dev/null > ${file} -grep -q -e ${branch_search} ${file} +grep -q -E ${branch_search} ${file} echo "Found userspace branches" =20 glb_err=3D0 --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 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 CB4054657C8 for ; Wed, 3 Jun 2026 10:17:42 +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=1780481865; cv=none; b=BSYpS1q1TCdsV4H1yva+mj3tmz0jwknoSsB1bpbraztHyM/s5vMnvK4CzzQUr2lcYcNlDuQqJRkr2uP4f1ArGx3CN8F1wRr14mACrBIVsc1FWfyJ7WPQr4APC1O/a+Jq2I5xIV2DUKffYTuKxTqNIRH9ngGWS7ESc1KuacM/qto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481865; c=relaxed/simple; bh=8LSDPEyYFg9oEMScO6e3DlP1X0ZKaHJzrU3+/imMTps=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lqQ1ALUA8omvjNDxrkuewn2Eng7s3/OKgdp2uqDTh2oqYco2BjgJYDc1SjCL5E4qHYhBYkq8KH+d6hUPfJnkUhuGAmnrp5UCXuBbgO2ymmSJszAsjbxBSbuyMlBNIJOR5+2mrJ0QoCS2SZsjVpZWDGoiQSX/XqjpXrACUBlf4s8= 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=VBpeRwd4; 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="VBpeRwd4" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490af320e2aso26111525e9.2 for ; Wed, 03 Jun 2026 03:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481861; x=1781086661; 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=3CFsmZwqnn6DMPD7vsYdcccNw39lngm7NfIBTUlMynk=; b=VBpeRwd45cPbckMGAt35t3w4Z4+6esStr2Fw4PW7/puLyiucuKIvGsWUWiVqz8LsKR sf9GBjab7BHwK7FU49oAEm/vlems9TxQ78Ho8QmgAbLZztcvD+7yOZw+1v/ZduXGKuNE 0vOj3vkUrmZ30VnuoRXZwWIPnvacO6Qc2Z2wYFLmaY+zIXFN9QyxC29ypuzu30y7V163 AE/2G9z0jhXxbI09DULYfJ/VDOhZJIK6cDUtFY7PGi3yRVvs01yjPftj7mFH70+xVE5W Varb3UUnQs0zzJezaCg+6f3bV7yFE79Ngzg2vDOW0pyA0yy2h2PIUvbsNcOaeRKy3/eE mA6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481861; x=1781086661; 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=3CFsmZwqnn6DMPD7vsYdcccNw39lngm7NfIBTUlMynk=; b=HtUGC4Ls6HNmyxamaOSfbHmojIBPeo1OfKBCeucAA/uEe5JsCa2C+7iTvEAWIAwv61 oNjEpYl7DpG457NEy/eWsxSb71z4U1q4VI88Tnxi2pT+kSbxVGfAJYvCQkvEdTpCqlzl ELcPF5l9AYI3brWNiI1U5zf6g/ZMR1bF3vq0XDAICuOUeodTcJ5RiN7jgKkLrNvg/u+p dzBcjtrCCypdjp34nXq1ye7JR6bUxrD9qrZPbSld0iK8Zx/LuC/ByfaoofFFV8OHbR/J kI13BPjzAX6yZjw33bTbz5fJIYI5SYv02eRmHnasSywxRPGpTGWIFy0YcExIqJiW2e2v ukPQ== X-Forwarded-Encrypted: i=1; AFNElJ/YitZciaJMFC4rD/FCKH1VhjPU0YynpF/QDlLCtWVXqW/IZPH99AiDl05gd754dfcmKVAoZNNVvmC41Y8=@vger.kernel.org X-Gm-Message-State: AOJu0YxlkLJhTgIYxANsKhglaDyLTubNIxCyrs6v/FBErJQR3Vxuej8u XEdQWS4X23GgUvDu0ok97lweKSXwyIGij5eG81z3AVG6OMZrHIbwAIfuuSFXZmx8dCQ= X-Gm-Gg: Acq92OGaxYwPxz3Gy0PdoYpM8mcG+eFMDkeGtdi5pWB3w7YkfPZRKxwd8lHPSKO9pzj vnfU7PaxnXZG8C2IRKzNTSPSiOS4QCeZe2xEaUA5RlKcL+sFgabo/A3b63ubflqWiuDA6z7B6Hc AOcnXVIVBkUpadNoEW4q9zrj1ipWqzg2uTV7Nglk3D33FNJnYJk3sqAJ64ypirYGD9sS7kO0Q+5 /pwPT0U8L5NMXWjVD5gkizNUmfwlJPN2IEPCX88QUx6BCJnhXJ8aTkjWpIQrRhF7Dx4zrRk2820 fMYJv7BA3mNf+hiyojJycWWVb6Y4ioz6WNTCWwBogXgl6ALZUtxFO5eMR2SiGADt7B9KTIPJ5tj 4F7fOegcJOtTfqi1kadW2owmx/3dsu9hsOYY1pIdDNMox5hduRfuuw2h7tdBagUWv2QlNl7D7qY Kp32OsTuUYp8IDN9fpXi3TdjRqL5rnBv/Ok0sB29ces+4= X-Received: by 2002:a05:600c:a311:b0:490:b724:dbe3 with SMTP id 5b1f17b1804b1-490b724ddb5mr31187235e9.8.1780481861383; Wed, 03 Jun 2026 03:17:41 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:41 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:22 +0100 Subject: [PATCH v3 18/19] perf test cs-etm: Speed up disassembly test 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: <20260603-james-cs-context-tracking-fix-v3-18-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 We can use exit snapshot to limit the amount of trace to decode here too. Also each call to objdump is quite expensive on kcore so limit it to 2 samples instead of 30. We only want to see if there is no data at all. Signed-off-by: James Clark --- tools/perf/tests/shell/test_arm_coresight_disasm.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_coresight_disasm.sh b/tools/pe= rf/tests/shell/test_arm_coresight_disasm.sh index 5ee87eb7973e..2a400fd38a36 100755 --- a/tools/perf/tests/shell/test_arm_coresight_disasm.sh +++ b/tools/perf/tests/shell/test_arm_coresight_disasm.sh @@ -43,9 +43,9 @@ branch_search=3D'[[:space:]](bl|b(\.(eq|ne|cs|cc|mi|pl|vs= |vc|hi|ls|ge|lt|gt|le|al) ## Test kernel ## if [ -e /proc/kcore ]; then echo "Testing kernel disassembly" - perf record -o ${perfdata} -e cs_etm//k --kcore -- touch $file > /dev/nul= l 2>&1 + perf record -o ${perfdata} -e cs_etm//k --kcore -Se -m,64K -- touch $file= > /dev/null 2>&1 perf script -i ${perfdata} -s python:${script_path} -- \ - -d --stop-sample=3D30 -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${fi= le} + -d --stop-sample=3D2 -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${fil= e} grep -q -E ${branch_search} ${file} echo "Found kernel branches" else @@ -55,9 +55,9 @@ fi =20 ## Test user ## echo "Testing userspace disassembly" -perf record -o ${perfdata} -e cs_etm//u -- touch $file > /dev/null 2>&1 +perf record -o ${perfdata} -e cs_etm//u -Se -m,64K -- touch $file > /dev/n= ull 2>&1 perf script -i ${perfdata} -s python:${script_path} -- \ - -d --stop-sample=3D30 2> /dev/null > ${file} + -d --stop-sample=3D2 2> /dev/null > ${file} grep -q -E ${branch_search} ${file} echo "Found userspace branches" =20 --=20 2.34.1 From nobody Mon Jun 8 04:25:58 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 0B3F0466B55 for ; Wed, 3 Jun 2026 10:17:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481866; cv=none; b=cGltxl3MMfkad9BDC5kDbS/qrWEcLXsVLX0PhHh+cLRj6KsVXIon/pedICygPV76HWUBi+EQTjs2UkGxjW3Dx7ehOBmADAhrpzp4VmPxDrdlFdQHh0OUWziMdq3jSe3i3lTQqiiJJflCJP6Aqv/jjrGAnEOM3qb1CayVuu4sojs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481866; c=relaxed/simple; bh=UqUTcZlsYRMZ7HrUOPVdOIyjHND7lnBLRlj9pGTngF8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bydcKJRwqIikpFdtaxtH4Ie9VYCFdTaDnNsbp8ETsOGUOV2bjGf/hNASgpABuhUfuFIQ9A/ltYg75404x++aY2gUtFMWUL/aeNoSJHgyiWGbtyPwgE/K9NJi0FxoncfyQG3z/zmQDvHZaYMBg5Kkb+e975P64TQMaQv1vA+D+rI= 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=i0Wlt+RP; arc=none smtp.client-ip=209.85.128.47 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="i0Wlt+RP" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so94283565e9.0 for ; Wed, 03 Jun 2026 03:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780481862; x=1781086662; 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=eCyit+MYNey9T5qQgf6spNYkow7XxVLTYJAiVVbCmNE=; b=i0Wlt+RPcv44qhtF5udBvR8aHl6ithT7E5Mny7TyZAELaBbygssmh0taH+i/OYHja6 q/KpjtdsIRuXHERpimbuHLGQxE3ZP/c52GjM1UZZi5yeJOgTicoVh/pPHkH6mK80h4IV e3suAomkmYzwkNzmUaEqgX2j2GLLjs0BuGAf97ibu6s6JeN+H7I1q8uHLB/v3q6FqdjZ J9B9RSq+fgps6rzJ5gpXLdTdXbbJ0dsd1h026TuvyIdOVqqPQ3GiRwiE7Vwmv9vGnFek adBK8bKbPOE4dwePGotL7I7fmFYJIrMAIJ0FTftxGaCNfDwdzhJAviuJAq8ILYF++Sfq zFBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481862; x=1781086662; 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=eCyit+MYNey9T5qQgf6spNYkow7XxVLTYJAiVVbCmNE=; b=TUUKIbLfb0KEdAz0Rgw43kegVxvSE1WQW1fTN6Oo2bAJv5u1yAC99xZ7cUmRvGfA2h HGwTwsuKCJ8rqwIpIOEE/+Um1N3e6xf/z7r63EuHUBYqF9Z78HzdO6WAJqt3LX6YFfq1 QuYpXr6OK2CvRV44XFDt/tiScwxWVvQ+51pzBm329iKdd1htj5+jcj9jouESddVJgV2f 1IGzq9rD+QOcIIKLJQMQk5Ggyu4lrcfqA/Ue35pg8fyBjSVtO+eFKSC4kedmXhCj/PWh YN6kB6ZjyQ1f01MiQ2MdbuP5oJzs4HO0gfLrBxAZsqfIPQ63gAeHNrUUfPGhQ/pLO40M 89vg== X-Forwarded-Encrypted: i=1; AFNElJ8OWb2i+zq+kfmuX0hZdee7CHwc1S741slXdrAF+aZLYJtxtydQY/tbeL8ICMnJRMm6c+V1PJqkvAjpwtg=@vger.kernel.org X-Gm-Message-State: AOJu0YwRu2ZoADFJLBgCgkDMgBSkswgXBpRdgiq7LdMnMrKXGyVFLx/g iVsHjkeIDMYaOxuefQT++hUIrBCjlPmCwkN/GOzbVwLTZeis7NbAYsT3o3QcwVpei4k= X-Gm-Gg: Acq92OErmWMHCo7BzDVI/gex49gQcjtlulLHZM+XleiUvve7C3mUHBSTlHqqxFUkobS cfUekGaK2BJRoEMxoKrs3uvwlABhXZkhSrCe4eUcyC6vrgiuasLZdzc+Fdyy0z907Cv5lxhjrJ7 Mjn6lQo9dLXKWQc/03OjF5tzle35/XhF/KwpTpLuS0Xbo41ZiDj0FmBsqt7OHILP63SWTyYUkCv IQJJpNxBHSRZCy6pfRCJnVErvGRN87geyfm0EDQF0bRR9hfvA/XHwRfnMXLvVJdmvWSPeUSp4C+ 199Nptm/I8EpM4NyA/m3LEWMw2Wv4BjXfr1rm/q1YL6P44ykfybOROAsi4lEstdFElwuJn0kXa8 BnyfNiq47luTd/AtclVjKELNY8z0EOz7y5+s6/AQjpiH2rEuVc3VJr2vpR+onSgtNL2WIn5az96 Z1K+rMday4Z3GI3H+hiFUUuMEqqqF85IZtEb/SntvYQ9c= X-Received: by 2002:a05:600c:1c1e:b0:490:44eb:c1e0 with SMTP id 5b1f17b1804b1-490b5ed1318mr45363175e9.21.1780481862441; Wed, 03 Jun 2026 03:17:42 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63d8205sm38681875e9.11.2026.06.03.03.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:17:42 -0700 (PDT) From: James Clark Date: Wed, 03 Jun 2026 11:17:23 +0100 Subject: [PATCH v3 19/19] perf test cs-etm: Move existing tests to coresight folder 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: <20260603-james-cs-context-tracking-fix-v3-19-c392945d9ed5@linaro.org> References: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org> To: Suzuki K Poulose , Mike Leach , Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis Cc: coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 There is a subfolder for Coresight tests so might as well keep them all in here. Signed-off-by: James Clark --- MAINTAINERS | 1 - tools/perf/tests/shell/{ =3D> coresight}/test_arm_coresight.sh | 0 tools/perf/tests/shell/{ =3D> coresight}/test_arm_coresight_disasm.sh | 2 = +- 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 7efb893edcbb..ff8935b459ea 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2749,7 +2749,6 @@ F: tools/perf/arch/arm/util/auxtrace.c F: tools/perf/arch/arm/util/cs-etm.c F: tools/perf/arch/arm/util/cs-etm.h F: tools/perf/arch/arm/util/pmu.c -F: tools/perf/tests/shell/*coresight* F: tools/perf/tests/shell/coresight/* F: tools/perf/util/cs-etm-decoder/* F: tools/perf/util/cs-etm.* diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/test= s/shell/coresight/test_arm_coresight.sh similarity index 100% rename from tools/perf/tests/shell/test_arm_coresight.sh rename to tools/perf/tests/shell/coresight/test_arm_coresight.sh diff --git a/tools/perf/tests/shell/test_arm_coresight_disasm.sh b/tools/pe= rf/tests/shell/coresight/test_arm_coresight_disasm.sh similarity index 96% rename from tools/perf/tests/shell/test_arm_coresight_disasm.sh rename to tools/perf/tests/shell/coresight/test_arm_coresight_disasm.sh index 2a400fd38a36..b196aab709f8 100755 --- a/tools/perf/tests/shell/test_arm_coresight_disasm.sh +++ b/tools/perf/tests/shell/coresight/test_arm_coresight_disasm.sh @@ -24,7 +24,7 @@ perfdata_dir=3D$(mktemp -d /tmp/__perf_test.perf.data.XXX= XX) perfdata=3D${perfdata_dir}/perf.data file=3D$(mktemp /tmp/temporary_file.XXXXX) # Relative path works whether it's installed or running from repo -script_path=3D$(dirname "$0")/../../scripts/python/arm-cs-trace-disasm.py +script_path=3D$(dirname "$0")/../../../scripts/python/arm-cs-trace-disasm.= py =20 cleanup_files() { --=20 2.34.1