From 851098b5529c037bdc58eeafe2e5cfab62fd2dbb Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 15 Mar 2015 05:48:00 -0400 Subject: [PATCH] ck_fifo: Add fences to ABA-friendly operations. --- include/ck_fifo.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/ck_fifo.h b/include/ck_fifo.h index 49c7a8a..c75a9fb 100644 --- a/include/ck_fifo.h +++ b/include/ck_fifo.h @@ -262,6 +262,7 @@ ck_fifo_mpmc_enqueue(struct ck_fifo_mpmc *fifo, ck_pr_fence_load(); tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer); next.generation = ck_pr_load_ptr(&tail.pointer->next.generation); + ck_pr_fence_load(); next.pointer = ck_pr_load_ptr(&tail.pointer->next.pointer); if (ck_pr_load_ptr(&fifo->tail.generation) != tail.generation) @@ -314,6 +315,7 @@ ck_fifo_mpmc_tryenqueue(struct ck_fifo_mpmc *fifo, ck_pr_fence_load(); tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer); next.generation = ck_pr_load_ptr(&tail.pointer->next.generation); + ck_pr_fence_load(); next.pointer = ck_pr_load_ptr(&tail.pointer->next.pointer); if (ck_pr_load_ptr(&fifo->tail.generation) != tail.generation) @@ -365,6 +367,7 @@ ck_fifo_mpmc_dequeue(struct ck_fifo_mpmc *fifo, tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer); next.generation = ck_pr_load_ptr(&head.pointer->next.generation); + ck_pr_fence_load(); next.pointer = ck_pr_load_ptr(&head.pointer->next.pointer); update.pointer = next.pointer; @@ -419,6 +422,7 @@ ck_fifo_mpmc_trydequeue(struct ck_fifo_mpmc *fifo, tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer); next.generation = ck_pr_load_ptr(&head.pointer->next.generation); + ck_pr_fence_load(); next.pointer = ck_pr_load_ptr(&head.pointer->next.pointer); update.pointer = next.pointer;