Commit 015949ec authored by Robin Cheng's avatar Robin Cheng Committed by Facebook GitHub Bot

Fix an atomic memory ordering issue in SIMD version of the ConcurrentHashMap.

Summary: The find path reads a node that the insert path writes; they need to have acquire/release semantics due to the node being allocated on the fly.

Reviewed By: yfeldblum, magedm

Differential Revision: D22937394

fbshipit-source-id: c1497ed1764cd43e396bc520e9b716cdfe29e5ca
parent bdf5690a
......@@ -865,7 +865,7 @@ class alignas(64) SIMDTable {
FOLLY_SAFE_DCHECK(
index < kCapacity && (tag == 0x0 || (tag >= 0x80 && tag <= 0xff)),
"");
item(index).store(node, std::memory_order_relaxed);
item(index).store(node, std::memory_order_release);
setTag(index, tag);
}
......@@ -1441,7 +1441,7 @@ class alignas(64) SIMDTable {
auto hits = chunk->tagMatchIter(hp.second);
while (hits.hasNext()) {
tag_idx = hits.next();
Node* node = chunk->item(tag_idx).load(std::memory_order_relaxed);
Node* node = chunk->item(tag_idx).load(std::memory_order_acquire);
if (LIKELY(node && KeyEqual()(k, node->getItem().first))) {
chunk_idx = (chunk_idx & (ccount - 1));
return node;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment