lkml.org 
[lkml]   [2018]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf/ring_buffer: ensure atomicity and order of updates
On Thu, May 10, 2018 at 02:06:32PM +0100, Mark Rutland wrote:
> - smp_wmb(); /* B, matches C */
> - rb->user_page->data_head = head;
> + smp_store_release(&rb->user_page->data_head, head); /* B, matches C */

> - rb->user_page->aux_head = rb->aux_head;
> + smp_store_release(&rb->user_page->aux_head, rb->aux_head);

> - rb->user_page->aux_head = rb->aux_head;
> + smp_store_release(&rb->user_page->aux_head, rb->aux_head);


The kbuild test robot has helpfully discovered another latent bug here.

We assume we can make single-copy-atomic accesses to
{aux,data}_{head,tail}, but this isn't necessarily true on 32-bit
architectures, and smp_store_release() rightly complains at build time.

READ_ONCE() and WRITE_ONCE() "helpfully" make a silent fallback to a
memcpy in this case, so we're broken today, regardless of this change.

I suspect that in practice we get single-copy-atomicity for the 32-bit
halves, and sessions likely produce less than 4GiB of ringbuffer data,
so failures would be rare.

I'm not sure how to fix the ABI here. The same issue applies on the
userspace side, so whatever we do we need to fix both sides.

Thanks,
Mark.

\
 
 \ /
  Last update: 2018-05-11 13:00    [W:0.068 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site