[PATCH V5 01/12] perf/core: Add aux_pause, aux_resume, aux_start_paused

Adrian Hunter adrian.hunter at intel.com
Sun Feb 11 22:43:11 PST 2024


On 9/02/24 23:10, Andi Kleen wrote:
>> The writes to rb->aux_in_pause_resume must be done
>> only once.  It might be possible to get away without
>> WRITE_ONCE(), but really the compiler should be informed
>> not to make assumptions.
> 
> What stops the NMI from firing here?

That would be fine.

> 
>>>> +  if (READ_ONCE(rb->aux_in_pause_resume))
>>>> +	/* Guard against NMI, NMI loses here */
>>>> +          goto out_restore;
> <----------------------- NMI

That would be fine.

>>>> +  WRITE_ONCE(rb->aux_in_pause_resume, 1);

>From here on, the NMI will see rb->aux_in_pause_resume == 1
and do nothing, up to the point when rb->aux_in_pause_resume == 0
again.

This code is about guarding against NMI.  Interrupts are
disabled, and the rb and event only operate on 1 cpu at a time.

> 
> 
> Even if it isn't racy it needs a clear comment.

It has a comment, but it could be more explanatory.  The code
paradigm is also used in perf_pmu_snapshot_aux().




More information about the linux-arm-kernel mailing list