ck_ht: Several critical bug fixes (impacts TSO).

The tombstone and version counter update invariant was not respected
in all necessary places.

- If a concurrent load operation is preempted after observing
  the version counter and key field of a slot, then the slot is moved
  and re-used by another key-value pair, the load operation would
  observe an inconsistent pair without the relevant version counter
  update.

- On RMO architectures, a store fence was missing on the delete path
  (tombstone placement must always be followed by version counter
  update).
ck_pring
Samy Al Bahra 10 years ago
parent 8b20998ecd
commit 48b407f396

@ -462,6 +462,9 @@ ck_ht_gc(struct ck_ht *ht, unsigned long cycles, unsigned long seed)
ck_pr_store_64(&map->deletions, map->deletions + 1);
ck_pr_fence_store();
ck_pr_store_ptr(&entry->key, (void *)CK_HT_KEY_TOMBSTONE);
ck_pr_fence_store();
ck_pr_store_64(&map->deletions, map->deletions + 1);
ck_pr_fence_store();
}
if (cycles == 0) {
@ -786,6 +789,7 @@ ck_ht_remove_spmc(struct ck_ht *table,
* states should be (T, V') or (K', V'). The latter is guaranteed
* through memory fencing.
*/
ck_pr_fence_store();
ck_pr_store_64(&map->deletions, map->deletions + 1);
ck_pr_fence_store();
ck_pr_store_64(&map->n_entries, map->n_entries - 1);
@ -901,6 +905,9 @@ ck_ht_set_spmc(struct ck_ht *table,
ck_pr_store_64(&map->deletions, map->deletions + 1);
ck_pr_fence_store();
ck_pr_store_ptr(&candidate->key, (void *)CK_HT_KEY_TOMBSTONE);
ck_pr_fence_store();
ck_pr_store_64(&map->deletions, map->deletions + 1);
ck_pr_fence_store();
} else {
/*
* In this case we are inserting a new entry or replacing

Loading…
Cancel
Save