From ccbf28f0cb4f1c97775f4a78e136f8790fbaac4d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 17 Aug 2012 11:26:04 -0400 Subject: [PATCH] ck_fifo: Remove unused variables, serialize MPMC insertion. --- include/ck_fifo.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/include/ck_fifo.h b/include/ck_fifo.h index a0eb548..5ba8178 100644 --- a/include/ck_fifo.h +++ b/include/ck_fifo.h @@ -130,8 +130,7 @@ ck_fifo_spsc_enqueue(struct ck_fifo_spsc *fifo, CK_CC_INLINE static bool ck_fifo_spsc_dequeue(struct ck_fifo_spsc *fifo, void *value) { - struct ck_fifo_spsc_entry *stub, *entry; - void *store; + struct ck_fifo_spsc_entry *entry; /* * The head pointer is guaranteed to always point to a stub entry. @@ -217,12 +216,10 @@ CK_CC_INLINE static void ck_fifo_mpmc_init(struct ck_fifo_mpmc *fifo, struct ck_fifo_mpmc_entry *stub) { - ck_pr_store_ptr(&fifo->head.pointer, stub); - ck_pr_store_ptr(&fifo->head.generation, 0); - ck_pr_store_ptr(&fifo->tail.pointer, stub); - ck_pr_store_ptr(&fifo->tail.generation, 0); - ck_pr_store_ptr(&stub->next.pointer, NULL); - ck_pr_store_ptr(&stub->next.generation, 0); + stub->next.pointer = NULL; + stub->next.generation = NULL; + fifo->head.pointer = fifo->tail.pointer = stub; + fifo->head.generation = fifo->tail.generation = NULL; return; } @@ -277,6 +274,7 @@ ck_fifo_mpmc_enqueue(struct ck_fifo_mpmc *fifo, /* After a successful insert, forward the tail to the new entry. */ update.generation = tail.generation + 1; + ck_pr_fence_store(); ck_pr_cas_ptr_2(&fifo->tail, &tail, &update); return; } @@ -327,6 +325,7 @@ ck_fifo_mpmc_tryenqueue(struct ck_fifo_mpmc *fifo, } /* After a successful insert, forward the tail to the new entry. */ + ck_pr_fence_store(); update.generation = tail.generation + 1; ck_pr_cas_ptr_2(&fifo->tail, &tail, &update); return true;