Skip to contentSkip to conversation

net/smc: Add interface implementation of loopback device

RFC PATCH Wen Gu 1 participant 1 message Feb 23, 2023 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Wen Gu

author
#1 lore raw
Quoted 40 lines · Hillf Danton

On Thu, 16 Feb 2023 00:18:25 +0800 Wen Gu <[email protected]>

Review static int smc_lo_unregister_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb) · line 132

Quoted 8 lines
(quoted diff) +4 -0
@@ -124,12 +126,76 @@ static int smc_lo_unregister_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb)
  	write_unlock(&ldev->dmb_ht_lock);
 
  	clear_bit(dmb_node->sba_idx, ldev->sba_idx_mask);
+
+	/* wait for dmb refcnt to be 0 */
+	if (!refcount_dec_and_test(&dmb_node->refcnt))
+		wait_event(ldev->dmbs_release, !refcount_read(&dmb_node->refcnt));

Wait for zero refcnt with dmb node deleted from hash table.

Quoted 7 lines
(quoted diff) +4 -0
  	kfree(dmb_node->cpu_addr);
  	kfree(dmb_node);
 
+	if (atomic_dec_and_test(&ldev->dmb_cnt))
+		wake_up(&ldev->ldev_release);
+	return 0;
+}

[...]

Quoted 18 lines
(quoted diff) +18 -0
+static int smc_lo_detach_dmb(struct smcd_dev *smcd, u64 token)
+{
+	struct smc_lo_dmb_node *dmb_node = NULL, *tmp_node;
+	struct smc_lo_dev *ldev = smcd->priv;
+
+	/* find dmb_node according to dmb->dmb_tok */
+	read_lock(&ldev->dmb_ht_lock);
+	hash_for_each_possible(ldev->dmb_ht, tmp_node, list, token) {
+		if (tmp_node->token == token) {
+			dmb_node = tmp_node;
+			break;
+		}
+	}
+	if (!dmb_node) {
+		read_unlock(&ldev->dmb_ht_lock);
+		return -EINVAL;
+	}
+	read_unlock(&ldev->dmb_ht_lock);
Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +3 -0
+
+	if (refcount_dec_and_test(&dmb_node->refcnt))
+		wake_up_all(&ldev->dmbs_release);
  	return 0;
  }

Given no wakeup without finding dmb node in hash table, the chance for missing wakeup is not zero.

Good catch! Will fix it.

Thanks,
Wen Gu