Skip to content

Commit

Permalink
Update bf_sys_dma_hugepages.c (#25)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
varjabarefoot authored Jun 6, 2023
1 parent 5101538 commit 05b652e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bf_sal/linux_usr/bf_sys_dma_hugepages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 05b652e

Please sign in to comment.