diff mbox series

[v3,2/8] hash: fix a multi-writer bug

Message ID 1530906406-289697-3-git-send-email-yipeng1.wang@intel.com (mailing list archive)
State Superseded, archived
Headers show
Series Add read-write concurrency to rte_hash library | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Wang, Yipeng1 July 6, 2018, 7:46 p.m. UTC
Current multi-writer implementation uses Intel TSX to
protect the cuckoo path moving but not the cuckoo
path searching. After searching, we need to verify again if
the same empty slot still exists at the beginning of the TSX
region. Otherwise another writer could occupy the empty slot
before the TSX region. Current code does not verify.

Fixes: be856325cba3 ("hash: add scalable multi-writer insertion with Intel TSX")
Cc: stable@dpdk.org

Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
---
 lib/librte_hash/rte_cuckoo_hash_x86.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Pablo de Lara July 9, 2018, 2:16 p.m. UTC | #1
> -----Original Message-----
> From: Wang, Yipeng1
> Sent: Friday, July 6, 2018 8:47 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: dev@dpdk.org; Wang, Yipeng1 <yipeng1.wang@intel.com>; Richardson,
> Bruce <bruce.richardson@intel.com>; honnappa.nagarahalli@arm.com;
> vguvva@caviumnetworks.com; brijesh.s.singh@gmail.com
> Subject: [PATCH v3 2/8] hash: fix a multi-writer bug

Just a minor comment on the title. It should be a summary of the commit
(try to summarize the bug, instead of using the word "bug").
Keep my ack for the next version (like in other patches).

> 
> Current multi-writer implementation uses Intel TSX to protect the cuckoo path
> moving but not the cuckoo path searching. After searching, we need to verify
> again if the same empty slot still exists at the beginning of the TSX region.
> Otherwise another writer could occupy the empty slot before the TSX region.
> Current code does not verify.
> 
> Fixes: be856325cba3 ("hash: add scalable multi-writer insertion with Intel TSX")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
diff mbox series

Patch

diff --git a/lib/librte_hash/rte_cuckoo_hash_x86.h b/lib/librte_hash/rte_cuckoo_hash_x86.h
index 2c5b017..981d7bd 100644
--- a/lib/librte_hash/rte_cuckoo_hash_x86.h
+++ b/lib/librte_hash/rte_cuckoo_hash_x86.h
@@ -66,6 +66,9 @@  rte_hash_cuckoo_move_insert_mw_tm(const struct rte_hash *h,
 	while (try < RTE_HASH_TSX_MAX_RETRY) {
 		status = rte_xbegin();
 		if (likely(status == RTE_XBEGIN_STARTED)) {
+			/* In case empty slot was gone before entering TSX */
+			if (curr_bkt->key_idx[curr_slot] != EMPTY_SLOT)
+				rte_xabort(RTE_XABORT_CUCKOO_PATH_INVALIDED);
 			while (likely(curr_node->prev != NULL)) {
 				prev_node = curr_node->prev;
 				prev_bkt = prev_node->bkt;