Skip to content

Commit 1ed83c7

Browse files
committed
Add volatile to the pointer in the list_item structure.
This change has the side effect of improving the performance of all atomic data structures (in addition to making the code crrect under a certain interpretation of the volatile usage). This commit fixes #3450. Signed-off-by: George Bosilca <[email protected]>
1 parent d2f70ff commit 1ed83c7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

opal/class/opal_lifo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ union opal_counted_pointer_t {
4848
/** update counter used when cmpset_128 is available */
4949
uint64_t counter;
5050
/** list item pointer */
51-
opal_list_item_t *item;
51+
volatile opal_list_item_t * volatile item;
5252
} data;
5353
#if OPAL_HAVE_ATOMIC_CMPSET_128 && HAVE_OPAL_INT128_T
5454
/** used for atomics when there is a cmpset that can operate on
@@ -138,14 +138,14 @@ static inline opal_list_item_t *opal_lifo_push_atomic (opal_lifo_t *lifo,
138138
*/
139139
static inline opal_list_item_t *opal_lifo_pop_atomic (opal_lifo_t* lifo)
140140
{
141+
opal_counted_pointer_t old_head;
141142
opal_list_item_t *item;
142143

143144
do {
144-
opal_counted_pointer_t old_head;
145145

146146
old_head.data.counter = lifo->opal_lifo_head.data.counter;
147147
opal_atomic_rmb ();
148-
item = old_head.data.item = lifo->opal_lifo_head.data.item;
148+
old_head.data.item = item = (opal_list_item_t*)lifo->opal_lifo_head.data.item;
149149

150150
if (item == &lifo->opal_lifo_ghost) {
151151
return NULL;

opal/class/opal_list.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ struct opal_list_item_t
103103
{
104104
opal_object_t super;
105105
/**< Generic parent class for all Open MPI objects */
106-
volatile struct opal_list_item_t *opal_list_next;
106+
volatile struct opal_list_item_t * volatile opal_list_next;
107107
/**< Pointer to next list item */
108-
volatile struct opal_list_item_t *opal_list_prev;
108+
volatile struct opal_list_item_t * volatile opal_list_prev;
109109
/**< Pointer to previous list item */
110110
int32_t item_free;
111111

0 commit comments

Comments
 (0)