lkml.org 
[lkml]   [2023]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH net-next v3 9/9] net/smc: Add interface implementation of loopback device
From


On 2023/2/22 22:09, Hillf Danton wrote:

> On Thu, 16 Feb 2023 00:18:25 +0800 Wen Gu <guwen@linux.alibaba.com>
>> @@ -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.
>
>> kfree(dmb_node->cpu_addr);
>> kfree(dmb_node);
>>
>> + if (atomic_dec_and_test(&ldev->dmb_cnt))
>> + wake_up(&ldev->ldev_release);
>> + return 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);
>> +
>> + 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

\
 
 \ /
  Last update: 2023-03-27 00:33    [W:0.033 / U:3.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site