File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,27 @@ static inline opal_list_item_t *opal_fifo_pop_atomic (opal_fifo_t *fifo)
216216{
217217 opal_list_item_t * item , * next ;
218218
219+ #if OPAL_HAVE_ATOMIC_LLSC_PTR
220+ /* use load-linked store-conditional to avoid ABA issues */
221+ do {
222+ item = opal_atomic_ll_ptr (& fifo -> opal_fifo_head .data .item );
223+ if (& fifo -> opal_fifo_ghost == item ) {
224+ if (& fifo -> opal_fifo_ghost == fifo -> opal_fifo_tail .data .item ) {
225+ return NULL ;
226+ }
227+
228+ /* fifo does not appear empty. wait for the fifo to be made
229+ * consistent by conflicting thread. */
230+ continue ;
231+ }
232+
233+ next = (opal_list_item_t * ) item -> opal_list_next ;
234+ if (opal_atomic_sc_ptr (& fifo -> opal_fifo_head .data .item , next )) {
235+ break ;
236+ }
237+ } while (1 );
238+ #else
239+ /* protect against ABA issues by "locking" the head */
219240 do {
220241 if (opal_atomic_cmpset_32 ((int32_t * ) & fifo -> opal_fifo_head .data .counter , 0 , 1 )) {
221242 break ;
@@ -234,6 +255,7 @@ static inline opal_list_item_t *opal_fifo_pop_atomic (opal_fifo_t *fifo)
234255
235256 next = (opal_list_item_t * ) item -> opal_list_next ;
236257 fifo -> opal_fifo_head .data .item = next ;
258+ #endif
237259
238260 if (& fifo -> opal_fifo_ghost == next ) {
239261 if (!opal_atomic_cmpset_ptr (& fifo -> opal_fifo_tail .data .item , item , & fifo -> opal_fifo_ghost )) {
You can’t perform that action at this time.
0 commit comments