[PATCH] vhost: use try_lock in rte_vhost_vring_call
Maxime Coquelin
maxime.coquelin at redhat.com
Tue Sep 20 09:12:51 CEST 2022
On 9/7/22 02:40, Liu, Changpeng wrote:
>
>
>> -----Original Message-----
>> From: Stephen Hemminger <stephen at networkplumber.org>
>> Sent: Wednesday, September 7, 2022 5:16 AM
>> To: Liu, Changpeng <changpeng.liu at intel.com>
>> Cc: dev at dpdk.org; Maxime Coquelin <maxime.coquelin at redhat.com>; Xia,
>> Chenbo <chenbo.xia at intel.com>
>> Subject: Re: [PATCH] vhost: use try_lock in rte_vhost_vring_call
>>
>> On Tue, 6 Sep 2022 10:22:25 +0800
>> Changpeng Liu <changpeng.liu at intel.com> wrote:
>>
>>> Note that this function is in data path, so the thread context
>>> may not same as socket messages processing context, by using
>>> try_lock here, users can have another try in case of VQ's access
>>> lock is held by `vhost-events` thread.
>>>
>>> Signed-off-by: Changpeng Liu <changpeng.liu at intel.com>
>>> ---
>>> lib/vhost/vhost.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
>>> index 60cb05a0ff..072d2acb7b 100644
>>> --- a/lib/vhost/vhost.c
>>> +++ b/lib/vhost/vhost.c
>>> @@ -1329,7 +1329,11 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
>>> if (!vq)
>>> return -1;
>>>
>>> - rte_spinlock_lock(&vq->access_lock);
>>> + if (!rte_spinlock_trylock(&vq->access_lock)) {
>>> + VHOST_LOG_CONFIG(dev->ifname, DEBUG,
>>> + "failed to kick guest, virtqueue busy.\n");
>>> + return -1;
>>> + }
>>>
>>
>> If it is a race, logging a message is not a good idea; the log will fill
>> with this noise.
>>
>> Instead make it statistic that can be seen by xstats.
> It's a DEBUG log, users can't see it in practice.
>
Having an xstat would enable live debugging & post-mortem analysis.
You can have both the stats and the debug log.
Regards,
Maxime
More information about the dev
mailing list