[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d53ef26d-a7e6-4b3b-b593-be75425c0e77@intel.com>
Date: Fri, 9 Feb 2024 10:14:44 +0200
From: Adrian Hunter <adrian.hunter@...el.com>
To: Andi Kleen <ak@...ux.intel.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Heiko Carstens <hca@...ux.ibm.com>, Thomas Richter <tmricht@...ux.ibm.com>,
Hendrik Brueckner <brueckner@...ux.ibm.com>,
Suzuki K Poulose <suzuki.poulose@....com>, Mike Leach
<mike.leach@...aro.org>, James Clark <james.clark@....com>,
coresight@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org,
Yicong Yang <yangyicong@...ilicon.com>,
Jonathan Cameron <jonathan.cameron@...wei.com>, Will Deacon
<will@...nel.org>, Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH V5 01/12] perf/core: Add aux_pause, aux_resume,
aux_start_paused
On 9/02/24 02:13, Andi Kleen wrote:
>> +static void __perf_event_aux_pause(struct perf_event *event, bool pause)
>> +{
>> + if (pause) {
>> + if (!READ_ONCE(event->aux_paused)) {
>> + WRITE_ONCE(event->aux_paused, 1);
>> + event->pmu->stop(event, PERF_EF_PAUSE);
>> + }
>> + } else {
>> + if (READ_ONCE(event->aux_paused)) {
>> + WRITE_ONCE(event->aux_paused, 0);
>> + event->pmu->start(event, PERF_EF_RESUME);
>> + }
>
> This doesn't look atomic. Either the READ/WRITE once are not needed,
> or you need an actually atomic construct.
Yes READ_ONCE / WRITE_ONCE is not really needed here.
>
>> +
>> + rb = ring_buffer_get(event);
>> + if (!rb)
>> + return;
>> +
>> + local_irq_save(flags);
>> + /* Guard against NMI, NMI loses here */
>> + if (READ_ONCE(rb->aux_in_pause_resume))
>> + goto out_restore;
>> + WRITE_ONCE(rb->aux_in_pause_resume, 1);
>
>
>> + barrier();
>> + __perf_event_aux_pause(event, pause);
>> + barrier();
>> + WRITE_ONCE(rb->aux_in_pause_resume, 0);
>
> Dito.
>
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.
Powered by blists - more mailing lists