From a26c891f1a4dca803fd47ba2dcbcafdaf92d2d5f Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 21 May 2015 12:27:15 -0400 Subject: [PATCH] ck_hp_fifo: Migrate to ck_hp_set_fence. On Pentium M, this yields 30%-40% reduction in latency. --- include/ck_hp_fifo.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/include/ck_hp_fifo.h b/include/ck_hp_fifo.h index ea7d4f6..c53779f 100644 --- a/include/ck_hp_fifo.h +++ b/include/ck_hp_fifo.h @@ -88,8 +88,7 @@ ck_hp_fifo_enqueue_mpmc(ck_hp_record_t *record, for (;;) { tail = ck_pr_load_ptr(&fifo->tail); - ck_hp_set(record, 0, tail); - ck_pr_fence_store_load(); + ck_hp_set_fence(record, 0, tail); if (tail != ck_pr_load_ptr(&fifo->tail)) continue; @@ -119,8 +118,7 @@ ck_hp_fifo_tryenqueue_mpmc(ck_hp_record_t *record, ck_pr_fence_store_atomic(); tail = ck_pr_load_ptr(&fifo->tail); - ck_hp_set(record, 0, tail); - ck_pr_fence_store_load(); + ck_hp_set_fence(record, 0, tail); if (tail != ck_pr_load_ptr(&fifo->tail)) return false; @@ -147,14 +145,12 @@ ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record, head = ck_pr_load_ptr(&fifo->head); ck_pr_fence_load(); tail = ck_pr_load_ptr(&fifo->tail); - ck_hp_set(record, 0, head); - ck_pr_fence_store_load(); + ck_hp_set_fence(record, 0, head); if (head != ck_pr_load_ptr(&fifo->head)) continue; next = ck_pr_load_ptr(&head->next); - ck_hp_set(record, 1, next); - ck_pr_fence_store_load(); + ck_hp_set_fence(record, 1, next); if (head != ck_pr_load_ptr(&fifo->head)) continue; @@ -182,14 +178,12 @@ ck_hp_fifo_trydequeue_mpmc(ck_hp_record_t *record, head = ck_pr_load_ptr(&fifo->head); ck_pr_fence_load(); tail = ck_pr_load_ptr(&fifo->tail); - ck_hp_set(record, 0, head); - ck_pr_fence_store_load(); + ck_hp_set_fence(record, 0, head); if (head != ck_pr_load_ptr(&fifo->head)) return NULL; next = ck_pr_load_ptr(&head->next); - ck_hp_set(record, 1, next); - ck_pr_fence_store_load(); + ck_hp_set_fence(record, 1, next); if (head != ck_pr_load_ptr(&fifo->head)) return NULL;