Commit 1cc8e216 authored by Jeff Moyer's avatar Jeff Moyer Committed by Ben Hutchings

aio: add missing smp_rmb() in read_events_ring

commit 2ff396be upstream.

We ran into a case on ppc64 running mariadb where io_getevents would
return zeroed out I/O events.  After adding instrumentation, it became
clear that there was some missing synchronization between reading the
tail pointer and the events themselves.  This small patch fixes the
problem in testing.

Thanks to Zach for helping to look into this, and suggesting the fix.
Signed-off-by: default avatarJeff Moyer <jmoyer@redhat.com>
Signed-off-by: default avatarBenjamin LaHaise <bcrl@kvack.org>
[bwh: Backported to 3.2: adjust context, indentation]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 11d3b506
...@@ -1102,6 +1102,13 @@ static int aio_read_evt(struct kioctx *ioctx, struct io_event *ent) ...@@ -1102,6 +1102,13 @@ static int aio_read_evt(struct kioctx *ioctx, struct io_event *ent)
head = ring->head % info->nr; head = ring->head % info->nr;
if (head != ring->tail) { if (head != ring->tail) {
struct io_event *evp = aio_ring_event(info, head, KM_USER1); struct io_event *evp = aio_ring_event(info, head, KM_USER1);
/*
* Ensure that once we've read the current tail pointer, that
* we also see the events that were stored up to the tail.
*/
smp_rmb();
*ent = *evp; *ent = *evp;
head = (head + 1) % info->nr; head = (head + 1) % info->nr;
smp_mb(); /* finish reading the event before updatng the head */ smp_mb(); /* finish reading the event before updatng the head */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment