From: Wen Gu <guwen@linux.alibaba.com>
To: Hillf Danton <hdanton@sina.com>
Cc: kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com,
edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH net-next v3 9/9] net/smc: Add interface implementation of loopback device
Date: Thu, 23 Feb 2023 10:22:47 +0800 [thread overview]
Message-ID: <3f0b140f-5ee1-0ee1-6984-aed9de3d241a@linux.alibaba.com> (raw)
In-Reply-To: <20230222140931.2716-1-hdanton@sina.com>
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
next parent reply other threads:[~2023-02-23 2:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230222140931.2716-1-hdanton@sina.com>
2023-02-23 2:22 ` Wen Gu [this message]
2023-02-15 16:18 [RFC PATCH net-next v3 0/9] net/smc: Introduce SMC-D-based OS internal communication acceleration Wen Gu
2023-02-15 16:18 ` [RFC PATCH net-next v3 9/9] net/smc: Add interface implementation of loopback device Wen Gu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3f0b140f-5ee1-0ee1-6984-aed9de3d241a@linux.alibaba.com \
--to=guwen@linux.alibaba.com \
--cc=edumazet@google.com \
--cc=hdanton@sina.com \
--cc=jaka@linux.ibm.com \
--cc=kgraul@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wenjia@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox