From d595bafea756ad4af05bf0e2dd4c5b4a800f994a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Oct 2012 19:48:20 -0400 Subject: [PATCH] ck_ring: Serialize producer snapshot with respect to consumer. --- include/ck_ring.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/ck_ring.h b/include/ck_ring.h index 9c7e3a6..0699706 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -246,6 +246,12 @@ ck_ring_dequeue_spmc(struct ck_ring *ring, void *data) do { position = consumer & ring->mask; + + /* + * Producer counter must represent state relative to + * our latest consumer snapshot. + */ + ck_pr_fence_load(); producer = ck_pr_load_uint(&ring->p_tail); if (position == producer)