* [PATCH] vhost-net: add time limitation for tx polling
@ 2018-03-27 9:12 haibinzhang(张海斌)
2018-03-27 9:40 ` Jason Wang
0 siblings, 1 reply; 2+ messages in thread
From: haibinzhang(张海斌) @ 2018-03-27 9:12 UTC (permalink / raw)
To: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
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. It's not fair for handle_rx(),
so needs to limit max time of tx polling.
Signed-off-by: Haibin Zhang <haibinzhang@tencent.com>
---
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;
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)) {
vhost_poll_queue(&vq->poll);
break;
}
--
2.12.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] vhost-net: add time limitation for tx polling
2018-03-27 9:12 [PATCH] vhost-net: add time limitation for tx polling haibinzhang(张海斌)
@ 2018-03-27 9:40 ` Jason Wang
0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2018-03-27 9:40 UTC (permalink / raw)
To: haibinzhang(张海斌), mst@redhat.com,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
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?
> It's not fair for handle_rx(),
> so needs to limit max time of tx polling.
>
> Signed-off-by: Haibin Zhang <haibinzhang@tencent.com>
> ---
> 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.
Another thought is introduce another limit of #packets, but this need
benchmark too.
Thanks
> vhost_poll_queue(&vq->poll);
> break;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-27 9:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-27 9:12 [PATCH] vhost-net: add time limitation for tx polling haibinzhang(张海斌)
2018-03-27 9:40 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox