summaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-09 20:04:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-09 20:04:10 -0400
commitc18bb396d3d261ebbb4efbc05129c5d354c541e4 (patch)
tree058a1413dd34fe4e1d9a998a43d56f3358b93e36 /drivers/vhost
parentfd3b36d275660c905da9900b078eea341847d5e4 (diff)
parenta2ac99905f1ea8b15997a6ec39af69aa28a3653b (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) The sockmap code has to free socket memory on close if there is corked data, from John Fastabend. 2) Tunnel names coming from userspace need to be length validated. From Eric Dumazet. 3) arp_filter() has to take VRFs properly into account, from Miguel Fadon Perlines. 4) Fix oops in error path of tcf_bpf_init(), from Davide Caratti. 5) Missing idr_remove() in u32_delete_key(), from Cong Wang. 6) More syzbot stuff. Several use of uninitialized value fixes all over, from Eric Dumazet. 7) Do not leak kernel memory to userspace in sctp, also from Eric Dumazet. 8) Discard frames from unused ports in DSA, from Andrew Lunn. 9) Fix DMA mapping and reset/failover problems in ibmvnic, from Thomas Falcon. 10) Do not access dp83640 PHY registers prematurely after reset, from Esben Haabendal. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (46 commits) vhost-net: set packet weight of tx polling to 2 * vq size net: thunderx: rework mac addresses list to u64 array inetpeer: fix uninit-value in inet_getpeer dp83640: Ensure against premature access to PHY registers after reset devlink: convert occ_get op to separate registration ARM: dts: ls1021a: Specify TBIPA register address net/fsl_pq_mdio: Allow explicit speficition of TBIPA address ibmvnic: Do not reset CRQ for Mobility driver resets ibmvnic: Fix failover case for non-redundant configuration ibmvnic: Fix reset scheduler error handling ibmvnic: Zero used TX descriptor counter on reset ibmvnic: Fix DMA mapping mistakes tipc: use the right skb in tipc_sk_fill_sock_diag() sctp: sctp_sockaddr_af must check minimal addr length for AF_INET6 net: dsa: Discard frames from unused ports sctp: do not leak kernel memory to user space soreuseport: initialise timewait reuseport field ipv4: fix uninit-value in ip_route_output_key_hash_rcu() dccp: initialize ireq->ir_mark net: fix uninit-value in __hw_addr_add_ex() ...
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/net.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index edc6fec9ad84..986058a57917 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -44,6 +44,10 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
44 * Using this limit prevents one virtqueue from starving others. */ 44 * Using this limit prevents one virtqueue from starving others. */
45#define VHOST_NET_WEIGHT 0x80000 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/* MAX number of TX used buffers for outstanding zerocopy */ 51/* MAX number of TX used buffers for outstanding zerocopy */
48#define VHOST_MAX_PEND 128 52#define VHOST_MAX_PEND 128
49#define VHOST_GOODCOPY_LEN 256 53#define VHOST_GOODCOPY_LEN 256
@@ -473,6 +477,7 @@ static void handle_tx(struct vhost_net *net)
473 struct socket *sock; 477 struct socket *sock;
474 struct vhost_net_ubuf_ref *uninitialized_var(ubufs); 478 struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
475 bool zcopy, zcopy_used; 479 bool zcopy, zcopy_used;
480 int sent_pkts = 0;
476 481
477 mutex_lock(&vq->mutex); 482 mutex_lock(&vq->mutex);
478 sock = vq->private_data; 483 sock = vq->private_data;
@@ -580,7 +585,8 @@ static void handle_tx(struct vhost_net *net)
580 else 585 else
581 vhost_zerocopy_signal_used(net, vq); 586 vhost_zerocopy_signal_used(net, vq);
582 vhost_net_tx_packet(net); 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 vhost_poll_queue(&vq->poll); 590 vhost_poll_queue(&vq->poll);
585 break; 591 break;
586 } 592 }