[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210602123847.GE10272@leoy-ThinkPad-X240s>
Date: Wed, 2 Jun 2021 20:38:47 +0800
From: Leo Yan <leo.yan@...aro.org>
To: Adrian Hunter <adrian.hunter@...el.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach <mike.leach@...aro.org>,
Andi Kleen <ak@...ux.intel.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
coresight@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 8/8] perf record: Directly bail out for compat case
Hi Adrain,
On Wed, Jun 02, 2021 at 02:18:47PM +0300, Adrian Hunter wrote:
> On 2/06/21 1:30 pm, Leo Yan wrote:
> > Since the 64-bit atomicity is not promised in 32-bit perf, directly
> > report the error and bail out for this case.
> >
> > Now only applies on x86_64 and Arm64 platforms.
> >
> > Suggested-by: Adrian Hunter <adrian.hunter@...el.com>
>
> Maybe we can do better for the compat case.
>
> We can assume the upper 32-bits change very seldom,
> and always increase. So for the 'read' case:
>
> u64 first, second, last;
> u64 mask = (u64)((u32)-1) << 32;
>
> do {
> first = READ_ONCE(pc->aux_head);
> rmb();
> second = READ_ONCE(pc->aux_head);
> rmb();
> last = READ_ONCE(pc->aux_head);
> } while ((first & mask) != (last & mask));
> return second;
>
> For the write case, we can cause a fatal error only if the new
> tail has non-zero upper 32-bits. That gives up to 4GiB of data
> before aborting:
>
> if (tail & mask)
> return -1;
> smp_mb();
> WRITE_ONCE(pc->aux_tail, tail);
Seems to me, it's pointless to only support aux_head for 64-bit and
support aux_tail for 32-bit. I understand this can be helpful for the
snapshot mode which only uses aux_head, but it still fails to support
the normal case for AUX ring buffer using 64-bit head/tail.
Thanks,
Leo
Powered by blists - more mailing lists