netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "haibinzhang(张海斌)" <haibinzhang@tencent.com>,
	"mst@redhat.com" <mst@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "lidongchen(陈立东)" <lidongchen@tencent.com>,
	"yunfangtai(台运方)" <yunfangtai@tencent.com>
Subject: Re: [PATCH] vhost-net: add time limitation for tx polling(Internet mail)
Date: Wed, 28 Mar 2018 14:37:04 +0800	[thread overview]
Message-ID: <0b1846d3-dfcf-df0c-f94c-65d414331d88@redhat.com> (raw)
In-Reply-To: <88D661ADF6AFBF42B2AB88D8E7682B0901FC412A@EXMBX-SZMAIL011.tencent.com>



On 2018年03月28日 12:01, haibinzhang(张海斌) wrote:
> On 2018年03月27日 19:26, Jason wrote
> On 2018年03月27日 17:12, haibinzhang wrote:
>>> handle_tx() will delay rx for a long time when busy tx polling udp packets
>>> with short length(ie: 1byte udp payload), because setting VHOST_NET_WEIGHT
>>> takes into account only sent-bytes but no time.
>> Interesting.
>>
>> Looking at vhost_can_busy_poll() it tries to poke pending vhost work and
>> exit the busy loop if it found one. So I believe something block the
>> work queuing. E.g did reverting 8241a1e466cd56e6c10472cac9c1ad4e54bc65db
>> fix the issue?
> "busy tx polling" means using netperf send udp packets with 1 bytes payload(total 47bytes frame lenght),
> and handle_tx() will be busy sending packets continuously.
>
>>>    It's not fair for handle_rx(),
>>> so needs to limit max time of tx polling.
>>>
>>> ---
>>>    drivers/vhost/net.c | 3 ++-
>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
>>> index 8139bc70ad7d..dc9218a3a75b 100644
>>> --- a/drivers/vhost/net.c
>>> +++ b/drivers/vhost/net.c
>>> @@ -473,6 +473,7 @@ static void handle_tx(struct vhost_net *net)
>>>    	struct socket *sock;
>>>    	struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
>>>    	bool zcopy, zcopy_used;
>>> +	unsigned long start = jiffies;
>> Checking jiffies is tricky, need to convert it to ms or whatever others.
>>
>>>    
>>>    	mutex_lock(&vq->mutex);
>>>    	sock = vq->private_data;
>>> @@ -580,7 +581,7 @@ static void handle_tx(struct vhost_net *net)
>>>    		else
>>>    			vhost_zerocopy_signal_used(net, vq);
>>>    		vhost_net_tx_packet(net);
>>> -		if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
>>> +		if (unlikely(total_len >= VHOST_NET_WEIGHT) || unlikely(jiffies - start >= 1)) {
>> How value 1 is determined here? And we need a complete test to make sure
>> this won't affect other use cases.
> We just want <1ms ping latency, but actually we are not sure what value is reasonable.
> We have some test results using netperf before this patch as follow,
>
>      Udp payload    1byte    100bytes    1000bytes    1400bytes
>    Ping avg latency    25ms     10ms       2ms         1.5ms
>
> What is other testcases?

Something like https://patchwork.kernel.org/patch/10151645/.

Btw, you need use time_before() to properly handle jiffies overflow and 
I would also suggest you to try something like #packets limit (e.g 64).

For long term, we definitely need more worker threads.

Thanks

>
>> Another thought is introduce another limit of #packets, but this need
>> benchmark too.
>>
>> Thanks
>>
>>>    			vhost_poll_queue(&vq->poll);
>>>    			break;
>>>    		}
>>

  reply	other threads:[~2018-03-28  6:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28  4:01 [PATCH] vhost-net: add time limitation for tx polling(Internet mail) haibinzhang(张海斌)
2018-03-28  6:37 ` Jason Wang [this message]
2018-03-28 15:31   ` Michael S. Tsirkin
2018-03-29  2:00     ` Jason Wang

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=0b1846d3-dfcf-df0c-f94c-65d414331d88@redhat.com \
    --to=jasowang@redhat.com \
    --cc=haibinzhang@tencent.com \
    --cc=kvm@vger.kernel.org \
    --cc=lidongchen@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=yunfangtai@tencent.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;
as well as URLs for NNTP newsgroup(s).