Skip to content

Commit 02165ce

Browse files
hjelmnjsquyres
authored andcommitted
btl/vader: ensure the fast box tag is always read first
On some platfoms reading a 64-bit value is non-atomic and it is possible that the two 32-bit values are read in the wrong order. To ensure the tag is always read first this commit reads the tag before reading the full 64-bit value. Signed-off-by: Nathan Hjelm <[email protected]> (cherry picked from commit 66a7dc4)
1 parent 0690c67 commit 02165ce

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

opal/mca/btl/vader/btl_vader_fbox.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ static inline void mca_btl_vader_fbox_set_header (mca_btl_vader_fbox_hdr_t *hdr,
5656
hdr->data.tag = tag;
5757
}
5858

59+
static inline mca_btl_vader_fbox_hdr_t mca_btl_vader_fbox_read_header (mca_btl_vader_fbox_hdr_t *hdr)
60+
{
61+
mca_btl_vader_fbox_hdr_t tmp;
62+
uint16_t tag = hdr->data.tag;
63+
opal_atomic_rmb ();
64+
tmp.ival = hdr->ival;
65+
tmp.data.tag = tag;
66+
return tmp;
67+
}
68+
5969
/* attempt to reserve a contiguous segment from the remote ep */
6070
static inline bool mca_btl_vader_fbox_sendi (mca_btl_base_endpoint_t *ep, unsigned char tag,
6171
void * restrict header, const size_t header_size,
@@ -175,7 +185,7 @@ static inline bool mca_btl_vader_check_fboxes (void)
175185
int poll_count;
176186

177187
for (poll_count = 0 ; poll_count <= MCA_BTL_VADER_POLL_COUNT ; ++poll_count) {
178-
const mca_btl_vader_fbox_hdr_t hdr = {.ival = MCA_BTL_VADER_FBOX_HDR(ep->fbox_in.buffer + start)->ival};
188+
const mca_btl_vader_fbox_hdr_t hdr = mca_btl_vader_fbox_read_header (MCA_BTL_VADER_FBOX_HDR(ep->fbox_in.buffer + start));
179189

180190
/* check for a valid tag a sequence number */
181191
if (0 == hdr.data.tag || hdr.data.seq != ep->fbox_in.seq) {

0 commit comments

Comments
 (0)