diff --git a/include/ck_fifo.h b/include/ck_fifo.h index 09fb382..42a9a0c 100644 --- a/include/ck_fifo.h +++ b/include/ck_fifo.h @@ -155,8 +155,6 @@ struct ck_fifo_mpmc { struct ck_fifo_mpmc_pointer head; char pad[CK_MD_CACHELINE - sizeof(struct ck_fifo_mpmc_pointer)]; struct ck_fifo_mpmc_pointer tail; - struct ck_fifo_mpmc_entry *head_snapshot; - struct ck_fifo_mpmc_pointer garbage; }; typedef struct ck_fifo_mpmc ck_fifo_mpmc_t; @@ -170,8 +168,6 @@ ck_fifo_mpmc_init(struct ck_fifo_mpmc *fifo, struct ck_fifo_mpmc_entry *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); - ck_pr_store_ptr(&fifo->head_snapshot, stub); - ck_pr_store_ptr(&fifo->garbage, stub); return; } @@ -233,7 +229,7 @@ ck_fifo_mpmc_enqueue(struct ck_fifo_mpmc *fifo, struct ck_fifo_mpmc_entry *entry } CK_CC_INLINE static bool -ck_fifo_mpmc_dequeue(struct ck_fifo_mpmc *fifo, void *value) +ck_fifo_mpmc_dequeue(struct ck_fifo_mpmc *fifo, void *value, ck_fifo_mpmc_entry_t **garbage) { struct ck_fifo_mpmc_pointer head, tail, next, update; ck_backoff_t backoff = CK_BACKOFF_INITIALIZER; @@ -274,6 +270,7 @@ ck_fifo_mpmc_dequeue(struct ck_fifo_mpmc *fifo, void *value) } } + *garbage = head.pointer; return (true); } diff --git a/regressions/ck_fifo/benchmark/latency.c b/regressions/ck_fifo/benchmark/latency.c index 8dbaf0b..ec51918 100644 --- a/regressions/ck_fifo/benchmark/latency.c +++ b/regressions/ck_fifo/benchmark/latency.c @@ -59,6 +59,7 @@ main(void) ck_fifo_mpmc_t mpmc_fifo; ck_fifo_mpmc_entry_t mpmc_entry[ENTRIES]; ck_fifo_mpmc_entry_t mpmc_stub; + ck_fifo_mpmc_entry_t *garbage; #endif #ifdef CK_F_FIFO_SPSC @@ -145,7 +146,7 @@ main(void) s = rdtsc(); for (j = 0; j < ENTRIES; j++) - ck_fifo_mpmc_dequeue(&mpmc_fifo, &r); + ck_fifo_mpmc_dequeue(&mpmc_fifo, &r, &garbage); e = rdtsc(); a += e - s; } diff --git a/regressions/ck_fifo/validate/ck_fifo_mpmc.c b/regressions/ck_fifo/validate/ck_fifo_mpmc.c index 0ce13bf..3e7ac0d 100644 --- a/regressions/ck_fifo/validate/ck_fifo_mpmc.c +++ b/regressions/ck_fifo/validate/ck_fifo_mpmc.c @@ -64,7 +64,7 @@ test(void *c) #ifdef CK_F_FIFO_MPMC struct context *context = c; struct entry *entry; - ck_fifo_mpmc_entry_t *fifo_entry; + ck_fifo_mpmc_entry_t *fifo_entry, *garbage; int i, j; if (aff_iterate(&a)) { @@ -81,7 +81,7 @@ test(void *c) entry = malloc(sizeof(struct entry)); entry->tid = context->tid; ck_fifo_mpmc_enqueue(&fifo, fifo_entry, entry); - if (ck_fifo_mpmc_dequeue(&fifo, &entry) == false) { + if (ck_fifo_mpmc_dequeue(&fifo, &entry, &garbage) == false) { fprintf(stderr, "ERROR [%u] Queue should never be empty.\n", context->tid); exit(EXIT_FAILURE); }