lkml.org 
[lkml]   [2021]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@intel.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

\
 
 \ /
  Last update: 2021-06-02 14:40    [W:0.067 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site