From 05b652eb724b8e4f18ad09b651300634fa5e5c5b Mon Sep 17 00:00:00 2001 From: Veerababu Arja Date: Tue, 6 Jun 2023 15:43:35 -0700 Subject: [PATCH] Update bf_sys_dma_hugepages.c (#25) The __sync_val_compare_and_swap() call is not made while unlocking the locked code, this causes the compiler to rearrange the code for optimization and hence defeats the purpose of the lock. --- src/bf_sal/linux_usr/bf_sys_dma_hugepages.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bf_sal/linux_usr/bf_sys_dma_hugepages.c b/src/bf_sal/linux_usr/bf_sys_dma_hugepages.c index 935e861..17398b8 100644 --- a/src/bf_sal/linux_usr/bf_sys_dma_hugepages.c +++ b/src/bf_sal/linux_usr/bf_sys_dma_hugepages.c @@ -504,7 +504,7 @@ static int bf_pop_free_buf(bf_huge_pool_t *pool, void **buf_ptr) { *buf_ptr = (pool->pool_buf_ptr)[pool->pool_buf_offset++]; } /* open the gate */ - pool->pool_gate = 0; + __sync_val_compare_and_swap(&pool->pool_gate, 1, 0); return err; } @@ -524,7 +524,7 @@ static int bf_push_free_buf(bf_huge_pool_t *pool, void *buf_ptr) { } /* open the gate */ - pool->pool_gate = 0; + __sync_val_compare_and_swap(&pool->pool_gate, 1, 0); return err; }