File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
44
44
* Using this limit prevents one virtqueue from starving others. */
45
45
#define VHOST_NET_WEIGHT 0x80000
46
46
47
+ /* Max number of packets transferred before requeueing the job.
48
+ * Using this limit prevents one virtqueue from starving rx. */
49
+ #define VHOST_NET_PKT_WEIGHT (vq ) ((vq)->num * 2)
50
+
47
51
/* MAX number of TX used buffers for outstanding zerocopy */
48
52
#define VHOST_MAX_PEND 128
49
53
#define VHOST_GOODCOPY_LEN 256
@@ -473,6 +477,7 @@ static void handle_tx(struct vhost_net *net)
473
477
struct socket * sock ;
474
478
struct vhost_net_ubuf_ref * uninitialized_var (ubufs );
475
479
bool zcopy , zcopy_used ;
480
+ int sent_pkts = 0 ;
476
481
477
482
mutex_lock (& vq -> mutex );
478
483
sock = vq -> private_data ;
@@ -580,7 +585,8 @@ static void handle_tx(struct vhost_net *net)
580
585
else
581
586
vhost_zerocopy_signal_used (net , vq );
582
587
vhost_net_tx_packet (net );
583
- if (unlikely (total_len >= VHOST_NET_WEIGHT )) {
588
+ if (unlikely (total_len >= VHOST_NET_WEIGHT ) ||
589
+ unlikely (++ sent_pkts >= VHOST_NET_PKT_WEIGHT (vq ))) {
584
590
vhost_poll_queue (& vq -> poll );
585
591
break ;
586
592
}
You can’t perform that action at this time.
0 commit comments