[PATCH] coresight: perf: End AUX output when an event is throttled

Suzuki K Poulose suzuki.poulose at arm.com
Tue Nov 24 07:41:41 PST 2026


On 24/11/2026 15:35, Leo Yan wrote:
> On Tue, Nov 24, 2026 at 01:06:04PM +0000, Suzuki K Poulose wrote:
> 
>>> Check AUX handle ownership before updating the buffer or ending AUX
>>> output. Drop the post-update check because the full stop runs with
>>> local IRQs disabled, which prevents the TRBE IRQ from closing the
>>> handle during the stop.
> 
> ...
> 
>>> +	if (mode & PERF_EF_UPDATE) {
>>>    		/* update trace information */
>>> -		if (!sink_ops(sink)->update_buffer)
>>> -			return;
>>> -
>>> -		size = sink_ops(sink)->update_buffer(sink, handle,
>>> -					      event_data->snk_config);
>>> -		/*
>>> -		 * Make sure the handle is still valid as the
>>> -		 * sink could have closed it from an IRQ.
>>> -		 * The sink driver must handle the race with
>>> -		 * update_buffer() and IRQ. Thus either we
>>> -		 * should get a valid handle and valid size
>>> -		 * (which may be 0).
>>> -		 *
>>> -		 * But we should never get a non-zero size with
>>> -		 * an invalid handle.
>>> -		 */
>>> -		if (READ_ONCE(handle->event))
>>> -			perf_aux_output_end(handle, size);
>>> -		else
>>> -			WARN_ON(size);
>>> +		if (sink_ops(sink)->update_buffer)
>>> +			size = sink_ops(sink)->update_buffer(sink, handle,
>>> +							     event_data->snk_config);
>>
>> Could we retain the READ_ONCE() check to handle the TRBE case here ? This
>> looks like introducing a regression. Something like :
>>
>> 		if (!READ_ONCE(handle->event)) {
>> 			WARN_ON(size);
>> 			goto out;
>> 		}
>>
>>
>>>    	}
>>
>>
>> Otherwise looks good to me
> 
> etm_event_stop() runs with local IRQ disabled, so the TRBE IRQ handler
> cannot close the AUX handle during the stop. If the handler closed it
> earlier, the ownership check before update_buffer() catches that case.
> 
> The second READ_ONCE(handle->event) check is redundant and is safe to
> be removed.

Of course, yes. agreed. Thanks for the clarification

Cheers
Suzuki

> 
> Thanks,
> Leo




More information about the linux-arm-kernel mailing list